| 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_ui_controller.h" | 10 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 ManagePasswordsUIController::FromWebContents(web_contents); | 26 ManagePasswordsUIController::FromWebContents(web_contents); |
| 27 | 27 |
| 28 // TODO(mkwst): Reverse this logic. The controller should populate the model | 28 // TODO(mkwst): Reverse this logic. The controller should populate the model |
| 29 // directly rather than the model pulling from the controller. Perhaps like | 29 // directly rather than the model pulling from the controller. Perhaps like |
| 30 // `controller->PopulateModel(this)`. | 30 // `controller->PopulateModel(this)`. |
| 31 state_ = controller->state(); | 31 state_ = controller->state(); |
| 32 if (password_manager::ui::IsPendingState(state_)) | 32 if (password_manager::ui::IsPendingState(state_)) |
| 33 pending_credentials_ = controller->PendingCredentials(); | 33 pending_credentials_ = controller->PendingCredentials(); |
| 34 best_matches_ = controller->best_matches(); | 34 best_matches_ = controller->best_matches(); |
| 35 | 35 |
| 36 title_ = l10n_util::GetStringUTF16( | 36 if (password_manager::ui::IsPendingState(state_)) |
| 37 password_manager::ui::IsPendingState(state_) ? IDS_SAVE_PASSWORD | 37 title_ = l10n_util::GetStringUTF16(IDS_SAVE_PASSWORD); |
| 38 : IDS_MANAGE_PASSWORDS); | 38 else if (state_ == password_manager::ui::BLACKLIST_STATE) |
| 39 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_BLACKLISTED_TITLE); |
| 40 else |
| 41 title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_TITLE); |
| 42 |
| 39 manage_link_ = | 43 manage_link_ = |
| 40 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK); | 44 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK); |
| 41 } | 45 } |
| 42 | 46 |
| 43 ManagePasswordsBubbleModel::~ManagePasswordsBubbleModel() {} | 47 ManagePasswordsBubbleModel::~ManagePasswordsBubbleModel() {} |
| 44 | 48 |
| 45 void ManagePasswordsBubbleModel::OnBubbleShown( | 49 void ManagePasswordsBubbleModel::OnBubbleShown( |
| 46 ManagePasswordsBubble::DisplayReason reason) { | 50 ManagePasswordsBubble::DisplayReason reason) { |
| 47 if (reason == ManagePasswordsBubble::USER_ACTION) { | 51 if (reason == ManagePasswordsBubble::USER_ACTION) { |
| 48 if (password_manager::ui::IsPendingState(state_)) { | 52 if (password_manager::ui::IsPendingState(state_)) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 126 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 123 password_manager::PasswordStore* password_store = | 127 password_manager::PasswordStore* password_store = |
| 124 PasswordStoreFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS) | 128 PasswordStoreFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS) |
| 125 .get(); | 129 .get(); |
| 126 DCHECK(password_store); | 130 DCHECK(password_store); |
| 127 if (action == REMOVE_PASSWORD) | 131 if (action == REMOVE_PASSWORD) |
| 128 password_store->RemoveLogin(password_form); | 132 password_store->RemoveLogin(password_form); |
| 129 else | 133 else |
| 130 password_store->AddLogin(password_form); | 134 password_store->AddLogin(password_form); |
| 131 } | 135 } |
| OLD | NEW |