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

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

Issue 861103002: Credentials chooser UI for Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing tests. Created 5 years, 10 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/passwords/password_bubble_experiment.h" 18 #include "chrome/browser/ui/passwords/password_bubble_experiment.h"
19 #include "chrome/browser/ui/tab_dialogs.h" 19 #include "chrome/browser/ui/tab_dialogs.h"
20 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
21 #include "components/password_manager/content/common/credential_manager_types.h" 21 #include "components/password_manager/content/common/credential_manager_types.h"
22 #include "components/password_manager/core/browser/browser_save_password_progres s_logger.h" 22 #include "components/password_manager/core/browser/browser_save_password_progres s_logger.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 "content/public/browser/navigation_details.h" 24 #include "content/public/browser/navigation_details.h"
25 25
26 #if defined(OS_ANDROID) 26 #if defined(OS_ANDROID)
27 #include "chrome/browser/android/chromium_application.h" 27 #include "chrome/browser/android/chromium_application.h"
28 #include "chrome/browser/infobars/infobar_service.h"
29 #include "chrome/browser/password_manager/account_chooser_infobar_delegate_andro id.h"
28 #endif 30 #endif
29 31
30 using autofill::PasswordFormMap; 32 using autofill::PasswordFormMap;
31 using password_manager::PasswordFormManager; 33 using password_manager::PasswordFormManager;
32 34
33 namespace { 35 namespace {
34 36
35 password_manager::PasswordStore* GetPasswordStore( 37 password_manager::PasswordStore* GetPasswordStore(
36 content::WebContents* web_contents) { 38 content::WebContents* web_contents) {
37 return PasswordStoreFactory::GetForProfile( 39 return PasswordStoreFactory::GetForProfile(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 #if !defined(OS_ANDROID) 90 #if !defined(OS_ANDROID)
89 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); 91 Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
90 if (!browser) 92 if (!browser)
91 return; 93 return;
92 LocationBar* location_bar = browser->window()->GetLocationBar(); 94 LocationBar* location_bar = browser->window()->GetLocationBar();
93 DCHECK(location_bar); 95 DCHECK(location_bar);
94 location_bar->UpdateManagePasswordsIconAndBubble(); 96 location_bar->UpdateManagePasswordsIconAndBubble();
95 #endif 97 #endif
96 } 98 }
97 99
100 void ManagePasswordsUIController::
101 UpdateAndroidAccountChooserInfoBarVisibility() {
102 AccountChooserInfoBarDelegateAndroid::Create(
103 InfoBarService::FromWebContents(web_contents()), this);
104 should_pop_up_bubble_ = false;
105 }
106
98 base::TimeDelta ManagePasswordsUIController::Elapsed() const { 107 base::TimeDelta ManagePasswordsUIController::Elapsed() const {
99 return timer_ ? timer_->Elapsed() : base::TimeDelta::Max(); 108 return timer_ ? timer_->Elapsed() : base::TimeDelta::Max();
100 } 109 }
101 110
102 void ManagePasswordsUIController::OnAskToReportURL(const GURL& url) { 111 void ManagePasswordsUIController::OnAskToReportURL(const GURL& url) {
103 origin_ = url; 112 origin_ = url;
104 SetState(password_manager::ui:: 113 SetState(password_manager::ui::
105 ASK_USER_REPORT_URL_BUBBLE_SHOWN_BEFORE_TRANSITION_STATE); 114 ASK_USER_REPORT_URL_BUBBLE_SHOWN_BEFORE_TRANSITION_STATE);
106 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); 115 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true);
107 UpdateBubbleAndIconVisibility(); 116 UpdateBubbleAndIconVisibility();
(...skipping 13 matching lines...) Expand all
121 bool ManagePasswordsUIController::OnChooseCredentials( 130 bool ManagePasswordsUIController::OnChooseCredentials(
122 ScopedVector<autofill::PasswordForm> local_credentials, 131 ScopedVector<autofill::PasswordForm> local_credentials,
123 ScopedVector<autofill::PasswordForm> federated_credentials, 132 ScopedVector<autofill::PasswordForm> federated_credentials,
124 const GURL& origin, 133 const GURL& origin,
125 base::Callback<void(const password_manager::CredentialInfo&)> callback) { 134 base::Callback<void(const password_manager::CredentialInfo&)> callback) {
126 DCHECK(!local_credentials.empty() || !federated_credentials.empty()); 135 DCHECK(!local_credentials.empty() || !federated_credentials.empty());
127 SaveForms(local_credentials.Pass(), federated_credentials.Pass()); 136 SaveForms(local_credentials.Pass(), federated_credentials.Pass());
128 origin_ = origin; 137 origin_ = origin;
129 SetState(password_manager::ui::CREDENTIAL_REQUEST_STATE); 138 SetState(password_manager::ui::CREDENTIAL_REQUEST_STATE);
130 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); 139 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true);
140 #if defined(OS_ANDROID)
141 UpdateAndroidAccountChooserInfoBarVisibility();
142 #else
131 UpdateBubbleAndIconVisibility(); 143 UpdateBubbleAndIconVisibility();
144 #endif
132 if (!should_pop_up_bubble_) { 145 if (!should_pop_up_bubble_) {
133 credentials_callback_ = callback; 146 credentials_callback_ = callback;
134 return true; 147 return true;
135 } 148 }
136 return false; 149 return false;
137 } 150 }
138 151
139 void ManagePasswordsUIController::OnAutoSignin( 152 void ManagePasswordsUIController::OnAutoSignin(
140 ScopedVector<autofill::PasswordForm> local_forms) { 153 ScopedVector<autofill::PasswordForm> local_forms) {
141 DCHECK(!local_forms.empty()); 154 DCHECK(!local_forms.empty());
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 ScopedVector<autofill::PasswordForm> local_forms, 429 ScopedVector<autofill::PasswordForm> local_forms,
417 ScopedVector<autofill::PasswordForm> federated_forms) { 430 ScopedVector<autofill::PasswordForm> federated_forms) {
418 form_manager_.reset(); 431 form_manager_.reset();
419 origin_ = GURL(); 432 origin_ = GURL();
420 local_credentials_forms_.swap(local_forms); 433 local_credentials_forms_.swap(local_forms);
421 federated_credentials_forms_.swap(federated_forms); 434 federated_credentials_forms_.swap(federated_forms);
422 // The map is useless because usernames may overlap. 435 // The map is useless because usernames may overlap.
423 password_form_map_.clear(); 436 password_form_map_.clear();
424 new_password_forms_.clear(); 437 new_password_forms_.clear();
425 } 438 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698