| 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/browsing_data/browsing_data_helper.h" | 8 #include "chrome/browser/browsing_data/browsing_data_helper.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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 #if !defined(OS_ANDROID) | 85 #if !defined(OS_ANDROID) |
| 86 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); | 86 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |
| 87 if (!browser) | 87 if (!browser) |
| 88 return; | 88 return; |
| 89 LocationBar* location_bar = browser->window()->GetLocationBar(); | 89 LocationBar* location_bar = browser->window()->GetLocationBar(); |
| 90 DCHECK(location_bar); | 90 DCHECK(location_bar); |
| 91 location_bar->UpdateManagePasswordsIconAndBubble(); | 91 location_bar->UpdateManagePasswordsIconAndBubble(); |
| 92 #endif | 92 #endif |
| 93 } | 93 } |
| 94 | 94 |
| 95 void ManagePasswordsUIController::OnAskToReportURL(const GURL& url) { |
| 96 origin_ = url; |
| 97 state_ = password_manager::ui::ASK_USER_TO_REPORT_URL_STATE; |
| 98 UpdateBubbleAndIconVisibility(); |
| 99 } |
| 100 |
| 95 void ManagePasswordsUIController::OnPasswordSubmitted( | 101 void ManagePasswordsUIController::OnPasswordSubmitted( |
| 96 scoped_ptr<PasswordFormManager> form_manager) { | 102 scoped_ptr<PasswordFormManager> form_manager) { |
| 97 form_manager_ = form_manager.Pass(); | 103 form_manager_ = form_manager.Pass(); |
| 98 password_form_map_ = ConstifyMap(form_manager_->best_matches()); | 104 password_form_map_ = ConstifyMap(form_manager_->best_matches()); |
| 99 origin_ = PendingPassword().origin; | 105 origin_ = PendingPassword().origin; |
| 100 state_ = password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE; | 106 state_ = password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE; |
| 101 UpdateBubbleAndIconVisibility(); | 107 UpdateBubbleAndIconVisibility(); |
| 102 } | 108 } |
| 103 | 109 |
| 104 bool ManagePasswordsUIController::OnChooseCredentials( | 110 bool ManagePasswordsUIController::OnChooseCredentials( |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 const content::FrameNavigateParams& params) { | 250 const content::FrameNavigateParams& params) { |
| 245 // Don't react to in-page (fragment) navigations. | 251 // Don't react to in-page (fragment) navigations. |
| 246 if (details.is_in_page) | 252 if (details.is_in_page) |
| 247 return; | 253 return; |
| 248 | 254 |
| 249 // Don't do anything if a navigation occurs before a user could reasonably | 255 // Don't do anything if a navigation occurs before a user could reasonably |
| 250 // interact with the password bubble. | 256 // interact with the password bubble. |
| 251 if (timer_ && timer_->Elapsed() < base::TimeDelta::FromSeconds(1)) | 257 if (timer_ && timer_->Elapsed() < base::TimeDelta::FromSeconds(1)) |
| 252 return; | 258 return; |
| 253 | 259 |
| 260 // This allows "Allow to collect URL?" bubble to outlive the coming |
| 261 // navigation. |
| 262 if (state_ == |
| 263 password_manager::ui::ASK_USER_TO_REPORT_URL_AFTER_NEXT_LOAD_STATE) { |
| 264 // TODO(melandory): Substitute this with a proper solution using |
| 265 // provisional_save_manager. |
| 266 state_ = password_manager::ui::ASK_USER_TO_REPORT_URL_AND_BUBBLE_STATE; |
| 267 return; |
| 268 } |
| 269 |
| 254 // Otherwise, reset the password manager and the timer. | 270 // Otherwise, reset the password manager and the timer. |
| 255 state_ = password_manager::ui::INACTIVE_STATE; | 271 state_ = password_manager::ui::INACTIVE_STATE; |
| 256 UpdateBubbleAndIconVisibility(); | 272 UpdateBubbleAndIconVisibility(); |
| 257 timer_.reset(new base::ElapsedTimer()); | 273 timer_.reset(new base::ElapsedTimer()); |
| 258 } | 274 } |
| 259 | 275 |
| 260 void ManagePasswordsUIController::WasHidden() { | 276 void ManagePasswordsUIController::WasHidden() { |
| 261 #if !defined(OS_ANDROID) | 277 #if !defined(OS_ANDROID) |
| 262 chrome::CloseManagePasswordsBubble(web_contents()); | 278 chrome::CloseManagePasswordsBubble(web_contents()); |
| 263 #endif | 279 #endif |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 bool ManagePasswordsUIController::PasswordPendingUserDecision() const { | 325 bool ManagePasswordsUIController::PasswordPendingUserDecision() const { |
| 310 return password_manager::ui::IsPendingState(state_); | 326 return password_manager::ui::IsPendingState(state_); |
| 311 } | 327 } |
| 312 | 328 |
| 313 void ManagePasswordsUIController::WebContentsDestroyed() { | 329 void ManagePasswordsUIController::WebContentsDestroyed() { |
| 314 password_manager::PasswordStore* password_store = | 330 password_manager::PasswordStore* password_store = |
| 315 GetPasswordStore(web_contents()); | 331 GetPasswordStore(web_contents()); |
| 316 if (password_store) | 332 if (password_store) |
| 317 password_store->RemoveObserver(this); | 333 password_store->RemoveObserver(this); |
| 318 } | 334 } |
| OLD | NEW |