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

Side by Side Diff: chrome/browser/password_manager/chrome_password_manager_client.cc

Issue 1313383006: Don't compile save_password_infobar_delegate.cc everywhere but Mac and Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Exclude kEnableSavePasswordBubble/kDisableSavePasswordBubble definitions on Aura platforms Created 5 years, 3 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/password_manager/chrome_password_manager_client.h" 5 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "chrome/browser/browsing_data/browsing_data_helper.h" 13 #include "chrome/browser/browsing_data/browsing_data_helper.h"
14 #include "chrome/browser/password_manager/password_store_factory.h" 14 #include "chrome/browser/password_manager/password_store_factory.h"
15 #include "chrome/browser/password_manager/save_password_infobar_delegate.h"
16 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/signin/signin_manager_factory.h" 16 #include "chrome/browser/signin/signin_manager_factory.h"
18 #include "chrome/browser/sync/profile_sync_service.h" 17 #include "chrome/browser/sync/profile_sync_service.h"
19 #include "chrome/browser/sync/profile_sync_service_factory.h" 18 #include "chrome/browser/sync/profile_sync_service_factory.h"
20 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h " 19 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h "
21 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 20 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
22 #include "chrome/common/channel_info.h" 21 #include "chrome/common/channel_info.h"
23 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
25 #include "components/autofill/content/browser/content_autofill_driver.h" 24 #include "components/autofill/content/browser/content_autofill_driver.h"
(...skipping 16 matching lines...) Expand all
42 #include "components/password_manager/sync/browser/password_sync_util.h" 41 #include "components/password_manager/sync/browser/password_sync_util.h"
43 #include "components/signin/core/browser/signin_manager.h" 42 #include "components/signin/core/browser/signin_manager.h"
44 #include "components/version_info/version_info.h" 43 #include "components/version_info/version_info.h"
45 #include "content/public/browser/navigation_entry.h" 44 #include "content/public/browser/navigation_entry.h"
46 #include "content/public/browser/render_view_host.h" 45 #include "content/public/browser/render_view_host.h"
47 #include "content/public/browser/web_contents.h" 46 #include "content/public/browser/web_contents.h"
48 #include "google_apis/gaia/gaia_urls.h" 47 #include "google_apis/gaia/gaia_urls.h"
49 #include "net/base/url_util.h" 48 #include "net/base/url_util.h"
50 #include "third_party/re2/re2/re2.h" 49 #include "third_party/re2/re2/re2.h"
51 50
51 #if defined(OS_MACOSX) || defined(OS_ANDROID)
52 #include "chrome/browser/password_manager/save_password_infobar_delegate.h"
53 #endif
54
52 #if defined(OS_ANDROID) 55 #if defined(OS_ANDROID)
53 #include "chrome/browser/android/tab_android.h" 56 #include "chrome/browser/android/tab_android.h"
54 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg ate_android.h" 57 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg ate_android.h"
55 #include "chrome/browser/ui/android/snackbars/auto_signin_snackbar_controller.h" 58 #include "chrome/browser/ui/android/snackbars/auto_signin_snackbar_controller.h"
56 #endif 59 #endif
57 60
58 using password_manager::ContentPasswordManagerDriverFactory; 61 using password_manager::ContentPasswordManagerDriverFactory;
59 using password_manager::PasswordManagerInternalsService; 62 using password_manager::PasswordManagerInternalsService;
60 using password_manager::PasswordManagerInternalsServiceFactory; 63 using password_manager::PasswordManagerInternalsServiceFactory;
61 64
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 if (IsTheHotNewBubbleUIEnabled()) { 212 if (IsTheHotNewBubbleUIEnabled()) {
210 ManagePasswordsUIController* manage_passwords_ui_controller = 213 ManagePasswordsUIController* manage_passwords_ui_controller =
211 ManagePasswordsUIController::FromWebContents(web_contents()); 214 ManagePasswordsUIController::FromWebContents(web_contents());
212 if (update_password && IsUpdatePasswordUIEnabled()) { 215 if (update_password && IsUpdatePasswordUIEnabled()) {
213 manage_passwords_ui_controller->OnUpdatePasswordSubmitted( 216 manage_passwords_ui_controller->OnUpdatePasswordSubmitted(
214 form_to_save.Pass()); 217 form_to_save.Pass());
215 } else { 218 } else {
216 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save.Pass()); 219 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save.Pass());
217 } 220 }
218 } else { 221 } else {
222 #if defined(OS_MACOSX) || defined(OS_ANDROID)
219 if (form_to_save->IsBlacklisted()) 223 if (form_to_save->IsBlacklisted())
220 return false; 224 return false;
221 std::string uma_histogram_suffix( 225 std::string uma_histogram_suffix(
222 password_manager::metrics_util::GroupIdToString( 226 password_manager::metrics_util::GroupIdToString(
223 password_manager::metrics_util::MonitoredDomainGroupId( 227 password_manager::metrics_util::MonitoredDomainGroupId(
224 form_to_save->pending_credentials().signon_realm, GetPrefs()))); 228 form_to_save->pending_credentials().signon_realm, GetPrefs())));
225 SavePasswordInfoBarDelegate::Create( 229 SavePasswordInfoBarDelegate::Create(
226 web_contents(), form_to_save.Pass(), uma_histogram_suffix, type); 230 web_contents(), form_to_save.Pass(), uma_histogram_suffix, type);
231 #else
232 NOTREACHED() << "Aura platforms should always use the bubble";
233 #endif
227 } 234 }
228 return true; 235 return true;
229 } 236 }
230 237
231 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( 238 bool ChromePasswordManagerClient::PromptUserToChooseCredentials(
232 ScopedVector<autofill::PasswordForm> local_forms, 239 ScopedVector<autofill::PasswordForm> local_forms,
233 ScopedVector<autofill::PasswordForm> federated_forms, 240 ScopedVector<autofill::PasswordForm> federated_forms,
234 const GURL& origin, 241 const GURL& origin,
235 base::Callback<void(const password_manager::CredentialInfo&)> callback) { 242 base::Callback<void(const password_manager::CredentialInfo&)> callback) {
236 return ManagePasswordsUIController::FromWebContents(web_contents())-> 243 return ManagePasswordsUIController::FromWebContents(web_contents())->
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 return false; 506 return false;
500 507
501 // All password sites, including test sites, have autofilling disabled. 508 // All password sites, including test sites, have autofilling disabled.
502 CR_DEFINE_STATIC_LOCAL(RE2, account_dashboard_pattern, 509 CR_DEFINE_STATIC_LOCAL(RE2, account_dashboard_pattern,
503 ("passwords(-([a-z-]+\\.corp))?\\.google\\.com")); 510 ("passwords(-([a-z-]+\\.corp))?\\.google\\.com"));
504 511
505 return RE2::FullMatch(GURL(param_value).host(), account_dashboard_pattern); 512 return RE2::FullMatch(GURL(param_value).host(), account_dashboard_pattern);
506 } 513 }
507 514
508 bool ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled() { 515 bool ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled() {
509 #if !defined(USE_AURA) && !defined(OS_MACOSX) 516 #if defined(OS_MACOSX) || defined(OS_ANDROID)
510 return false;
511 #endif
512 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 517 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
513 if (command_line->HasSwitch(switches::kDisableSavePasswordBubble)) 518 if (command_line->HasSwitch(switches::kDisableSavePasswordBubble)) {
vabr (Chromium) 2015/09/10 07:21:47 nit: Drop the { and }, for on-liner "if" it is not
ki.stfu 2015/09/10 18:21:00 Done.
514 return false; 519 return false;
520 }
515 521
516 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble)) 522 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble))
517 return true; 523 return true;
518 524
519 std::string group_name = 525 std::string group_name =
520 base::FieldTrialList::FindFullName("PasswordManagerUI"); 526 base::FieldTrialList::FindFullName("PasswordManagerUI");
521 527
522 // The bubble should be the default case that runs on the bots. 528 // The bubble should be the default case that runs on the bots.
523 return group_name != "Infobar"; 529 return group_name != "Infobar";
530 #else
531 // All other platforms use Aura, and therefore always show the bubble.
532 return true;
533 #endif
524 } 534 }
525 535
526 bool ChromePasswordManagerClient::IsUpdatePasswordUIEnabled() const { 536 bool ChromePasswordManagerClient::IsUpdatePasswordUIEnabled() const {
527 #if defined(OS_MACOSX) 537 #if defined(OS_MACOSX)
528 return false; 538 return false;
529 #else 539 #else
530 return IsTheHotNewBubbleUIEnabled(); 540 return IsTheHotNewBubbleUIEnabled();
531 #endif 541 #endif
532 } 542 }
533 543
(...skipping 24 matching lines...) Expand all
558 if (!entry) 568 if (!entry)
559 return GURL::EmptyGURL(); 569 return GURL::EmptyGURL();
560 570
561 return entry->GetURL(); 571 return entry->GetURL();
562 } 572 }
563 573
564 const password_manager::CredentialsFilter* 574 const password_manager::CredentialsFilter*
565 ChromePasswordManagerClient::GetStoreResultFilter() const { 575 ChromePasswordManagerClient::GetStoreResultFilter() const {
566 return &credentials_filter_; 576 return &credentials_filter_;
567 } 577 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698