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

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

Issue 1459793002: Android: Allow compiling browser without Java UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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_navigator_params.h" 14 #include "chrome/browser/ui/browser_navigator_params.h"
15 #include "chrome/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/browser/ui/chrome_pages.h" 16 #include "chrome/browser/ui/chrome_pages.h"
17 #include "chrome/browser/ui/location_bar/location_bar.h" 17 #include "chrome/browser/ui/location_bar/location_bar.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/browser/statistics_table.h" 24 #include "components/password_manager/core/browser/statistics_table.h"
25 #include "components/password_manager/core/common/credential_manager_types.h" 25 #include "components/password_manager/core/common/credential_manager_types.h"
26 #include "content/public/browser/navigation_details.h" 26 #include "content/public/browser/navigation_details.h"
27 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
28 28
29 #if defined(OS_ANDROID) 29 #if defined(ANDROID_JAVA_UI)
30 #include "chrome/browser/android/chrome_application.h" 30 #include "chrome/browser/android/chrome_application.h"
31 #include "chrome/browser/infobars/infobar_service.h" 31 #include "chrome/browser/infobars/infobar_service.h"
32 #include "chrome/browser/password_manager/account_chooser_dialog_android.h" 32 #include "chrome/browser/password_manager/account_chooser_dialog_android.h"
33 #else 33 #else
34 #include "chrome/browser/ui/passwords/manage_passwords_icon_view.h" 34 #include "chrome/browser/ui/passwords/manage_passwords_icon_view.h"
35 #endif 35 #endif
36 36
37 using autofill::PasswordFormMap; 37 using autofill::PasswordFormMap;
38 using password_manager::PasswordFormManager; 38 using password_manager::PasswordFormManager;
39 39
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 ManagePasswordsUIController::~ManagePasswordsUIController() {} 72 ManagePasswordsUIController::~ManagePasswordsUIController() {}
73 73
74 void ManagePasswordsUIController::UpdateBubbleAndIconVisibility() { 74 void ManagePasswordsUIController::UpdateBubbleAndIconVisibility() {
75 // If we're not on a "webby" URL (e.g. "chrome://sign-in"), we shouldn't 75 // If we're not on a "webby" URL (e.g. "chrome://sign-in"), we shouldn't
76 // display either the bubble or the icon. 76 // display either the bubble or the icon.
77 if (!BrowsingDataHelper::IsWebScheme( 77 if (!BrowsingDataHelper::IsWebScheme(
78 web_contents()->GetLastCommittedURL().scheme())) { 78 web_contents()->GetLastCommittedURL().scheme())) {
79 passwords_data_.OnInactive(); 79 passwords_data_.OnInactive();
80 } 80 }
81 81
82 #if !defined(OS_ANDROID) 82 #if !defined(ANDROID_JAVA_UI)
83 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); 83 Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
84 if (!browser) 84 if (!browser)
85 return; 85 return;
86 LocationBar* location_bar = browser->window()->GetLocationBar(); 86 LocationBar* location_bar = browser->window()->GetLocationBar();
87 DCHECK(location_bar); 87 DCHECK(location_bar);
88 location_bar->UpdateManagePasswordsIconAndBubble(); 88 location_bar->UpdateManagePasswordsIconAndBubble();
89 #endif 89 #endif
90 } 90 }
91 91
92 void ManagePasswordsUIController:: 92 void ManagePasswordsUIController::
93 UpdateAndroidAccountChooserInfoBarVisibility() { 93 UpdateAndroidAccountChooserInfoBarVisibility() {
94 #if defined(OS_ANDROID) 94 #if defined(ANDROID_JAVA_UI)
95 // Deletes itself on the event from Java counterpart, when user interacts with 95 // Deletes itself on the event from Java counterpart, when user interacts with
96 // dialog. 96 // dialog.
97 AccountChooserDialogAndroid* acccount_chooser_dialog = 97 AccountChooserDialogAndroid* acccount_chooser_dialog =
98 new AccountChooserDialogAndroid(web_contents(), this); 98 new AccountChooserDialogAndroid(web_contents(), this);
99 acccount_chooser_dialog->ShowDialog(); 99 acccount_chooser_dialog->ShowDialog();
100 should_pop_up_bubble_ = false; 100 should_pop_up_bubble_ = false;
101 #endif 101 #endif
102 } 102 }
103 103
104 base::TimeDelta ManagePasswordsUIController::Elapsed() const { 104 base::TimeDelta ManagePasswordsUIController::Elapsed() const {
(...skipping 25 matching lines...) Expand all
130 bool ManagePasswordsUIController::OnChooseCredentials( 130 bool ManagePasswordsUIController::OnChooseCredentials(
131 ScopedVector<autofill::PasswordForm> local_credentials, 131 ScopedVector<autofill::PasswordForm> local_credentials,
132 ScopedVector<autofill::PasswordForm> federated_credentials, 132 ScopedVector<autofill::PasswordForm> federated_credentials,
133 const GURL& origin, 133 const GURL& origin,
134 base::Callback<void(const password_manager::CredentialInfo&)> callback) { 134 base::Callback<void(const password_manager::CredentialInfo&)> callback) {
135 DCHECK(!local_credentials.empty() || !federated_credentials.empty()); 135 DCHECK(!local_credentials.empty() || !federated_credentials.empty());
136 passwords_data_.OnRequestCredentials(local_credentials.Pass(), 136 passwords_data_.OnRequestCredentials(local_credentials.Pass(),
137 federated_credentials.Pass(), 137 federated_credentials.Pass(),
138 origin); 138 origin);
139 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true); 139 base::AutoReset<bool> resetter(&should_pop_up_bubble_, true);
140 #if defined(OS_ANDROID) 140 #if defined(ANDROID_JAVA_UI)
141 UpdateAndroidAccountChooserInfoBarVisibility(); 141 UpdateAndroidAccountChooserInfoBarVisibility();
142 #else 142 #else
143 UpdateBubbleAndIconVisibility(); 143 UpdateBubbleAndIconVisibility();
144 #endif 144 #endif
145 if (!should_pop_up_bubble_) { 145 if (!should_pop_up_bubble_) {
146 passwords_data_.set_credentials_callback(callback); 146 passwords_data_.set_credentials_callback(callback);
147 return true; 147 return true;
148 } 148 }
149 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE); 149 passwords_data_.TransitionToState(password_manager::ui::MANAGE_STATE);
150 return false; 150 return false;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 UpdateBubbleAndIconVisibility(); 291 UpdateBubbleAndIconVisibility();
292 } 292 }
293 293
294 void ManagePasswordsUIController::ChooseCredential( 294 void ManagePasswordsUIController::ChooseCredential(
295 const autofill::PasswordForm& form, 295 const autofill::PasswordForm& form,
296 password_manager::CredentialType credential_type) { 296 password_manager::CredentialType credential_type) {
297 passwords_data_.ChooseCredential(form, credential_type); 297 passwords_data_.ChooseCredential(form, credential_type);
298 } 298 }
299 299
300 void ManagePasswordsUIController::NavigateToExternalPasswordManager() { 300 void ManagePasswordsUIController::NavigateToExternalPasswordManager() {
301 #if defined(OS_ANDROID) 301 #if defined(ANDROID_JAVA_UI)
302 NOTREACHED(); 302 NOTREACHED();
303 #else 303 #else
304 chrome::NavigateParams params( 304 chrome::NavigateParams params(
305 chrome::FindBrowserWithWebContents(web_contents()), 305 chrome::FindBrowserWithWebContents(web_contents()),
306 GURL(chrome::kPasswordManagerAccountDashboardURL), 306 GURL(chrome::kPasswordManagerAccountDashboardURL),
307 ui::PAGE_TRANSITION_LINK); 307 ui::PAGE_TRANSITION_LINK);
308 params.disposition = NEW_FOREGROUND_TAB; 308 params.disposition = NEW_FOREGROUND_TAB;
309 chrome::Navigate(&params); 309 chrome::Navigate(&params);
310 #endif 310 #endif
311 } 311 }
312 312
313 void ManagePasswordsUIController::NavigateToSmartLockPage() { 313 void ManagePasswordsUIController::NavigateToSmartLockPage() {
314 #if defined(OS_ANDROID) 314 #if defined(ANDROID_JAVA_UI)
315 NOTREACHED(); 315 NOTREACHED();
316 #else 316 #else
317 chrome::NavigateParams params( 317 chrome::NavigateParams params(
318 chrome::FindBrowserWithWebContents(web_contents()), 318 chrome::FindBrowserWithWebContents(web_contents()),
319 GURL(l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK_PAGE)), 319 GURL(l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SMART_LOCK_PAGE)),
320 ui::PAGE_TRANSITION_LINK); 320 ui::PAGE_TRANSITION_LINK);
321 params.disposition = NEW_FOREGROUND_TAB; 321 params.disposition = NEW_FOREGROUND_TAB;
322 chrome::Navigate(&params); 322 chrome::Navigate(&params);
323 #endif 323 #endif
324 } 324 }
325 325
326 void ManagePasswordsUIController::NavigateToSmartLockHelpPage() { 326 void ManagePasswordsUIController::NavigateToSmartLockHelpPage() {
327 #if defined(OS_ANDROID) 327 #if defined(ANDROID_JAVA_UI)
328 NOTREACHED(); 328 NOTREACHED();
329 #else 329 #else
330 chrome::NavigateParams params( 330 chrome::NavigateParams params(
331 chrome::FindBrowserWithWebContents(web_contents()), 331 chrome::FindBrowserWithWebContents(web_contents()),
332 GURL(chrome::kSmartLockHelpPage), ui::PAGE_TRANSITION_LINK); 332 GURL(chrome::kSmartLockHelpPage), ui::PAGE_TRANSITION_LINK);
333 params.disposition = NEW_FOREGROUND_TAB; 333 params.disposition = NEW_FOREGROUND_TAB;
334 chrome::Navigate(&params); 334 chrome::Navigate(&params);
335 #endif 335 #endif
336 } 336 }
337 337
338 void ManagePasswordsUIController::NavigateToPasswordManagerSettingsPage() { 338 void ManagePasswordsUIController::NavigateToPasswordManagerSettingsPage() {
339 #if defined(OS_ANDROID) 339 #if defined(ANDROID_JAVA_UI)
340 chrome::android::ChromeApplication::ShowPasswordSettings(); 340 chrome::android::ChromeApplication::ShowPasswordSettings();
341 #else 341 #else
342 chrome::ShowSettingsSubPage( 342 chrome::ShowSettingsSubPage(
343 chrome::FindBrowserWithWebContents(web_contents()), 343 chrome::FindBrowserWithWebContents(web_contents()),
344 chrome::kPasswordManagerSubPage); 344 chrome::kPasswordManagerSubPage);
345 #endif 345 #endif
346 } 346 }
347 347
348 void ManagePasswordsUIController::SavePasswordInternal() { 348 void ManagePasswordsUIController::SavePasswordInternal() {
349 password_manager::PasswordStore* password_store = 349 password_manager::PasswordStore* password_store =
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 386
387 // Otherwise, reset the password manager and the timer. 387 // Otherwise, reset the password manager and the timer.
388 passwords_data_.OnInactive(); 388 passwords_data_.OnInactive();
389 UpdateBubbleAndIconVisibility(); 389 UpdateBubbleAndIconVisibility();
390 // This allows the bubble to survive several redirects in case the whole 390 // This allows the bubble to survive several redirects in case the whole
391 // process of navigating to the landing page is longer than 1 second. 391 // process of navigating to the landing page is longer than 1 second.
392 timer_.reset(new base::ElapsedTimer()); 392 timer_.reset(new base::ElapsedTimer());
393 } 393 }
394 394
395 void ManagePasswordsUIController::WasHidden() { 395 void ManagePasswordsUIController::WasHidden() {
396 #if !defined(OS_ANDROID) 396 #if !defined(ANDROID_JAVA_UI)
397 TabDialogs::FromWebContents(web_contents())->HideManagePasswordsBubble(); 397 TabDialogs::FromWebContents(web_contents())->HideManagePasswordsBubble();
398 #endif 398 #endif
399 } 399 }
400 400
401 #if !defined(OS_ANDROID) 401 #if !defined(ANDROID_JAVA_UI)
402 void ManagePasswordsUIController::UpdateIconAndBubbleState( 402 void ManagePasswordsUIController::UpdateIconAndBubbleState(
403 ManagePasswordsIconView* icon) { 403 ManagePasswordsIconView* icon) {
404 if (should_pop_up_bubble_) { 404 if (should_pop_up_bubble_) {
405 // We must display the icon before showing the bubble, as the bubble would 405 // We must display the icon before showing the bubble, as the bubble would
406 // be otherwise unanchored. 406 // be otherwise unanchored.
407 icon->SetState(GetState()); 407 icon->SetState(GetState());
408 ShowBubbleWithoutUserInteraction(); 408 ShowBubbleWithoutUserInteraction();
409 } else { 409 } else {
410 icon->SetState(GetState()); 410 icon->SetState(GetState());
411 } 411 }
412 } 412 }
413 #endif 413 #endif
414 414
415 void ManagePasswordsUIController::ShowBubbleWithoutUserInteraction() { 415 void ManagePasswordsUIController::ShowBubbleWithoutUserInteraction() {
416 DCHECK(should_pop_up_bubble_); 416 DCHECK(should_pop_up_bubble_);
417 #if !defined(OS_ANDROID) 417 #if !defined(ANDROID_JAVA_UI)
418 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); 418 Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
419 if (!browser || browser->toolbar_model()->input_in_progress()) 419 if (!browser || browser->toolbar_model()->input_in_progress())
420 return; 420 return;
421 421
422 CommandUpdater* updater = browser->command_controller()->command_updater(); 422 CommandUpdater* updater = browser->command_controller()->command_updater();
423 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE); 423 updater->ExecuteCommand(IDC_MANAGE_PASSWORDS_FOR_PAGE);
424 #endif 424 #endif
425 } 425 }
426 426
427 void ManagePasswordsUIController::WebContentsDestroyed() { 427 void ManagePasswordsUIController::WebContentsDestroyed() {
428 password_manager::PasswordStore* password_store = 428 password_manager::PasswordStore* password_store =
429 GetPasswordStore(web_contents()); 429 GetPasswordStore(web_contents());
430 if (password_store) 430 if (password_store)
431 password_store->RemoveObserver(this); 431 password_store->RemoveObserver(this);
432 } 432 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698