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 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 5 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
6 | 6 |
7 #include "chrome/browser/password_manager/password_store_factory.h" | 7 #include "chrome/browser/password_manager/password_store_factory.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
10 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" | 10 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" |
11 #include "components/password_manager/core/browser/password_store.h" | 11 #include "components/password_manager/core/browser/password_store.h" |
12 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
13 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
14 | 14 |
15 using content::WebContents; | 15 using content::WebContents; |
16 using autofill::PasswordFormMap; | 16 using autofill::PasswordFormMap; |
17 | 17 |
18 ManagePasswordsBubbleModel::ManagePasswordsBubbleModel( | 18 ManagePasswordsBubbleModel::ManagePasswordsBubbleModel( |
19 content::WebContents* web_contents) | 19 content::WebContents* web_contents) |
20 : content::WebContentsObserver(web_contents), | 20 : content::WebContentsObserver(web_contents), |
21 web_contents_(web_contents), | 21 web_contents_(web_contents), |
22 display_disposition_( | 22 display_disposition_( |
23 password_manager::metrics_util::AUTOMATIC_WITH_PASSWORD_PENDING), | 23 password_manager::metrics_util::AUTOMATIC_WITH_PASSWORD_PENDING), |
24 dismissal_reason_(password_manager::metrics_util::NOT_DISPLAYED) { | 24 dismissal_reason_(password_manager::metrics_util::NOT_DISPLAYED) { |
25 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller = | 25 ManagePasswordsBubbleUIController* manage_passwords_bubble_ui_controller = |
26 ManagePasswordsBubbleUIController::FromWebContents(web_contents_); | 26 ManagePasswordsBubbleUIController::FromWebContents(web_contents_); |
27 | 27 |
28 if (manage_passwords_bubble_ui_controller->password_to_be_saved()) | 28 if (manage_passwords_bubble_ui_controller->password_to_be_saved()) { |
29 manage_passwords_bubble_state_ = PASSWORD_TO_BE_SAVED; | 29 manage_passwords_bubble_state_ = PASSWORD_TO_BE_SAVED; |
30 else | 30 pending_credentials_ = |
| 31 manage_passwords_bubble_ui_controller->PendingCredentials(); |
| 32 } else { |
31 manage_passwords_bubble_state_ = MANAGE_PASSWORDS; | 33 manage_passwords_bubble_state_ = MANAGE_PASSWORDS; |
| 34 } |
32 | 35 |
33 title_ = l10n_util::GetStringUTF16( | 36 title_ = l10n_util::GetStringUTF16( |
34 (manage_passwords_bubble_state_ == PASSWORD_TO_BE_SAVED) ? | 37 (manage_passwords_bubble_state_ == PASSWORD_TO_BE_SAVED) ? |
35 IDS_SAVE_PASSWORD : IDS_MANAGE_PASSWORDS); | 38 IDS_SAVE_PASSWORD : IDS_MANAGE_PASSWORDS); |
36 pending_credentials_ = | |
37 manage_passwords_bubble_ui_controller->PendingCredentials(); | |
38 best_matches_ = manage_passwords_bubble_ui_controller->best_matches(); | 39 best_matches_ = manage_passwords_bubble_ui_controller->best_matches(); |
39 manage_link_ = | 40 manage_link_ = |
40 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK); | 41 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK); |
41 } | 42 } |
42 | 43 |
43 ManagePasswordsBubbleModel::~ManagePasswordsBubbleModel() {} | 44 ManagePasswordsBubbleModel::~ManagePasswordsBubbleModel() {} |
44 | 45 |
45 void ManagePasswordsBubbleModel::OnBubbleShown( | 46 void ManagePasswordsBubbleModel::OnBubbleShown( |
46 ManagePasswordsBubble::DisplayReason reason) { | 47 ManagePasswordsBubble::DisplayReason reason) { |
47 DCHECK(WaitingToSavePassword() || | 48 DCHECK(WaitingToSavePassword() || |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 password_store->RemoveLogin(password_form); | 128 password_store->RemoveLogin(password_form); |
128 else | 129 else |
129 password_store->AddLogin(password_form); | 130 password_store->AddLogin(password_form); |
130 } | 131 } |
131 | 132 |
132 void ManagePasswordsBubbleModel::WebContentsDestroyed( | 133 void ManagePasswordsBubbleModel::WebContentsDestroyed( |
133 content::WebContents* web_contents) { | 134 content::WebContents* web_contents) { |
134 // The WebContents have been destroyed. | 135 // The WebContents have been destroyed. |
135 web_contents_ = NULL; | 136 web_contents_ = NULL; |
136 } | 137 } |
OLD | NEW |