summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgcasto@chromium.org <gcasto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-25 14:09:43 +0000
committergcasto@chromium.org <gcasto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-25 14:09:43 +0000
commit53e4e6d9b4cc1db592ac20a10c649cceee27e255 (patch)
treeca37dfa136de08322ef7b526175f958f9e703ce9
parent9b107b6555b94fa82117932be6d65c12270368d8 (diff)
downloadchromium_src-53e4e6d9b4cc1db592ac20a10c649cceee27e255.zip
chromium_src-53e4e6d9b4cc1db592ac20a10c649cceee27e255.tar.gz
chromium_src-53e4e6d9b4cc1db592ac20a10c649cceee27e255.tar.bz2
[Password Autofill] Move UI code to ChromePasswordManagerClient
This is part of the refactoring to make the password manager a layered component. BUG=340675,335043 Review URL: https://codereview.chromium.org/173113005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253158 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/password_manager/chrome_password_manager_client.cc97
-rw-r--r--chrome/browser/password_manager/chrome_password_manager_client.h44
-rw-r--r--chrome/browser/password_manager/content_password_manager_driver.cc37
-rw-r--r--chrome/browser/password_manager/content_password_manager_driver.h11
-rw-r--r--chrome/browser/password_manager/password_generation_interactive_uitest.cc14
-rw-r--r--chrome/browser/password_manager/password_generation_manager.cc81
-rw-r--r--chrome/browser/password_manager/password_generation_manager.h60
-rw-r--r--chrome/browser/password_manager/password_generation_manager_unittest.cc2
-rw-r--r--chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc10
9 files changed, 165 insertions, 191 deletions
diff --git a/chrome/browser/password_manager/chrome_password_manager_client.cc b/chrome/browser/password_manager/chrome_password_manager_client.cc
index 8daf0a4..8e5cf93 100644
--- a/chrome/browser/password_manager/chrome_password_manager_client.cc
+++ b/chrome/browser/password_manager/chrome_password_manager_client.cc
@@ -16,11 +16,17 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
+#include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h"
#include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/chrome_version_info.h"
+#include "components/autofill/content/common/autofill_messages.h"
+#include "components/autofill/core/browser/password_generator.h"
+#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_view.h"
+#include "ipc/ipc_message_macros.h"
#if defined(OS_ANDROID)
#include "chrome/browser/android/password_authentication_manager.h"
@@ -43,7 +49,7 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromePasswordManagerClient);
ChromePasswordManagerClient::ChromePasswordManagerClient(
content::WebContents* web_contents)
- : web_contents_(web_contents),
+ : content::WebContentsObserver(web_contents),
driver_(web_contents, this),
weak_factory_(this) {
// Avoid checking OS password until later on in browser startup
@@ -61,7 +67,7 @@ void ChromePasswordManagerClient::PromptUserToSavePassword(
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableSavePasswordBubble)) {
ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller =
- ManagePasswordsBubbleUIController::FromWebContents(web_contents_);
+ ManagePasswordsBubbleUIController::FromWebContents(web_contents());
if (manage_passwords_bubble_ui_controller) {
manage_passwords_bubble_ui_controller->OnPasswordSubmitted(form_to_save);
} else {
@@ -73,14 +79,14 @@ void ChromePasswordManagerClient::PromptUserToSavePassword(
password_manager_metrics_util::MonitoredDomainGroupId(
form_to_save->realm(), GetPrefs())));
SavePasswordInfoBarDelegate::Create(
- web_contents_, form_to_save, uma_histogram_suffix);
+ web_contents(), form_to_save, uma_histogram_suffix);
}
}
void ChromePasswordManagerClient::PasswordWasAutofilled(
const autofill::PasswordFormMap& best_matches) const {
ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller =
- ManagePasswordsBubbleUIController::FromWebContents(web_contents_);
+ ManagePasswordsBubbleUIController::FromWebContents(web_contents());
if (manage_passwords_bubble_ui_controller &&
CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableSavePasswordBubble)) {
@@ -92,7 +98,7 @@ void ChromePasswordManagerClient::AuthenticateAutofillAndFillForm(
scoped_ptr<autofill::PasswordFormFillData> fill_data) {
#if defined(OS_ANDROID)
PasswordAuthenticationManager::AuthenticatePasswordAutofill(
- web_contents_,
+ web_contents(),
base::Bind(&ChromePasswordManagerClient::CommitFillPasswordForm,
weak_factory_.GetWeakPtr(),
base::Owned(fill_data.release())));
@@ -104,7 +110,12 @@ void ChromePasswordManagerClient::AuthenticateAutofillAndFillForm(
}
Profile* ChromePasswordManagerClient::GetProfile() {
- return Profile::FromBrowserContext(web_contents_->GetBrowserContext());
+ return Profile::FromBrowserContext(web_contents()->GetBrowserContext());
+}
+
+void ChromePasswordManagerClient::HidePasswordGenerationPopup() {
+ if (popup_controller_)
+ popup_controller_->HideAndDestroy();
}
PrefService* ChromePasswordManagerClient::GetPrefs() {
@@ -169,6 +180,80 @@ PasswordManager* ChromePasswordManagerClient::GetManagerFromWebContents(
return client->GetDriver()->GetPasswordManager();
}
+void ChromePasswordManagerClient::SetTestObserver(
+ autofill::PasswordGenerationPopupObserver* observer) {
+ observer_ = observer;
+}
+
+bool ChromePasswordManagerClient::OnMessageReceived(
+ const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(ChromePasswordManagerClient, message)
+ IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordGenerationPopup,
+ ShowPasswordGenerationPopup)
+ IPC_MESSAGE_HANDLER(AutofillHostMsg_ShowPasswordEditingPopup,
+ ShowPasswordEditingPopup)
+ IPC_MESSAGE_HANDLER(AutofillHostMsg_HidePasswordGenerationPopup,
+ HidePasswordGenerationPopup)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+gfx::RectF ChromePasswordManagerClient::GetBoundsInScreenSpace(
+ const gfx::RectF& bounds) {
+ gfx::Rect client_area;
+ web_contents()->GetView()->GetContainerBounds(&client_area);
+ return bounds + client_area.OffsetFromOrigin();
+}
+
+void ChromePasswordManagerClient::ShowPasswordGenerationPopup(
+ const gfx::RectF& bounds,
+ int max_length,
+ const autofill::PasswordForm& form) {
+ // TODO(gcasto): Validate data in PasswordForm.
+
+ // Only implemented for Aura right now.
+#if defined(USE_AURA)
+ gfx::RectF element_bounds_in_screen_space = GetBoundsInScreenSpace(bounds);
+
+ password_generator_.reset(new autofill::PasswordGenerator(max_length));
+
+ popup_controller_ =
+ autofill::PasswordGenerationPopupControllerImpl::GetOrCreate(
+ popup_controller_,
+ element_bounds_in_screen_space,
+ form,
+ password_generator_.get(),
+ driver_.GetPasswordManager(),
+ observer_,
+ web_contents(),
+ web_contents()->GetView()->GetNativeView());
+ popup_controller_->Show(true /* display_password */);
+#endif // #if defined(USE_AURA)
+}
+
+void ChromePasswordManagerClient::ShowPasswordEditingPopup(
+ const gfx::RectF& bounds,
+ const autofill::PasswordForm& form) {
+ // Only implemented for Aura right now.
+#if defined(USE_AURA)
+ gfx::RectF element_bounds_in_screen_space = GetBoundsInScreenSpace(bounds);
+
+ popup_controller_ =
+ autofill::PasswordGenerationPopupControllerImpl::GetOrCreate(
+ popup_controller_,
+ element_bounds_in_screen_space,
+ form,
+ password_generator_.get(),
+ driver_.GetPasswordManager(),
+ observer_,
+ web_contents(),
+ web_contents()->GetView()->GetNativeView());
+ popup_controller_->Show(false /* display_password */);
+#endif // #if defined(USE_AURA)
+}
+
void ChromePasswordManagerClient::CommitFillPasswordForm(
autofill::PasswordFormFillData* data) {
driver_.FillPasswordForm(*data);
diff --git a/chrome/browser/password_manager/chrome_password_manager_client.h b/chrome/browser/password_manager/chrome_password_manager_client.h
index df3d28d..ad0b9b4 100644
--- a/chrome/browser/password_manager/chrome_password_manager_client.h
+++ b/chrome/browser/password_manager/chrome_password_manager_client.h
@@ -9,12 +9,20 @@
#include "base/compiler_specific.h"
#include "chrome/browser/password_manager/content_password_manager_driver.h"
#include "chrome/browser/password_manager/password_manager_client.h"
+#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
+#include "ui/gfx/rect.h"
class PasswordGenerationManager;
class PasswordManager;
class Profile;
+namespace autofill {
+class PasswordGenerationPopupObserver;
+class PasswordGenerationPopupControllerImpl;
+class PasswordGenerator;
+}
+
namespace content {
class WebContents;
}
@@ -22,6 +30,7 @@ class WebContents;
// ChromePasswordManagerClient implements the PasswordManagerClient interface.
class ChromePasswordManagerClient
: public PasswordManagerClient,
+ public content::WebContentsObserver,
public content::WebContentsUserData<ChromePasswordManagerClient> {
public:
virtual ~ChromePasswordManagerClient();
@@ -40,6 +49,9 @@ class ChromePasswordManagerClient
const std::string& experiment_name) OVERRIDE;
virtual bool IsPasswordSyncEnabled() OVERRIDE;
+ // Hides any visible generation UI.
+ void HidePasswordGenerationPopup();
+
// Convenience method to allow //chrome code easy access to a PasswordManager
// from a WebContents instance.
static PasswordManager* GetManagerFromWebContents(
@@ -50,20 +62,50 @@ class ChromePasswordManagerClient
static PasswordGenerationManager* GetGenerationManagerFromWebContents(
content::WebContents* contents);
+ // Observer for PasswordGenerationPopup events. Used for testing.
+ void SetTestObserver(autofill::PasswordGenerationPopupObserver* observer);
+
private:
explicit ChromePasswordManagerClient(content::WebContents* web_contents);
friend class content::WebContentsUserData<ChromePasswordManagerClient>;
+ // content::WebContentsObserver overrides.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+
// Callback method to be triggered when authentication is successful for a
// given password authentication request. If authentication is disabled or
// not supported, this will be triggered directly.
void CommitFillPasswordForm(autofill::PasswordFormFillData* fill_data);
+ // Given |bounds| in the renderers coordinate system, return the same bounds
+ // in the screens coordinate system.
+ gfx::RectF GetBoundsInScreenSpace(const gfx::RectF& bounds);
+
+ // Causes the password generation UI to be shown for the specified form.
+ // The popup will be anchored at |element_bounds|. The generated password
+ // will be no longer than |max_length|.
+ void ShowPasswordGenerationPopup(const gfx::RectF& bounds,
+ int max_length,
+ const autofill::PasswordForm& form);
+
+ // Causes the password editing UI to be shown anchored at |element_bounds|.
+ void ShowPasswordEditingPopup(
+ const gfx::RectF& bounds, const autofill::PasswordForm& form);
+
Profile* GetProfile();
- content::WebContents* web_contents_;
ContentPasswordManagerDriver driver_;
+ // Observer for password generation popup.
+ autofill::PasswordGenerationPopupObserver* observer_;
+
+ // Controls how passwords are generated.
+ scoped_ptr<autofill::PasswordGenerator> password_generator_;
+
+ // Controls the popup
+ base::WeakPtr<
+ autofill::PasswordGenerationPopupControllerImpl> popup_controller_;
+
// Allows authentication callbacks to be destroyed when this client is gone.
base::WeakPtrFactory<ChromePasswordManagerClient> weak_factory_;
diff --git a/chrome/browser/password_manager/content_password_manager_driver.cc b/chrome/browser/password_manager/content_password_manager_driver.cc
index c72167e..b78dd83 100644
--- a/chrome/browser/password_manager/content_password_manager_driver.cc
+++ b/chrome/browser/password_manager/content_password_manager_driver.cc
@@ -23,7 +23,7 @@ ContentPasswordManagerDriver::ContentPasswordManagerDriver(
PasswordManagerClient* client)
: WebContentsObserver(web_contents),
password_manager_(client),
- password_generation_manager_(web_contents, client) {
+ password_generation_manager_(client) {
DCHECK(web_contents);
}
@@ -36,6 +36,19 @@ void ContentPasswordManagerDriver::FillPasswordForm(
web_contents()->GetRenderViewHost()->GetRoutingID(), form_data));
}
+void ContentPasswordManagerDriver::AllowPasswordGenerationForForm(
+ autofill::PasswordForm* form) {
+ content::RenderViewHost* host = web_contents()->GetRenderViewHost();
+ host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), *form));
+}
+
+void ContentPasswordManagerDriver::AccountCreationFormsFound(
+ const std::vector<autofill::FormData>& forms) {
+ content::RenderViewHost* host = web_contents()->GetRenderViewHost();
+ host->Send(new AutofillMsg_AccountCreationFormsDetected(host->GetRoutingID(),
+ forms));
+}
+
bool ContentPasswordManagerDriver::DidLastPageLoadEncounterSSLErrors() {
DCHECK(web_contents());
content::NavigationEntry* entry =
@@ -62,13 +75,6 @@ PasswordManager* ContentPasswordManagerDriver::GetPasswordManager() {
return &password_manager_;
}
-void ContentPasswordManagerDriver::AccountCreationFormsFound(
- const std::vector<autofill::FormData>& forms) {
- content::RenderViewHost* host = web_contents()->GetRenderViewHost();
- host->Send(new AutofillMsg_AccountCreationFormsDetected(host->GetRoutingID(),
- forms));
-}
-
void ContentPasswordManagerDriver::DidNavigateMainFrame(
const content::LoadCommittedDetails& details,
const content::FrameNavigateParams& params) {
@@ -88,15 +94,6 @@ bool ContentPasswordManagerDriver::OnMessageReceived(
IPC_MESSAGE_FORWARD(AutofillHostMsg_PasswordFormSubmitted,
&password_manager_,
PasswordManager::OnPasswordFormSubmitted)
- IPC_MESSAGE_FORWARD(AutofillHostMsg_ShowPasswordGenerationPopup,
- &password_generation_manager_,
- PasswordGenerationManager::OnShowPasswordGenerationPopup)
- IPC_MESSAGE_FORWARD(AutofillHostMsg_ShowPasswordEditingPopup,
- &password_generation_manager_,
- PasswordGenerationManager::OnShowPasswordEditingPopup)
- IPC_MESSAGE_FORWARD(AutofillHostMsg_HidePasswordGenerationPopup,
- &password_generation_manager_,
- PasswordGenerationManager::OnHidePasswordGenerationPopup)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -108,9 +105,3 @@ autofill::AutofillManager* ContentPasswordManagerDriver::GetAutofillManager() {
autofill::AutofillDriverImpl::FromWebContents(web_contents());
return driver ? driver->autofill_manager() : NULL;
}
-
-void ContentPasswordManagerDriver::AllowPasswordGenerationForForm(
- autofill::PasswordForm* form) {
- content::RenderViewHost* host = web_contents()->GetRenderViewHost();
- host->Send(new AutofillMsg_FormNotBlacklisted(host->GetRoutingID(), *form));
-}
diff --git a/chrome/browser/password_manager/content_password_manager_driver.h b/chrome/browser/password_manager/content_password_manager_driver.h
index 5f51cc5..b18d8b8 100644
--- a/chrome/browser/password_manager/content_password_manager_driver.h
+++ b/chrome/browser/password_manager/content_password_manager_driver.h
@@ -31,15 +31,15 @@ class ContentPasswordManagerDriver : public PasswordManagerDriver,
// PasswordManagerDriver implementation.
virtual void FillPasswordForm(const autofill::PasswordFormFillData& form_data)
OVERRIDE;
+ virtual void AllowPasswordGenerationForForm(autofill::PasswordForm* form)
+ OVERRIDE;
+ virtual void AccountCreationFormsFound(
+ const std::vector<autofill::FormData>& forms) OVERRIDE;
virtual bool DidLastPageLoadEncounterSSLErrors() OVERRIDE;
virtual bool IsOffTheRecord() OVERRIDE;
virtual PasswordGenerationManager* GetPasswordGenerationManager() OVERRIDE;
virtual PasswordManager* GetPasswordManager() OVERRIDE;
virtual autofill::AutofillManager* GetAutofillManager() OVERRIDE;
- virtual void AllowPasswordGenerationForForm(autofill::PasswordForm* form)
- OVERRIDE;
- virtual void AccountCreationFormsFound(
- const std::vector<autofill::FormData>& forms) OVERRIDE;
// content::WebContentsObserver overrides.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
@@ -48,9 +48,6 @@ class ContentPasswordManagerDriver : public PasswordManagerDriver,
const content::FrameNavigateParams& params) OVERRIDE;
private:
- // Must outlive this instance.
- PasswordManagerClient* client_;
-
PasswordManager password_manager_;
PasswordGenerationManager password_generation_manager_;
diff --git a/chrome/browser/password_manager/password_generation_interactive_uitest.cc b/chrome/browser/password_manager/password_generation_interactive_uitest.cc
index dbd948d..a8602a2 100644
--- a/chrome/browser/password_manager/password_generation_interactive_uitest.cc
+++ b/chrome/browser/password_manager/password_generation_interactive_uitest.cc
@@ -65,10 +65,9 @@ class PasswordGenerationInteractiveTest : public InProcessBrowserTest {
autofill::test::DisableSystemServices(browser()->profile());
// Set observer for popup.
- PasswordGenerationManager* generation_manager =
- ChromePasswordManagerClient::GetGenerationManagerFromWebContents(
- GetWebContents());
- generation_manager->SetTestObserver(&observer_);
+ ChromePasswordManagerClient* client =
+ ChromePasswordManagerClient::FromWebContents(GetWebContents());
+ client->SetTestObserver(&observer_);
ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
GURL url = embedded_test_server()->GetURL("/password/signup_form.html");
@@ -77,10 +76,9 @@ class PasswordGenerationInteractiveTest : public InProcessBrowserTest {
virtual void CleanUpOnMainThread() OVERRIDE {
// Clean up UI.
- PasswordGenerationManager* generation_manager =
- ChromePasswordManagerClient::GetGenerationManagerFromWebContents(
- GetWebContents());
- generation_manager->HidePopup();
+ ChromePasswordManagerClient* client =
+ ChromePasswordManagerClient::FromWebContents(GetWebContents());
+ client->HidePasswordGenerationPopup();
}
content::WebContents* GetWebContents() {
diff --git a/chrome/browser/password_manager/password_generation_manager.cc b/chrome/browser/password_manager/password_generation_manager.cc
index e6b87da..49c6826 100644
--- a/chrome/browser/password_manager/password_generation_manager.cc
+++ b/chrome/browser/password_manager/password_generation_manager.cc
@@ -7,10 +7,6 @@
#include "chrome/browser/password_manager/password_manager.h"
#include "chrome/browser/password_manager/password_manager_client.h"
#include "chrome/browser/password_manager/password_manager_driver.h"
-#include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_finder.h"
-#include "chrome/browser/ui/browser_window.h"
#include "components/autofill/content/common/autofill_messages.h"
#include "components/autofill/core/browser/autofill_field.h"
#include "components/autofill/core/browser/field_types.h"
@@ -18,25 +14,14 @@
#include "components/autofill/core/browser/password_generator.h"
#include "components/autofill/core/common/form_data.h"
#include "components/autofill/core/common/password_form.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_contents_view.h"
-#include "ui/gfx/rect.h"
PasswordGenerationManager::PasswordGenerationManager(
- content::WebContents* contents,
PasswordManagerClient* client)
- : web_contents_(contents),
- observer_(NULL),
- client_(client),
+ : client_(client),
driver_(client->GetDriver()) {}
PasswordGenerationManager::~PasswordGenerationManager() {}
-void PasswordGenerationManager::SetTestObserver(
- autofill::PasswordGenerationPopupObserver* observer) {
- observer_ = observer;
-}
-
void PasswordGenerationManager::DetectAccountCreationForms(
const std::vector<autofill::FormStructure*>& forms) {
std::vector<autofill::FormData> account_creation_forms;
@@ -72,67 +57,3 @@ bool PasswordGenerationManager::IsGenerationEnabled() const {
return true;
}
-
-gfx::RectF PasswordGenerationManager::GetBoundsInScreenSpace(
- const gfx::RectF& bounds) {
- gfx::Rect client_area;
- web_contents_->GetView()->GetContainerBounds(&client_area);
- return bounds + client_area.OffsetFromOrigin();
-}
-
-void PasswordGenerationManager::OnShowPasswordGenerationPopup(
- const gfx::RectF& bounds,
- int max_length,
- const autofill::PasswordForm& form) {
- // TODO(gcasto): Validate data in PasswordForm.
-
- // Only implemented for Aura right now.
-#if defined(USE_AURA)
- // Convert element_bounds to be in screen space.
- gfx::RectF element_bounds_in_screen_space = GetBoundsInScreenSpace(bounds);
-
- password_generator_.reset(new autofill::PasswordGenerator(max_length));
-
- popup_controller_ =
- autofill::PasswordGenerationPopupControllerImpl::GetOrCreate(
- popup_controller_,
- element_bounds_in_screen_space,
- form,
- password_generator_.get(),
- driver_->GetPasswordManager(),
- observer_,
- web_contents_,
- web_contents_->GetView()->GetNativeView());
- popup_controller_->Show(true /* display_password */);
-#endif // #if defined(USE_AURA)
-}
-
-void PasswordGenerationManager::OnShowPasswordEditingPopup(
- const gfx::RectF& bounds,
- const autofill::PasswordForm& form) {
- // Only implemented for Aura right now.
-#if defined(USE_AURA)
- gfx::RectF element_bounds_in_screen_space = GetBoundsInScreenSpace(bounds);
-
- popup_controller_ =
- autofill::PasswordGenerationPopupControllerImpl::GetOrCreate(
- popup_controller_,
- element_bounds_in_screen_space,
- form,
- password_generator_.get(),
- driver_->GetPasswordManager(),
- observer_,
- web_contents_,
- web_contents_->GetView()->GetNativeView());
- popup_controller_->Show(false /* display_password */);
-#endif // #if defined(USE_AURA)
-}
-
-void PasswordGenerationManager::OnHidePasswordGenerationPopup() {
- HidePopup();
-}
-
-void PasswordGenerationManager::HidePopup() {
- if (popup_controller_)
- popup_controller_->HideAndDestroy();
-}
diff --git a/chrome/browser/password_manager/password_generation_manager.h b/chrome/browser/password_manager/password_generation_manager.h
index 47f1c71..cff4d97 100644
--- a/chrome/browser/password_manager/password_generation_manager.h
+++ b/chrome/browser/password_manager/password_generation_manager.h
@@ -8,30 +8,13 @@
#include <vector>
#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/memory/weak_ptr.h"
-#include "ui/gfx/rect.h"
class PasswordManager;
class PasswordManagerClient;
class PasswordManagerDriver;
namespace autofill {
-struct FormData;
class FormStructure;
-class PasswordGenerator;
-class PasswordGenerationPopupControllerImpl;
-class PasswordGenerationPopupObserver;
-struct PasswordForm;
-}
-
-namespace content {
-class RenderViewHost;
-class WebContents;
-}
-
-namespace user_prefs {
-class PrefRegistrySyncable;
}
// Per-tab manager for password generation. Will enable this feature only if
@@ -49,8 +32,7 @@ class PrefRegistrySyncable;
// generate a password.
class PasswordGenerationManager {
public:
- PasswordGenerationManager(content::WebContents* contents,
- PasswordManagerClient* client);
+ explicit PasswordGenerationManager(PasswordManagerClient* client);
virtual ~PasswordGenerationManager();
// Detect account creation forms from forms with autofill type annotated.
@@ -59,52 +41,12 @@ class PasswordGenerationManager {
void DetectAccountCreationForms(
const std::vector<autofill::FormStructure*>& forms);
- // Hide any visible password generation related popups.
- void HidePopup();
-
- // Observer for PasswordGenerationPopup events. Used for testing.
- void SetTestObserver(autofill::PasswordGenerationPopupObserver* observer);
-
- // Causes the password generation UI to be shown for the specified form.
- // The popup will be anchored at |element_bounds|. The generated password
- // will be no longer than |max_length|.
- void OnShowPasswordGenerationPopup(const gfx::RectF& element_bounds,
- int max_length,
- const autofill::PasswordForm& form);
-
- // Causes the password editing UI to be shown anchored at |element_bounds|.
- void OnShowPasswordEditingPopup(const gfx::RectF& element_bounds,
- const autofill::PasswordForm& form);
-
- // Hides any visible UI.
- void OnHidePasswordGenerationPopup();
-
private:
friend class PasswordGenerationManagerTest;
// Determines current state of password generation
bool IsGenerationEnabled() const;
- // Given |bounds| in the renderers coordinate system, return the same bounds
- // in the screens coordinate system.
- gfx::RectF GetBoundsInScreenSpace(const gfx::RectF& bounds);
-
- // The WebContents instance associated with this instance. Scoped to the
- // lifetime of this class, as this class is indirectly a WCUD via
- // ChromePasswordManagerClient.
- // TODO(blundell): Eliminate this ivar. crbug.com/340675
- content::WebContents* web_contents_;
-
- // Observer for password generation popup.
- autofill::PasswordGenerationPopupObserver* observer_;
-
- // Controls how passwords are generated.
- scoped_ptr<autofill::PasswordGenerator> password_generator_;
-
- // Controls the popup
- base::WeakPtr<
- autofill::PasswordGenerationPopupControllerImpl> popup_controller_;
-
// The PasswordManagerClient instance associated with this instance. Must
// outlive this instance.
PasswordManagerClient* client_;
diff --git a/chrome/browser/password_manager/password_generation_manager_unittest.cc b/chrome/browser/password_manager/password_generation_manager_unittest.cc
index c2c8646..010f004 100644
--- a/chrome/browser/password_manager/password_generation_manager_unittest.cc
+++ b/chrome/browser/password_manager/password_generation_manager_unittest.cc
@@ -30,7 +30,7 @@ class TestPasswordManagerDriver : public PasswordManagerDriver {
TestPasswordManagerDriver(content::WebContents* web_contents,
PasswordManagerClient* client)
: password_manager_(client),
- password_generation_manager_(web_contents, client),
+ password_generation_manager_(client),
is_off_the_record_(false) {}
virtual ~TestPasswordManagerDriver() {}
diff --git a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc
index f3869b9..de88a5b 100644
--- a/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc
+++ b/chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc
@@ -10,7 +10,6 @@
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/password_manager/chrome_password_manager_client.h"
-#include "chrome/browser/password_manager/password_generation_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
#include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
@@ -148,11 +147,10 @@ void TabAutofillManagerDelegate::HideAutofillPopup() {
// Password generation popups behave in the same fashion and should also
// be hidden.
- PasswordGenerationManager* generation_manager =
- ChromePasswordManagerClient::GetGenerationManagerFromWebContents(
- web_contents_);
- if (generation_manager)
- generation_manager->HidePopup();
+ ChromePasswordManagerClient* password_client =
+ ChromePasswordManagerClient::FromWebContents(web_contents_);
+ if (password_client)
+ password_client->HidePasswordGenerationPopup();
}
bool TabAutofillManagerDelegate::IsAutocompleteEnabled() {