| 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. |
| 87 password_manager::metrics_util::UIDisplayDisposition display_disposition() | 95 password_manager::metrics_util::UIDisplayDisposition display_disposition() |
| 88 const { | 96 const { |
| 89 return display_disposition_; | 97 return display_disposition_; |
| 90 } | 98 } |
| 91 | 99 |
| 92 // Gets the reason the bubble was dismissed. | 100 // Gets the reason the bubble was dismissed. |
| 93 password_manager::metrics_util::UIDismissalReason dismissal_reason() const { | 101 password_manager::metrics_util::UIDismissalReason dismissal_reason() const { |
| 94 return dismissal_reason_; | 102 return dismissal_reason_; |
| 95 } | 103 } |
| 96 | 104 |
| 97 // State setter. | 105 // State setter. |
| 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: |
| 114 friend void InitPasswordsModelFromController( |
| 115 ManagePasswordsUIController* controller, |
| 116 ManagePasswordsBubbleModel* model); |
| 117 |
| 106 password_manager::ui::State state_; | 118 password_manager::ui::State state_; |
| 107 base::string16 title_; | 119 base::string16 title_; |
| 108 autofill::PasswordForm pending_credentials_; | 120 autofill::PasswordForm pending_password_; |
| 109 autofill::ConstPasswordFormMap best_matches_; | 121 autofill::ConstPasswordFormMap best_matches_; |
| 122 ScopedVector<autofill::PasswordForm> pending_credentials_; |
| 110 base::string16 manage_link_; | 123 base::string16 manage_link_; |
| 111 base::string16 save_confirmation_text_; | 124 base::string16 save_confirmation_text_; |
| 112 gfx::Range save_confirmation_link_range_; | 125 gfx::Range save_confirmation_link_range_; |
| 113 | 126 |
| 114 password_manager::metrics_util::UIDisplayDisposition display_disposition_; | 127 password_manager::metrics_util::UIDisplayDisposition display_disposition_; |
| 115 password_manager::metrics_util::UIDismissalReason dismissal_reason_; | 128 password_manager::metrics_util::UIDismissalReason dismissal_reason_; |
| 116 | 129 |
| 117 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleModel); | 130 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsBubbleModel); |
| 118 }; | 131 }; |
| 119 | 132 |
| 120 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ | 133 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_BUBBLE_MODEL_H_ |
| OLD | NEW |