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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_controller.h

Issue 87853004: Refactoring Manage Passwords Bubble Code to exclude TabSpecificContentSettings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@movingclasses
Patch Set: adding controller files Created 7 years 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_CONTROLLER_H_
7
8 #include "chrome/browser/password_manager/password_form_manager.h"
9 #include "content/public/browser/navigation_details.h"
10 #include "content/public/browser/web_contents_observer.h"
11 #include "content/public/browser/web_contents_user_data.h"
12
13 namespace content {
14 class WebContents;
15 }
16
17 // Per-tab class to control the Omnibox password icon and bubble.
18 class ManagePasswordsController
markusheintz_ 2013/11/26 12:44:37 ManagePasswordsController is a very generic name t
npentrel 2013/11/26 14:25:55 Done.
19 : public content::WebContentsObserver,
20 public content::WebContentsUserData<ManagePasswordsController> {
21 public:
22 virtual ~ManagePasswordsController();
23
24 // Called when the user submits a form containing login information, so we
25 // can handle later requests to save or blacklist that login information.
26 // This stores the provided object in form_manager_ and triggers the UI to
27 // prompt the user about whether they would like to save the password.
28 void OnPasswordSubmitted(PasswordFormManager* form_manager);
29
30 // Called when a form is autofilled with login information, so we can manage
31 // password credentials for the current site which are stored in
32 // |password_form_map|. This stores a copy of |password_form_map| and shows
33 // the manage password icon.
34 void OnPasswordAutofilled(const autofill::PasswordFormMap& password_form_map);
35
36 // TODO(npentrel) This ought to be changed. Best matches should be newly
37 // made when opening the ManagePasswordsBubble because there may have been
38 // changes to the best matches via the settings page. At the moment this also
39 // fails if one deletes a password when they are autofilled, as it still shows
40 // up after logging in and saving a password.
41 void RemoveFromBestMatches(autofill::PasswordForm password_form);
42
43 void SavePassword();
44
45 // Called when the bubble is opened after the icon gets displayed. We change
46 // the state to know that we do not need to pop up the bubble again.
47 void OnBubbleShown();
48
49 bool manage_passwords_icon_to_be_shown() const {
50 return manage_passwords_icon_to_be_shown_;
51 }
52
53 bool password_to_be_saved() const {
54 return password_to_be_saved_;
55 }
56
57 bool manage_passwords_bubble_needs_showing() const {
58 return manage_passwords_bubble_needs_showing_;
59 }
60
61 void unset_manage_passwords_bubble_needs_showing() {
62 manage_passwords_bubble_needs_showing_ = false;
63 }
64
65 void unset_password_to_be_saved() {
66 password_to_be_saved_ = false;
67 }
68
69 const autofill::PasswordForm pending_credentials() const {
70 return form_manager_->pending_credentials();
71 }
72
73 const autofill::PasswordFormMap best_matches() const {
74 return password_form_map_;
75 }
76
77 bool password_submitted() const {
78 return password_submitted_;
79 }
80
81 void set_password_submitted(bool password_submitted) {
82 password_submitted_ = password_submitted;
83 }
84
85 private:
86 friend class content::WebContentsUserData<ManagePasswordsController>;
87
88 explicit ManagePasswordsController(content::WebContents* web_contents);
89
90 // Called when a passwordform is autofilled, when a new passwordform is
91 // submitted, or when a navigation occurs to update the visibility of the
92 // manage passwords icon and bubble.
93 void OnPasswordAction();
markusheintz_ 2013/11/26 12:44:37 nit: I'll leave this name change up to you but "Up
npentrel 2013/11/26 14:25:55 Done.
94
95 // content::WebContentsObserver:
96 virtual void DidNavigateMainFrame(
97 const content::LoadCommittedDetails& details,
98 const content::FrameNavigateParams& params) OVERRIDE;
99
100 // Set by OnPasswordSubmitted() when the user submits a form containing login
101 // information. If the user responds to a subsequent "Do you want to save
102 // this password?" prompt, we ask this object to save or blacklist the
103 // associated login information in Chrome's password store.
104 scoped_ptr<PasswordFormManager> form_manager_;
105
106 // All previously stored credentials for a specific site. Set by
107 // OnPasswordSubmitted() or OnPasswordAutofilled().
108 autofill::PasswordFormMap password_form_map_;
109
110 bool manage_passwords_icon_to_be_shown_;
111 bool password_to_be_saved_;
112 bool manage_passwords_bubble_needs_showing_;
markusheintz_ 2013/11/26 12:44:37 It would be great to add a comment for this field.
npentrel 2013/11/26 14:25:55 Done.
113 bool password_submitted_;
114
115 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsController);
116 };
117
118 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698