OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ |
6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ | 6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ |
7 | 7 |
| 8 #include "base/memory/scoped_vector.h" |
8 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h" | 9 #include "chrome/browser/ui/passwords/manage_passwords_bubble.h" |
9 #include "components/autofill/core/common/password_form.h" | 10 #include "components/autofill/core/common/password_form.h" |
10 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 11 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
11 #include "components/password_manager/core/common/password_manager_ui.h" | 12 #include "components/password_manager/core/common/password_manager_ui.h" |
12 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
13 #include "ui/gfx/range/range.h" | 14 #include "ui/gfx/range/range.h" |
14 | 15 |
15 class ManagePasswordsIconController; | 16 class ManagePasswordsIconController; |
| 17 class ManagePasswordsUIController; |
16 | 18 |
17 namespace content { | 19 namespace content { |
18 class WebContents; | 20 class WebContents; |
19 } | 21 } |
20 | 22 |
21 // This model provides data for the ManagePasswordsBubble and controls the | 23 // This model provides data for the ManagePasswordsBubble and controls the |
22 // password management actions. | 24 // password management actions. |
23 class ManagePasswordsBubbleModel : public content::WebContentsObserver { | 25 class ManagePasswordsBubbleModel : public content::WebContentsObserver { |
24 public: | 26 public: |
25 enum PasswordAction { REMOVE_PASSWORD, ADD_PASSWORD }; | 27 enum PasswordAction { REMOVE_PASSWORD, ADD_PASSWORD }; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 void OnOKClicked(); | 60 void OnOKClicked(); |
59 | 61 |
60 // Called by the view code when the manage link is clicked by the user. | 62 // Called by the view code when the manage link is clicked by the user. |
61 void OnManageLinkClicked(); | 63 void OnManageLinkClicked(); |
62 | 64 |
63 // Called by the view code to delete or add a password form to the | 65 // Called by the view code to delete or add a password form to the |
64 // PasswordStore. | 66 // PasswordStore. |
65 void OnPasswordAction(const autofill::PasswordForm& password_form, | 67 void OnPasswordAction(const autofill::PasswordForm& password_form, |
66 PasswordAction action); | 68 PasswordAction action); |
67 | 69 |
| 70 // Called by the view code to notify about chosen credential. |
| 71 void OnChooseCredentials(const autofill::PasswordForm& password_form); |
| 72 |
68 password_manager::ui::State state() const { return state_; } | 73 password_manager::ui::State state() const { return state_; } |
69 | 74 |
70 const base::string16& title() const { return title_; } | 75 const base::string16& title() const { return title_; } |
71 const autofill::PasswordForm& pending_credentials() const { | 76 const autofill::PasswordForm& pending_password() const { |
72 return pending_credentials_; | 77 return pending_password_; |
73 } | 78 } |
74 const autofill::ConstPasswordFormMap& best_matches() const { | 79 const autofill::ConstPasswordFormMap& best_matches() const { |
75 return best_matches_; | 80 return best_matches_; |
76 } | 81 } |
| 82 const ScopedVector<autofill::PasswordForm>& pending_credentials() const { |
| 83 return pending_credentials_; |
| 84 } |
77 const base::string16& manage_link() const { return manage_link_; } | 85 const base::string16& manage_link() const { return manage_link_; } |
78 const base::string16& save_confirmation_text() const { | 86 const base::string16& save_confirmation_text() const { |
79 return save_confirmation_text_; | 87 return save_confirmation_text_; |
80 } | 88 } |
81 const gfx::Range& save_confirmation_link_range() const { | 89 const gfx::Range& save_confirmation_link_range() const { |
82 return save_confirmation_link_range_; | 90 return save_confirmation_link_range_; |
83 } | 91 } |
84 | 92 |
85 #if defined(UNIT_TEST) | 93 #if defined(UNIT_TEST) |
86 // Gets and sets the reason the bubble was displayed. | 94 // Gets and sets the reason the bubble was displayed. |
(...skipping 11 matching lines...) Expand all Loading... |
98 void set_state(password_manager::ui::State state) { state_ = state; } | 106 void set_state(password_manager::ui::State state) { state_ = state; } |
99 #endif | 107 #endif |
100 | 108 |
101 // Upper limits on the size of the username and password fields. | 109 // Upper limits on the size of the username and password fields. |
102 static int UsernameFieldWidth(); | 110 static int UsernameFieldWidth(); |
103 static int PasswordFieldWidth(); | 111 static int PasswordFieldWidth(); |
104 | 112 |
105 private: | 113 private: |
106 password_manager::ui::State state_; | 114 password_manager::ui::State state_; |
107 base::string16 title_; | 115 base::string16 title_; |
108 autofill::PasswordForm pending_credentials_; | 116 autofill::PasswordForm pending_password_; |
109 autofill::ConstPasswordFormMap best_matches_; | 117 autofill::ConstPasswordFormMap best_matches_; |
| 118 ScopedVector<autofill::PasswordForm> pending_credentials_; |
110 base::string16 manage_link_; | 119 base::string16 manage_link_; |
111 base::string16 save_confirmation_text_; | 120 base::string16 save_confirmation_text_; |
112 gfx::Range save_confirmation_link_range_; | 121 gfx::Range save_confirmation_link_range_; |
113 | 122 |
114 password_manager::metrics_util::UIDisplayDisposition display_disposition_; | 123 password_manager::metrics_util::UIDisplayDisposition display_disposition_; |
115 password_manager::metrics_util::UIDismissalReason dismissal_reason_; | 124 password_manager::metrics_util::UIDismissalReason dismissal_reason_; |
116 | 125 |
117 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleModel); | 126 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleModel); |
118 }; | 127 }; |
119 | 128 |
120 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ | 129 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ |
OLD | NEW |