Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1652)

Unified Diff: chrome/browser/password_manager/password_generation_manager.cc

Issue 151413008: Move ownership of Password(Generation)Manager to ContentPasswordDriver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix up unittests Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/password_manager/password_generation_manager.cc
diff --git a/chrome/browser/password_manager/password_generation_manager.cc b/chrome/browser/password_manager/password_generation_manager.cc
index d808b2fdbc40a27b338ec64ffaf1ee5de95cbb54..4a46a722a69641cd54ecfe436523d931a3e4ccbd 100644
--- a/chrome/browser/password_manager/password_generation_manager.cc
+++ b/chrome/browser/password_manager/password_generation_manager.cc
@@ -5,6 +5,8 @@
#include "chrome/browser/password_manager/password_generation_manager.h"
#include "chrome/browser/password_manager/password_manager.h"
+#include "chrome/browser/password_manager/password_manager_delegate.h"
+#include "chrome/browser/password_manager/password_manager_driver.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
@@ -26,12 +28,13 @@
#include "ipc/ipc_message_macros.h"
#include "ui/gfx/rect.h"
-DEFINE_WEB_CONTENTS_USER_DATA_KEY(PasswordGenerationManager);
-
PasswordGenerationManager::PasswordGenerationManager(
- content::WebContents* contents)
+ content::WebContents* contents,
+ PasswordManagerDelegate* delegate)
: content::WebContentsObserver(contents),
- observer_(NULL) {}
+ observer_(NULL),
+ delegate_(delegate),
+ driver_(delegate->GetDriver()) {}
PasswordGenerationManager::~PasswordGenerationManager() {}
@@ -86,7 +89,7 @@ bool PasswordGenerationManager::IsGenerationEnabled() const {
Profile* profile = Profile::FromBrowserContext(
web_contents()->GetBrowserContext());
- if (!PasswordManager::FromWebContents(web_contents())->IsSavingEnabled()) {
+ if (!driver_->GetPasswordManager()->IsSavingEnabled()) {
DVLOG(2) << "Generation disabled because password saving is disabled";
return false;
}
@@ -125,6 +128,8 @@ void PasswordGenerationManager::OnShowPasswordGenerationPopup(
const gfx::RectF& bounds,
int max_length,
const autofill::PasswordForm& form) {
+// TODO(blundell): Should this short-circuit out if web_contents() is NULL?
Garrett Casto 2014/02/04 12:53:36 Won't web_contents_ always be valid if this object
blundell 2014/02/04 13:16:18 There is a period of time for WCO's when web_conte
+
// TODO(gcasto): Validate data in PasswordForm.
// Only implemented for Aura right now.
@@ -140,7 +145,7 @@ void PasswordGenerationManager::OnShowPasswordGenerationPopup(
element_bounds_in_screen_space,
form,
password_generator_.get(),
- PasswordManager::FromWebContents(web_contents()),
+ driver_->GetPasswordManager(),
observer_,
web_contents(),
web_contents()->GetView()->GetNativeView());

Powered by Google App Engine
This is Rietveld 408576698