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

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

Issue 322093003: Password bubble: The bots should run the bubble code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tests. Created 6 years, 6 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 | Annotate | Revision Log
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_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 20 matching lines...) Expand all
31 #include "content/public/browser/render_view_host.h" 31 #include "content/public/browser/render_view_host.h"
32 #include "content/public/browser/web_contents.h" 32 #include "content/public/browser/web_contents.h"
33 33
34 #if defined(OS_ANDROID) 34 #if defined(OS_ANDROID)
35 #include "chrome/browser/android/password_authentication_manager.h" 35 #include "chrome/browser/android/password_authentication_manager.h"
36 #endif // OS_ANDROID 36 #endif // OS_ANDROID
37 37
38 using password_manager::PasswordManagerInternalsService; 38 using password_manager::PasswordManagerInternalsService;
39 using password_manager::PasswordManagerInternalsServiceFactory; 39 using password_manager::PasswordManagerInternalsServiceFactory;
40 40
41 namespace {
42
43 bool IsTheHotNewBubbleUIEnabled() {
44 #if !defined(USE_AURA)
45 return false;
46 #endif
47 CommandLine* command_line = CommandLine::ForCurrentProcess();
48 if (command_line->HasSwitch(switches::kDisableSavePasswordBubble))
49 return false;
50
51 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble))
52 return true;
53
54 std::string group_name =
55 base::FieldTrialList::FindFullName("PasswordManagerUI");
56 return group_name == "Bubble";
57 }
58
59 } // namespace
60
61 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromePasswordManagerClient); 41 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromePasswordManagerClient);
62 42
63 // static 43 // static
64 void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( 44 void ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
65 content::WebContents* contents, 45 content::WebContents* contents,
66 autofill::AutofillClient* autofill_client) { 46 autofill::AutofillClient* autofill_client) {
67 if (FromWebContents(contents)) 47 if (FromWebContents(contents))
68 return; 48 return;
69 49
70 contents->SetUserData( 50 contents->SetUserData(
(...skipping 28 matching lines...) Expand all
99 password_manager::switches::kEnableAutomaticPasswordSaving) && 79 password_manager::switches::kEnableAutomaticPasswordSaving) &&
100 chrome::VersionInfo::GetChannel() == 80 chrome::VersionInfo::GetChannel() ==
101 chrome::VersionInfo::CHANNEL_UNKNOWN; 81 chrome::VersionInfo::CHANNEL_UNKNOWN;
102 } 82 }
103 83
104 void ChromePasswordManagerClient::PromptUserToSavePassword( 84 void ChromePasswordManagerClient::PromptUserToSavePassword(
105 password_manager::PasswordFormManager* form_to_save) { 85 password_manager::PasswordFormManager* form_to_save) {
106 if (IsTheHotNewBubbleUIEnabled()) { 86 if (IsTheHotNewBubbleUIEnabled()) {
107 ManagePasswordsUIController* manage_passwords_ui_controller = 87 ManagePasswordsUIController* manage_passwords_ui_controller =
108 ManagePasswordsUIController::FromWebContents(web_contents()); 88 ManagePasswordsUIController::FromWebContents(web_contents());
109 if (manage_passwords_ui_controller) { 89 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save);
110 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save);
111 } else {
112 delete form_to_save;
113 }
114 } else { 90 } else {
115 std::string uma_histogram_suffix( 91 std::string uma_histogram_suffix(
116 password_manager::metrics_util::GroupIdToString( 92 password_manager::metrics_util::GroupIdToString(
117 password_manager::metrics_util::MonitoredDomainGroupId( 93 password_manager::metrics_util::MonitoredDomainGroupId(
118 form_to_save->realm(), GetPrefs()))); 94 form_to_save->realm(), GetPrefs())));
119 SavePasswordInfoBarDelegate::Create( 95 SavePasswordInfoBarDelegate::Create(
120 web_contents(), form_to_save, uma_histogram_suffix); 96 web_contents(), form_to_save, uma_histogram_suffix);
121 } 97 }
122 } 98 }
123 99
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 web_contents(), 303 web_contents(),
328 web_contents()->GetNativeView()); 304 web_contents()->GetNativeView());
329 popup_controller_->Show(false /* display_password */); 305 popup_controller_->Show(false /* display_password */);
330 #endif // defined(USE_AURA) || defined(OS_MACOSX) 306 #endif // defined(USE_AURA) || defined(OS_MACOSX)
331 } 307 }
332 308
333 void ChromePasswordManagerClient::CommitFillPasswordForm( 309 void ChromePasswordManagerClient::CommitFillPasswordForm(
334 autofill::PasswordFormFillData* data) { 310 autofill::PasswordFormFillData* data) {
335 driver_.FillPasswordForm(*data); 311 driver_.FillPasswordForm(*data);
336 } 312 }
313
314 bool ChromePasswordManagerClient::IsTheHotNewBubbleUIEnabled() {
315 #if !defined(USE_AURA)
316 return false;
317 #endif
318 CommandLine* command_line = CommandLine::ForCurrentProcess();
319 if (command_line->HasSwitch(switches::kDisableSavePasswordBubble))
320 return false;
321
322 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble))
323 return true;
324
325 std::string group_name =
326 base::FieldTrialList::FindFullName("PasswordManagerUI");
327
328 // The bubble should be the default case that runs on the bots.
329 return group_name != "Infobar";
330 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698