OLD | NEW |
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/save_password_infobar_delegate.h" | 5 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "chrome/browser/infobars/infobar_service.h" | 8 #include "chrome/browser/infobars/infobar_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/sync/profile_sync_service.h" |
| 11 #include "chrome/browser/sync/profile_sync_service_factory.h" |
10 #include "chrome/browser/ui/passwords/password_bubble_experiment.h" | 12 #include "chrome/browser/ui/passwords/password_bubble_experiment.h" |
11 #include "chrome/grit/chromium_strings.h" | 13 #include "chrome/grit/chromium_strings.h" |
12 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
13 #include "components/infobars/core/infobar.h" | 15 #include "components/infobars/core/infobar.h" |
14 #include "components/password_manager/core/browser/password_manager_client.h" | 16 #include "components/password_manager/core/browser/password_manager_client.h" |
15 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
16 #include "grit/theme_resources.h" | 18 #include "grit/theme_resources.h" |
17 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
18 | 20 |
19 #if defined(OS_ANDROID) | 21 #if defined(OS_ANDROID) |
(...skipping 14 matching lines...) Expand all Loading... |
34 // static | 36 // static |
35 void SavePasswordInfoBarDelegate::Create( | 37 void SavePasswordInfoBarDelegate::Create( |
36 content::WebContents* web_contents, | 38 content::WebContents* web_contents, |
37 scoped_ptr<password_manager::PasswordFormManager> form_to_save, | 39 scoped_ptr<password_manager::PasswordFormManager> form_to_save, |
38 const std::string& uma_histogram_suffix, | 40 const std::string& uma_histogram_suffix, |
39 password_manager::CredentialSourceType source_type) { | 41 password_manager::CredentialSourceType source_type) { |
40 InfoBarService* infobar_service = | 42 InfoBarService* infobar_service = |
41 InfoBarService::FromWebContents(web_contents); | 43 InfoBarService::FromWebContents(web_contents); |
42 Profile* profile = | 44 Profile* profile = |
43 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 45 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 46 const ProfileSyncService* sync_service = |
| 47 ProfileSyncServiceFactory::GetForProfile(profile); |
44 SavePasswordInfoBarDelegate* infobar_delegate = | 48 SavePasswordInfoBarDelegate* infobar_delegate = |
45 new SavePasswordInfoBarDelegate( | 49 new SavePasswordInfoBarDelegate( |
46 form_to_save.Pass(), uma_histogram_suffix, source_type, | 50 form_to_save.Pass(), uma_histogram_suffix, source_type, |
47 password_bubble_experiment::IsSmartLockBrandingEnabled(profile)); | 51 password_bubble_experiment::IsSmartLockBrandingEnabled(sync_service)); |
48 #if defined(OS_ANDROID) | 52 #if defined(OS_ANDROID) |
49 // For Android in case of smart lock we need different appearance of infobar. | 53 // For Android in case of smart lock we need different appearance of infobar. |
50 scoped_ptr<infobars::InfoBar> infobar = | 54 scoped_ptr<infobars::InfoBar> infobar = |
51 make_scoped_ptr(new SavePasswordInfoBar( | 55 make_scoped_ptr(new SavePasswordInfoBar( |
52 scoped_ptr<SavePasswordInfoBarDelegate>(infobar_delegate))); | 56 scoped_ptr<SavePasswordInfoBarDelegate>(infobar_delegate))); |
53 #else | 57 #else |
54 // For desktop we'll keep using the ConfirmInfobar. | 58 // For desktop we'll keep using the ConfirmInfobar. |
55 scoped_ptr<infobars::InfoBar> infobar(infobar_service->CreateConfirmInfoBar( | 59 scoped_ptr<infobars::InfoBar> infobar(infobar_service->CreateConfirmInfoBar( |
56 scoped_ptr<ConfirmInfoBarDelegate>(infobar_delegate))); | 60 scoped_ptr<ConfirmInfoBarDelegate>(infobar_delegate))); |
57 #endif | 61 #endif |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 WindowOpenDisposition disposition) { | 180 WindowOpenDisposition disposition) { |
177 InfoBarService::WebContentsFromInfoBar(infobar()) | 181 InfoBarService::WebContentsFromInfoBar(infobar()) |
178 ->OpenURL(content::OpenURLParams( | 182 ->OpenURL(content::OpenURLParams( |
179 GURL(l10n_util::GetStringUTF16( | 183 GURL(l10n_util::GetStringUTF16( |
180 IDS_PASSWORD_MANAGER_SMART_LOCK_ARTICLE)), | 184 IDS_PASSWORD_MANAGER_SMART_LOCK_ARTICLE)), |
181 content::Referrer(), | 185 content::Referrer(), |
182 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 186 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
183 ui::PAGE_TRANSITION_LINK, false)); | 187 ui::PAGE_TRANSITION_LINK, false)); |
184 return true; | 188 return true; |
185 } | 189 } |
OLD | NEW |