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/chrome_password_manager_client.h" | 9 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
10 #include "chrome/browser/password_manager/password_store_factory.h" | 10 #include "chrome/browser/password_manager/password_store_factory.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 password_form_map_ = ConstifyMap(form_manager_->best_matches()); | 111 password_form_map_ = ConstifyMap(form_manager_->best_matches()); |
112 origin_ = PendingPassword().origin; | 112 origin_ = PendingPassword().origin; |
113 SetState(password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE); | 113 SetState(password_manager::ui::PENDING_PASSWORD_AND_BUBBLE_STATE); |
114 timer_.reset(new base::ElapsedTimer()); | 114 timer_.reset(new base::ElapsedTimer()); |
115 UpdateBubbleAndIconVisibility(); | 115 UpdateBubbleAndIconVisibility(); |
116 } | 116 } |
117 | 117 |
118 bool ManagePasswordsUIController::OnChooseCredentials( | 118 bool ManagePasswordsUIController::OnChooseCredentials( |
119 ScopedVector<autofill::PasswordForm> local_credentials, | 119 ScopedVector<autofill::PasswordForm> local_credentials, |
120 ScopedVector<autofill::PasswordForm> federated_credentials, | 120 ScopedVector<autofill::PasswordForm> federated_credentials, |
121 base::Callback<void(const password_manager::CredentialInfo&)> callback){ | 121 const GURL& origin, |
| 122 base::Callback<void(const password_manager::CredentialInfo&)> callback) { |
122 DCHECK(!local_credentials.empty() || !federated_credentials.empty()); | 123 DCHECK(!local_credentials.empty() || !federated_credentials.empty()); |
123 form_manager_.reset(); | 124 form_manager_.reset(); |
124 // TODO(melandory): fix the crash when |local_credentials| is empty. | 125 origin_ = origin; |
125 // By providing origin explicitly. | |
126 if (!local_credentials.empty()) | |
127 origin_ = local_credentials[0]->origin; | |
128 else | |
129 origin_ = GURL(); | |
130 local_credentials_forms_.swap(local_credentials); | 126 local_credentials_forms_.swap(local_credentials); |
131 federated_credentials_forms_.swap(federated_credentials); | 127 federated_credentials_forms_.swap(federated_credentials); |
132 // The map is useless because usernames may overlap. | 128 // The map is useless because usernames may overlap. |
133 password_form_map_.clear(); | 129 password_form_map_.clear(); |
134 SetState(password_manager::ui::CREDENTIAL_REQUEST_AND_BUBBLE_STATE); | 130 SetState(password_manager::ui::CREDENTIAL_REQUEST_AND_BUBBLE_STATE); |
135 UpdateBubbleAndIconVisibility(); | 131 UpdateBubbleAndIconVisibility(); |
136 if (bubble_shown_) | 132 if (bubble_shown_) |
137 credentials_callback_ = callback; | 133 credentials_callback_ = callback; |
138 return bubble_shown_; | 134 return bubble_shown_; |
139 } | 135 } |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 bool ManagePasswordsUIController::PasswordPendingUserDecision() const { | 352 bool ManagePasswordsUIController::PasswordPendingUserDecision() const { |
357 return password_manager::ui::IsPendingState(state_); | 353 return password_manager::ui::IsPendingState(state_); |
358 } | 354 } |
359 | 355 |
360 void ManagePasswordsUIController::WebContentsDestroyed() { | 356 void ManagePasswordsUIController::WebContentsDestroyed() { |
361 password_manager::PasswordStore* password_store = | 357 password_manager::PasswordStore* password_store = |
362 GetPasswordStore(web_contents()); | 358 GetPasswordStore(web_contents()); |
363 if (password_store) | 359 if (password_store) |
364 password_store->RemoveObserver(this); | 360 password_store->RemoveObserver(this); |
365 } | 361 } |
OLD | NEW |