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" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 const PasswordFormMap& password_form_map) { | 73 const PasswordFormMap& password_form_map) { |
74 password_form_map_ = password_form_map; | 74 password_form_map_ = password_form_map; |
75 origin_ = password_form_map_.begin()->second->origin; | 75 origin_ = password_form_map_.begin()->second->origin; |
76 manage_passwords_icon_to_be_shown_ = true; | 76 manage_passwords_icon_to_be_shown_ = true; |
77 password_to_be_saved_ = false; | 77 password_to_be_saved_ = false; |
78 manage_passwords_bubble_needs_showing_ = false; | 78 manage_passwords_bubble_needs_showing_ = false; |
79 autofill_blocked_ = false; | 79 autofill_blocked_ = false; |
80 UpdateBubbleAndIconVisibility(); | 80 UpdateBubbleAndIconVisibility(); |
81 } | 81 } |
82 | 82 |
83 void ManagePasswordsBubbleUIController::OnBlacklistBlockedAutofill() { | 83 void ManagePasswordsBubbleUIController::OnBlacklistBlockedAutofill( |
| 84 const PasswordFormMap& password_form_map) { |
| 85 password_form_map_ = password_form_map; |
| 86 origin_ = password_form_map_.begin()->second->origin; |
84 manage_passwords_icon_to_be_shown_ = true; | 87 manage_passwords_icon_to_be_shown_ = true; |
85 password_to_be_saved_ = false; | 88 password_to_be_saved_ = false; |
86 manage_passwords_bubble_needs_showing_ = false; | 89 manage_passwords_bubble_needs_showing_ = false; |
87 autofill_blocked_ = true; | 90 autofill_blocked_ = true; |
88 UpdateBubbleAndIconVisibility(); | 91 UpdateBubbleAndIconVisibility(); |
89 } | 92 } |
90 | 93 |
91 void ManagePasswordsBubbleUIController::WebContentsDestroyed( | 94 void ManagePasswordsBubbleUIController::WebContentsDestroyed( |
92 content::WebContents* web_contents) { | 95 content::WebContents* web_contents) { |
93 password_manager::PasswordStore* password_store = | 96 password_manager::PasswordStore* password_store = |
(...skipping 29 matching lines...) Expand all Loading... |
123 #if !defined(OS_ANDROID) | 126 #if !defined(OS_ANDROID) |
124 chrome::ShowSettingsSubPage( | 127 chrome::ShowSettingsSubPage( |
125 chrome::FindBrowserWithWebContents(web_contents()), | 128 chrome::FindBrowserWithWebContents(web_contents()), |
126 chrome::kPasswordManagerSubPage); | 129 chrome::kPasswordManagerSubPage); |
127 #endif | 130 #endif |
128 } | 131 } |
129 | 132 |
130 void ManagePasswordsBubbleUIController::SavePassword() { | 133 void ManagePasswordsBubbleUIController::SavePassword() { |
131 DCHECK(form_manager_.get()); | 134 DCHECK(form_manager_.get()); |
132 form_manager_->Save(); | 135 form_manager_->Save(); |
| 136 password_to_be_saved_ = false; |
133 } | 137 } |
134 | 138 |
135 void ManagePasswordsBubbleUIController::NeverSavePassword() { | 139 void ManagePasswordsBubbleUIController::NeverSavePassword() { |
136 DCHECK(form_manager_.get()); | 140 DCHECK(form_manager_.get()); |
137 form_manager_->PermanentlyBlacklist(); | 141 form_manager_->PermanentlyBlacklist(); |
| 142 autofill_blocked_ = true; |
| 143 password_to_be_saved_ = false; |
| 144 UpdateBubbleAndIconVisibility(); |
| 145 } |
| 146 |
| 147 void ManagePasswordsBubbleUIController::UnblacklistSite() { |
| 148 // We're in one of two states: either the user _just_ blacklisted the site |
| 149 // by clicking "Never save" in the pending bubble, or the user is visiting |
| 150 // a blacklisted site. |
| 151 // |
| 152 // Either way, |password_form_map_| has been populated with the relevant |
| 153 // form. We can safely pull it out, send it over to the password store |
| 154 // for removal, and update our internal state. |
| 155 DCHECK(!password_form_map_.empty()); |
| 156 password_manager::PasswordStore* password_store = |
| 157 GetPasswordStore(web_contents()); |
| 158 if (password_store) |
| 159 password_store->RemoveLogin(*password_form_map_.begin()->second); |
| 160 autofill_blocked_ = false; |
| 161 UpdateBubbleAndIconVisibility(); |
138 } | 162 } |
139 | 163 |
140 void ManagePasswordsBubbleUIController::DidNavigateMainFrame( | 164 void ManagePasswordsBubbleUIController::DidNavigateMainFrame( |
141 const content::LoadCommittedDetails& details, | 165 const content::LoadCommittedDetails& details, |
142 const content::FrameNavigateParams& params) { | 166 const content::FrameNavigateParams& params) { |
143 if (details.is_in_page) | 167 if (details.is_in_page) |
144 return; | 168 return; |
145 // Reset password states for next page. | 169 // Reset password states for next page. |
146 manage_passwords_icon_to_be_shown_ = false; | 170 manage_passwords_icon_to_be_shown_ = false; |
147 password_to_be_saved_ = false; | 171 password_to_be_saved_ = false; |
(...skipping 21 matching lines...) Expand all Loading... |
169 icon->SetState(state); | 193 icon->SetState(state); |
170 | 194 |
171 if (manage_passwords_bubble_needs_showing_) { | 195 if (manage_passwords_bubble_needs_showing_) { |
172 DCHECK(state == ManagePasswordsIcon::PENDING_STATE); | 196 DCHECK(state == ManagePasswordsIcon::PENDING_STATE); |
173 // TODO(mkwst): Replace this with execution of a browser command once we | 197 // TODO(mkwst): Replace this with execution of a browser command once we |
174 // can pipe a CommandUpdater down here. | 198 // can pipe a CommandUpdater down here. |
175 icon->ShowBubbleWithoutUserInteraction(); | 199 icon->ShowBubbleWithoutUserInteraction(); |
176 manage_passwords_bubble_needs_showing_ = false; | 200 manage_passwords_bubble_needs_showing_ = false; |
177 } | 201 } |
178 } | 202 } |
OLD | NEW |