OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_ui_controller.h" | 5 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
6 | 6 |
7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/password_manager/password_store_factory.h" | 9 #include "chrome/browser/password_manager/password_store_factory.h" |
10 #include "chrome/browser/ui/browser_command_controller.h" | 10 #include "chrome/browser/ui/browser_command_controller.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 void ManagePasswordsUIController::WebContentsDestroyed() { | 84 void ManagePasswordsUIController::WebContentsDestroyed() { |
85 password_manager::PasswordStore* password_store = | 85 password_manager::PasswordStore* password_store = |
86 GetPasswordStore(web_contents()); | 86 GetPasswordStore(web_contents()); |
87 if (password_store) | 87 if (password_store) |
88 password_store->RemoveObserver(this); | 88 password_store->RemoveObserver(this); |
89 } | 89 } |
90 | 90 |
91 void ManagePasswordsUIController::OnLoginsChanged( | 91 void ManagePasswordsUIController::OnLoginsChanged( |
92 const password_manager::PasswordStoreChangeList& changes) { | 92 const password_manager::PasswordStoreChangeList& changes) { |
| 93 password_manager::ui::State current_state = state_; |
93 for (password_manager::PasswordStoreChangeList::const_iterator it = | 94 for (password_manager::PasswordStoreChangeList::const_iterator it = |
94 changes.begin(); | 95 changes.begin(); |
95 it != changes.end(); | 96 it != changes.end(); |
96 it++) { | 97 it++) { |
97 const autofill::PasswordForm& changed_form = it->form(); | 98 const autofill::PasswordForm& changed_form = it->form(); |
98 if (changed_form.origin != origin_) | 99 if (changed_form.origin != origin_) |
99 continue; | 100 continue; |
100 | 101 |
101 if (it->type() == password_manager::PasswordStoreChange::REMOVE) { | 102 if (it->type() == password_manager::PasswordStoreChange::REMOVE) { |
102 password_form_map_.erase(changed_form.username_value); | 103 password_form_map_.erase(changed_form.username_value); |
| 104 if (changed_form.blacklisted_by_user) { |
| 105 DCHECK(state_ == password_manager::ui::BLACKLIST_STATE); |
| 106 state_ = password_manager::ui::MANAGE_STATE; |
| 107 } |
103 } else { | 108 } else { |
104 autofill::PasswordForm* new_form = | 109 new_password_forms_.push_back(new autofill::PasswordForm(changed_form)); |
105 new autofill::PasswordForm(changed_form); | 110 password_form_map_[changed_form.username_value] = |
106 password_form_map_[changed_form.username_value] = new_form; | 111 new_password_forms_.back(); |
| 112 if (changed_form.blacklisted_by_user) |
| 113 state_ = password_manager::ui::BLACKLIST_STATE; |
107 } | 114 } |
108 } | 115 } |
| 116 if (current_state != state_) |
| 117 UpdateBubbleAndIconVisibility(); |
109 } | 118 } |
110 | 119 |
111 void ManagePasswordsUIController:: | 120 void ManagePasswordsUIController:: |
112 NavigateToPasswordManagerSettingsPage() { | 121 NavigateToPasswordManagerSettingsPage() { |
113 // TODO(mkwst): chrome_pages.h is compiled out of Android. Need to figure out | 122 // TODO(mkwst): chrome_pages.h is compiled out of Android. Need to figure out |
114 // how this navigation should work there. | 123 // how this navigation should work there. |
115 #if !defined(OS_ANDROID) | 124 #if !defined(OS_ANDROID) |
116 chrome::ShowSettingsSubPage( | 125 chrome::ShowSettingsSubPage( |
117 chrome::FindBrowserWithWebContents(web_contents()), | 126 chrome::FindBrowserWithWebContents(web_contents()), |
118 chrome::kPasswordManagerSubPage); | 127 chrome::kPasswordManagerSubPage); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 return; | 201 return; |
193 CommandUpdater* updater = browser->command_controller()->command_updater(); | 202 CommandUpdater* updater = browser->command_controller()->command_updater(); |
194 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); | 203 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); |
195 #endif | 204 #endif |
196 } | 205 } |
197 | 206 |
198 bool ManagePasswordsUIController::PasswordPendingUserDecision() const { | 207 bool ManagePasswordsUIController::PasswordPendingUserDecision() const { |
199 return state_ == password_manager::ui::PENDING_PASSWORD_STATE || | 208 return state_ == password_manager::ui::PENDING_PASSWORD_STATE || |
200 state_ == password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE; | 209 state_ == password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE; |
201 } | 210 } |
OLD | NEW |