Chromium Code Reviews| 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 // TODO(mkwst): Hrm. | |
|
vabr (Chromium)
2014/04/29 13:30:12
Please elaborate on "Hrm.", so that if you suddenl
Mike West
2014/04/30 10:39:32
That's a _much_ happier scenario than the typical
| |
| 149 password_manager::PasswordStore* password_store = | |
| 150 GetPasswordStore(web_contents()); | |
| 151 if (!password_store) | |
| 152 return; | |
| 153 | |
| 154 // We're in one of two states: either the user _just_ blacklisted the site | |
| 155 // by clicking "Never save" in the pending bubble, or the user is visiting | |
| 156 // a blacklisted site. | |
| 157 // | |
| 158 // Either way, |password_form_map_| has been populated with the relevant | |
| 159 // form. We can safely pull it out, send it over to the password store | |
| 160 // for removal, and update our internal state. | |
| 161 password_store->RemoveLogin(*password_form_map_.begin()->second); | |
| 162 autofill_blocked_ = false; | |
| 163 UpdateBubbleAndIconVisibility(); | |
| 138 } | 164 } |
| 139 | 165 |
| 140 void ManagePasswordsBubbleUIController::DidNavigateMainFrame( | 166 void ManagePasswordsBubbleUIController::DidNavigateMainFrame( |
| 141 const content::LoadCommittedDetails& details, | 167 const content::LoadCommittedDetails& details, |
| 142 const content::FrameNavigateParams& params) { | 168 const content::FrameNavigateParams& params) { |
| 143 if (details.is_in_page) | 169 if (details.is_in_page) |
| 144 return; | 170 return; |
| 145 // Reset password states for next page. | 171 // Reset password states for next page. |
| 146 manage_passwords_icon_to_be_shown_ = false; | 172 manage_passwords_icon_to_be_shown_ = false; |
| 147 password_to_be_saved_ = false; | 173 password_to_be_saved_ = false; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 169 icon->SetState(state); | 195 icon->SetState(state); |
| 170 | 196 |
| 171 if (manage_passwords_bubble_needs_showing_) { | 197 if (manage_passwords_bubble_needs_showing_) { |
| 172 DCHECK(state == ManagePasswordsIcon::PENDING_STATE); | 198 DCHECK(state == ManagePasswordsIcon::PENDING_STATE); |
| 173 // TODO(mkwst): Replace this with execution of a browser command once we | 199 // TODO(mkwst): Replace this with execution of a browser command once we |
| 174 // can pipe a CommandUpdater down here. | 200 // can pipe a CommandUpdater down here. |
| 175 icon->ShowBubbleWithoutUserInteraction(); | 201 icon->ShowBubbleWithoutUserInteraction(); |
| 176 manage_passwords_bubble_needs_showing_ = false; | 202 manage_passwords_bubble_needs_showing_ = false; |
| 177 } | 203 } |
| 178 } | 204 } |
| OLD | NEW |