Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1566)

Side by Side Diff: chrome/browser/ui/passwords/manage_passwords_ui_controller.cc

Issue 1391893003: NOT FOR REVIEW: Aura on Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/browsing_data/browsing_data_helper.h" 9 #include "chrome/browser/browsing_data/browsing_data_helper.h"
10 #include "chrome/browser/password_manager/chrome_password_manager_client.h" 10 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
11 #include "chrome/browser/password_manager/password_store_factory.h" 11 #include "chrome/browser/password_manager/password_store_factory.h"
12 #include "chrome/browser/ui/browser_command_controller.h" 12 #include "chrome/browser/ui/browser_command_controller.h"
13 #include "chrome/browser/ui/browser_finder.h" 13 #include "chrome/browser/ui/browser_finder.h"
14 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/chrome_pages.h" 15 #include "chrome/browser/ui/chrome_pages.h"
16 #include "chrome/browser/ui/location_bar/location_bar.h" 16 #include "chrome/browser/ui/location_bar/location_bar.h"
17 #include "chrome/browser/ui/passwords/manage_passwords_icon.h" 17 #include "chrome/browser/ui/passwords/manage_passwords_icon.h"
18 #include "chrome/browser/ui/tab_dialogs.h" 18 #include "chrome/browser/ui/tab_dialogs.h"
19 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
20 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
21 #include "components/password_manager/core/browser/browser_save_password_progres s_logger.h" 21 #include "components/password_manager/core/browser/browser_save_password_progres s_logger.h"
22 #include "components/password_manager/core/browser/password_bubble_experiment.h" 22 #include "components/password_manager/core/browser/password_bubble_experiment.h"
23 #include "components/password_manager/core/browser/password_form_manager.h" 23 #include "components/password_manager/core/browser/password_form_manager.h"
24 #include "components/password_manager/core/common/credential_manager_types.h" 24 #include "components/password_manager/core/common/credential_manager_types.h"
25 #include "content/public/browser/navigation_details.h" 25 #include "content/public/browser/navigation_details.h"
26 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
27 27
28 #if defined(OS_ANDROID) 28 #if defined(OS_ANDROID) && !defined(USE_AURA)
29 #include "chrome/browser/android/chrome_application.h" 29 #include "chrome/browser/android/chrome_application.h"
30 #include "chrome/browser/infobars/infobar_service.h" 30 #include "chrome/browser/infobars/infobar_service.h"
31 #include "chrome/browser/password_manager/account_chooser_infobar_delegate_andro id.h" 31 #include "chrome/browser/password_manager/account_chooser_infobar_delegate_andro id.h"
32 #endif 32 #endif
33 33
34 using autofill::PasswordFormMap; 34 using autofill::PasswordFormMap;
35 using password_manager::PasswordFormManager; 35 using password_manager::PasswordFormManager;
36 36
37 namespace { 37 namespace {
38 38
(...skipping 26 matching lines...) Expand all
65 ManagePasswordsUIController::~ManagePasswordsUIController() {} 65 ManagePasswordsUIController::~ManagePasswordsUIController() {}
66 66
67 void ManagePasswordsUIController::UpdateBubbleAndIconVisibility() { 67 void ManagePasswordsUIController::UpdateBubbleAndIconVisibility() {
68 // If we're not on a "webby" URL (e.g. "chrome://sign-in"), we shouldn't 68 // If we're not on a "webby" URL (e.g. "chrome://sign-in"), we shouldn't
69 // display either the bubble or the icon. 69 // display either the bubble or the icon.
70 if (!BrowsingDataHelper::IsWebScheme( 70 if (!BrowsingDataHelper::IsWebScheme(
71 web_contents()->GetLastCommittedURL().scheme())) { 71 web_contents()->GetLastCommittedURL().scheme())) {
72 passwords_data_.OnInactive(); 72 passwords_data_.OnInactive();
73 } 73 }
74 74
75 #if !defined(OS_ANDROID) 75 #if !defined(OS_ANDROID) || defined(USE_AURA)
76 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); 76 Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
77 if (!browser) 77 if (!browser)
78 return; 78 return;
79 LocationBar* location_bar = browser->window()->GetLocationBar(); 79 LocationBar* location_bar = browser->window()->GetLocationBar();
80 DCHECK(location_bar); 80 DCHECK(location_bar);
81 location_bar->UpdateManagePasswordsIconAndBubble(); 81 location_bar->UpdateManagePasswordsIconAndBubble();
82 #endif 82 #endif
83 } 83 }
84 84
85 void ManagePasswordsUIController:: 85 void ManagePasswordsUIController::
86 UpdateAndroidAccountChooserInfoBarVisibility() { 86 UpdateAndroidAccountChooserInfoBarVisibility() {
87 #if defined(OS_ANDROID) 87 #if defined(OS_ANDROID) && !defined(USE_AURA)
88 AccountChooserInfoBarDelegateAndroid::Create( 88 AccountChooserInfoBarDelegateAndroid::Create(
89 InfoBarService::FromWebContents(web_contents()), this); 89 InfoBarService::FromWebContents(web_contents()), this);
90 should_pop_up_bubble_ = false; 90 should_pop_up_bubble_ = false;
91 #endif 91 #endif
92 } 92 }
93 93
94 base::TimeDelta ManagePasswordsUIController::Elapsed() const { 94 base::TimeDelta ManagePasswordsUIController::Elapsed() const {
95 return timer_ ? timer_->Elapsed() : base::TimeDelta::Max(); 95 return timer_ ? timer_->Elapsed() : base::TimeDelta::Max();
96 } 96 }
97 97
(...skipping 16 matching lines...) Expand all
114 bool ManagePasswordsUIController::OnChooseCredentials( 114 bool ManagePasswordsUIController::OnChooseCredentials(
115 ScopedVector<autofill::PasswordForm> local_credentials, 115 ScopedVector<autofill::PasswordForm> local_credentials,
116 ScopedVector<autofill::PasswordForm> federated_credentials, 116 ScopedVector<autofill::PasswordForm> federated_credentials,
117 const GURL& origin, 117 const GURL& origin,
118 base::Callback<void(const password_manager::CredentialInfo&)> callback) { 118 base::Callback<void(const password_manager::CredentialInfo&)> callback) {
119 DCHECK_IMPLIES(local_credentials.empty(), !federated_credentials.empty()); 119 DCHECK_IMPLIES(local_credentials.empty(), !federated_credentials.empty());
120 passwords_data_.OnRequestCredentials(local_credentials.Pass(), 120 passwords_data_.OnRequestCredentials(local_credentials.Pass(),
121 federated_credentials.Pass(), 121 federated_credentials.Pass(),
122 origin); 122 origin);
123 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); 123 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true);
124 #if defined(OS_ANDROID) 124 #if defined(OS_ANDROID) && !defined(USE_AURA)
125 UpdateAndroidAccountChooserInfoBarVisibility(); 125 UpdateAndroidAccountChooserInfoBarVisibility();
126 #else 126 #else
127 UpdateBubbleAndIconVisibility(); 127 UpdateBubbleAndIconVisibility();
128 #endif 128 #endif
129 if (!should_pop_up_bubble_) { 129 if (!should_pop_up_bubble_) {
130 passwords_data_.set_credentials_callback(callback); 130 passwords_data_.set_credentials_callback(callback);
131 return true; 131 return true;
132 } 132 }
133 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); 133 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE);
134 return false; 134 return false;
(...skipping 29 matching lines...) Expand all
164 164
165 void ManagePasswordsUIController::OnLoginsChanged( 165 void ManagePasswordsUIController::OnLoginsChanged(
166 const password_manager::PasswordStoreChangeList& changes) { 166 const password_manager::PasswordStoreChangeList& changes) {
167 password_manager::ui::State current_state = state(); 167 password_manager::ui::State current_state = state();
168 passwords_data_.ProcessLoginsChanged(changes); 168 passwords_data_.ProcessLoginsChanged(changes);
169 if (current_state != state()) 169 if (current_state != state())
170 UpdateBubbleAndIconVisibility(); 170 UpdateBubbleAndIconVisibility();
171 } 171 }
172 172
173 void ManagePasswordsUIController::NavigateToPasswordManagerSettingsPage() { 173 void ManagePasswordsUIController::NavigateToPasswordManagerSettingsPage() {
174 #if defined(OS_ANDROID) 174 #if defined(OS_ANDROID) && !defined(USE_AURA)
175 chrome::android::ChromeApplication::ShowPasswordSettings(); 175 chrome::android::ChromeApplication::ShowPasswordSettings();
176 #else 176 #else
177 chrome::ShowSettingsSubPage( 177 chrome::ShowSettingsSubPage(
178 chrome::FindBrowserWithWebContents(web_contents()), 178 chrome::FindBrowserWithWebContents(web_contents()),
179 chrome::kPasswordManagerSubPage); 179 chrome::kPasswordManagerSubPage);
180 #endif 180 #endif
181 } 181 }
182 182
183 void ManagePasswordsUIController::NavigateToExternalPasswordManager() { 183 void ManagePasswordsUIController::NavigateToExternalPasswordManager() {
184 #if defined(OS_ANDROID) 184 #if defined(OS_ANDROID) && !defined(USE_AURA)
185 NOTREACHED(); 185 NOTREACHED();
186 #else 186 #else
187 chrome::NavigateParams params( 187 chrome::NavigateParams params(
188 chrome::FindBrowserWithWebContents(web_contents()), 188 chrome::FindBrowserWithWebContents(web_contents()),
189 GURL(chrome::kPasswordManagerAccountDashboardURL), 189 GURL(chrome::kPasswordManagerAccountDashboardURL),
190 ui::PAGE_TRANSITION_LINK); 190 ui::PAGE_TRANSITION_LINK);
191 params.disposition = NEW_FOREGROUND_TAB; 191 params.disposition = NEW_FOREGROUND_TAB;
192 chrome::Navigate(&params); 192 chrome::Navigate(&params);
193 #endif 193 #endif
194 } 194 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 328
329 // Otherwise, reset the password manager and the timer. 329 // Otherwise, reset the password manager and the timer.
330 passwords_data_.OnInactive(); 330 passwords_data_.OnInactive();
331 UpdateBubbleAndIconVisibility(); 331 UpdateBubbleAndIconVisibility();
332 // This allows the bubble to survive several redirects in case the whole 332 // This allows the bubble to survive several redirects in case the whole
333 // process of navigating to the landing page is longer than 1 second. 333 // process of navigating to the landing page is longer than 1 second.
334 timer_.reset(new base::ElapsedTimer()); 334 timer_.reset(new base::ElapsedTimer());
335 } 335 }
336 336
337 void ManagePasswordsUIController::WasHidden() { 337 void ManagePasswordsUIController::WasHidden() {
338 #if !defined(OS_ANDROID) 338 #if !defined(OS_ANDROID) || defined(USE_AURA)
339 TabDialogs::FromWebContents(web_contents())->HideManagePasswordsBubble(); 339 TabDialogs::FromWebContents(web_contents())->HideManagePasswordsBubble();
340 #endif 340 #endif
341 } 341 }
342 342
343 const autofill::PasswordForm& ManagePasswordsUIController:: 343 const autofill::PasswordForm& ManagePasswordsUIController::
344 PendingPassword() const { 344 PendingPassword() const {
345 DCHECK(state() == password_manager::ui::PENDING_PASSWORD_STATE || 345 DCHECK(state() == password_manager::ui::PENDING_PASSWORD_STATE ||
346 state() == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE || 346 state() == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE ||
347 state() == password_manager::ui::CONFIRMATION_STATE) 347 state() == password_manager::ui::CONFIRMATION_STATE)
348 << state(); 348 << state();
(...skipping 23 matching lines...) Expand all
372 if (state() == password_manager::ui::CREDENTIAL_REQUEST_STATE || 372 if (state() == password_manager::ui::CREDENTIAL_REQUEST_STATE ||
373 state() == password_manager::ui::CONFIRMATION_STATE || 373 state() == password_manager::ui::CONFIRMATION_STATE ||
374 state() == password_manager::ui::AUTO_SIGNIN_STATE) { 374 state() == password_manager::ui::AUTO_SIGNIN_STATE) {
375 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); 375 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE);
376 UpdateBubbleAndIconVisibility(); 376 UpdateBubbleAndIconVisibility();
377 } 377 }
378 } 378 }
379 379
380 void ManagePasswordsUIController::ShowBubbleWithoutUserInteraction() { 380 void ManagePasswordsUIController::ShowBubbleWithoutUserInteraction() {
381 DCHECK(should_pop_up_bubble_); 381 DCHECK(should_pop_up_bubble_);
382 #if !defined(OS_ANDROID) 382 #if !defined(OS_ANDROID) || defined(USE_AURA)
383 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); 383 Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
384 if (!browser || browser->toolbar_model()->input_in_progress()) 384 if (!browser || browser->toolbar_model()->input_in_progress())
385 return; 385 return;
386 386
387 CommandUpdater* updater = browser->command_controller()->command_updater(); 387 CommandUpdater* updater = browser->command_controller()->command_updater();
388 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); 388 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE);
389 #endif 389 #endif
390 } 390 }
391 391
392 void ManagePasswordsUIController::WebContentsDestroyed() { 392 void ManagePasswordsUIController::WebContentsDestroyed() {
393 password_manager::PasswordStore* password_store = 393 password_manager::PasswordStore* password_store =
394 GetPasswordStore(web_contents()); 394 GetPasswordStore(web_contents());
395 if (password_store) 395 if (password_store)
396 password_store->RemoveObserver(this); 396 password_store->RemoveObserver(this);
397 } 397 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698