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

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_bubble_ui_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: Android fix 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_BUBBLE_UI_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_UI_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 ManagePasswordsBubbleUIController
19 : public content::WebContentsObserver,
20 public content::WebContentsUserData<ManagePasswordsBubbleUIController> {
21 public:
22 virtual ~ManagePasswordsBubbleUIController();
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<ManagePasswordsBubbleUIController>;
87
88 explicit ManagePasswordsBubbleUIController(
89 content::WebContents* web_contents);
90
91 // Called when a passwordform is autofilled, when a new passwordform is
92 // submitted, or when a navigation occurs to update the visibility of the
93 // manage passwords icon and bubble.
94 void UpdateBubbleAndIconVisibility();
95
96 // content::WebContentsObserver:
97 virtual void DidNavigateMainFrame(
98 const content::LoadCommittedDetails& details,
99 const content::FrameNavigateParams& params) OVERRIDE;
100
101 // Set by OnPasswordSubmitted() when the user submits a form containing login
102 // information. If the user responds to a subsequent "Do you want to save
103 // this password?" prompt, we ask this object to save or blacklist the
104 // associated login information in Chrome's password store.
105 scoped_ptr<PasswordFormManager> form_manager_;
106
107 // All previously stored credentials for a specific site. Set by
108 // OnPasswordSubmitted() or OnPasswordAutofilled().
109 autofill::PasswordFormMap password_form_map_;
110
111 bool manage_passwords_icon_to_be_shown_;
112 bool password_to_be_saved_;
113 bool manage_passwords_bubble_needs_showing_;
114 // Stores whether a new password has been submitted, if so we have
115 // |pending_credentials|.
116 bool password_submitted_;
117
118 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleUIController);
119 };
120
121 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_UI_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698