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_ui_controller.h" | 5 #include "chrome/browser/ui/passwords/manage_passwords_bubble_ui_controller.h" |
6 | 6 |
7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/password_manager/password_store_factory.h" | 8 #include "chrome/browser/password_manager/password_store_factory.h" |
9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
11 #include "chrome/browser/ui/chrome_pages.h" | 11 #include "chrome/browser/ui/chrome_pages.h" |
12 #include "chrome/browser/ui/omnibox/location_bar.h" | 12 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 13 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" |
13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
14 #include "components/password_manager/core/browser/password_store.h" | 15 #include "components/password_manager/core/browser/password_store.h" |
15 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
16 | 17 |
17 using autofill::PasswordFormMap; | 18 using autofill::PasswordFormMap; |
18 using password_manager::PasswordFormManager; | 19 using password_manager::PasswordFormManager; |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 password_manager::PasswordStore* GetPasswordStore( | 23 password_manager::PasswordStore* GetPasswordStore( |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 if (it->type() == password_manager::PasswordStoreChange::REMOVE) { | 109 if (it->type() == password_manager::PasswordStoreChange::REMOVE) { |
109 password_form_map_.erase(changed_form.username_value); | 110 password_form_map_.erase(changed_form.username_value); |
110 } else { | 111 } else { |
111 autofill::PasswordForm* new_form = | 112 autofill::PasswordForm* new_form = |
112 new autofill::PasswordForm(changed_form); | 113 new autofill::PasswordForm(changed_form); |
113 password_form_map_[changed_form.username_value] = new_form; | 114 password_form_map_[changed_form.username_value] = new_form; |
114 } | 115 } |
115 } | 116 } |
116 } | 117 } |
117 | 118 |
118 void ManagePasswordsBubbleUIController::OnBubbleShown() { | |
119 unset_manage_passwords_bubble_needs_showing(); | |
120 } | |
121 | |
122 void ManagePasswordsBubbleUIController:: | 119 void ManagePasswordsBubbleUIController:: |
123 NavigateToPasswordManagerSettingsPage() { | 120 NavigateToPasswordManagerSettingsPage() { |
124 // TODO(mkwst): chrome_pages.h is compiled out of Android. Need to figure out | 121 // TODO(mkwst): chrome_pages.h is compiled out of Android. Need to figure out |
125 // how this navigation should work there. | 122 // how this navigation should work there. |
126 #if !defined(OS_ANDROID) | 123 #if !defined(OS_ANDROID) |
127 chrome::ShowSettingsSubPage( | 124 chrome::ShowSettingsSubPage( |
128 chrome::FindBrowserWithWebContents(web_contents()), | 125 chrome::FindBrowserWithWebContents(web_contents()), |
129 chrome::kPasswordManagerSubPage); | 126 chrome::kPasswordManagerSubPage); |
130 #endif | 127 #endif |
131 } | 128 } |
(...skipping 18 matching lines...) Expand all Loading... |
150 password_to_be_saved_ = false; | 147 password_to_be_saved_ = false; |
151 manage_passwords_bubble_needs_showing_ = false; | 148 manage_passwords_bubble_needs_showing_ = false; |
152 UpdateBubbleAndIconVisibility(); | 149 UpdateBubbleAndIconVisibility(); |
153 } | 150 } |
154 | 151 |
155 const autofill::PasswordForm& ManagePasswordsBubbleUIController:: | 152 const autofill::PasswordForm& ManagePasswordsBubbleUIController:: |
156 PendingCredentials() const { | 153 PendingCredentials() const { |
157 DCHECK(form_manager_); | 154 DCHECK(form_manager_); |
158 return form_manager_->pending_credentials(); | 155 return form_manager_->pending_credentials(); |
159 } | 156 } |
| 157 |
| 158 void ManagePasswordsBubbleUIController::UpdateIconAndBubbleState( |
| 159 ManagePasswordsIcon* icon) { |
| 160 ManagePasswordsIcon::State state = ManagePasswordsIcon::INACTIVE_STATE; |
| 161 |
| 162 if (autofill_blocked_) |
| 163 state = ManagePasswordsIcon::BLACKLISTED_STATE; |
| 164 else if (password_to_be_saved_) |
| 165 state = ManagePasswordsIcon::PENDING_STATE; |
| 166 else if (manage_passwords_icon_to_be_shown_) |
| 167 state = ManagePasswordsIcon::MANAGE_STATE; |
| 168 |
| 169 icon->SetState(state); |
| 170 |
| 171 if (manage_passwords_bubble_needs_showing_) { |
| 172 DCHECK(state == ManagePasswordsIcon::PENDING_STATE); |
| 173 icon->ShowBubbleWithoutUserInteraction(); |
| 174 manage_passwords_bubble_needs_showing_ = false; |
| 175 } |
| 176 } |
OLD | NEW |