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_android
.h" | 5 #include "chrome/browser/password_manager/save_password_infobar_delegate_android
.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
11 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/sync/profile_sync_service_factory.h" | 13 #include "chrome/browser/sync/profile_sync_service_factory.h" |
14 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" | 14 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" |
15 #include "chrome/grit/chromium_strings.h" | 15 #include "chrome/grit/chromium_strings.h" |
16 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
17 #include "chrome/grit/theme_resources.h" | 17 #include "chrome/grit/theme_resources.h" |
18 #include "components/browser_sync/profile_sync_service.h" | 18 #include "components/browser_sync/profile_sync_service.h" |
19 #include "components/infobars/core/infobar.h" | 19 #include "components/infobars/core/infobar.h" |
20 #include "components/infobars/core/infobar_manager.h" | 20 #include "components/infobars/core/infobar_manager.h" |
21 #include "components/password_manager/core/browser/password_bubble_experiment.h" | 21 #include "components/password_manager/core/browser/password_bubble_experiment.h" |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 #include "url/origin.h" | 24 #include "url/origin.h" |
25 | 25 |
26 // static | 26 // static |
27 void SavePasswordInfoBarDelegate::Create( | 27 void SavePasswordInfoBarDelegate::Create( |
28 content::WebContents* web_contents, | 28 content::WebContents* web_contents, |
29 std::unique_ptr<password_manager::PasswordFormManager> form_to_save) { | 29 scoped_refptr<password_manager::PasswordFormManager> form_to_save) { |
30 Profile* profile = | 30 Profile* profile = |
31 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 31 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
32 syncer::SyncService* sync_service = | 32 syncer::SyncService* sync_service = |
33 ProfileSyncServiceFactory::GetForProfile(profile); | 33 ProfileSyncServiceFactory::GetForProfile(profile); |
34 bool is_smartlock_branding_enabled = | 34 bool is_smartlock_branding_enabled = |
35 password_bubble_experiment::IsSmartLockUser(sync_service); | 35 password_bubble_experiment::IsSmartLockUser(sync_service); |
36 InfoBarService* infobar_service = | 36 InfoBarService* infobar_service = |
37 InfoBarService::FromWebContents(web_contents); | 37 InfoBarService::FromWebContents(web_contents); |
38 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( | 38 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( |
39 std::unique_ptr<ConfirmInfoBarDelegate>( | 39 std::unique_ptr<ConfirmInfoBarDelegate>( |
40 new SavePasswordInfoBarDelegate(web_contents, std::move(form_to_save), | 40 new SavePasswordInfoBarDelegate(web_contents, std::move(form_to_save), |
41 is_smartlock_branding_enabled)))); | 41 is_smartlock_branding_enabled)))); |
42 } | 42 } |
43 | 43 |
44 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { | 44 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { |
45 password_manager::metrics_util::LogUIDismissalReason(infobar_response_); | 45 password_manager::metrics_util::LogUIDismissalReason(infobar_response_); |
46 } | 46 } |
47 | 47 |
48 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( | 48 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( |
49 content::WebContents* web_contents, | 49 content::WebContents* web_contents, |
50 std::unique_ptr<password_manager::PasswordFormManager> form_to_save, | 50 scoped_refptr<password_manager::PasswordFormManager> form_to_save, |
51 bool is_smartlock_branding_enabled) | 51 bool is_smartlock_branding_enabled) |
52 : PasswordManagerInfoBarDelegate(), | 52 : PasswordManagerInfoBarDelegate(), |
53 form_to_save_(std::move(form_to_save)), | 53 form_to_save_(std::move(form_to_save)), |
54 infobar_response_(password_manager::metrics_util::NO_DIRECT_INTERACTION) { | 54 infobar_response_(password_manager::metrics_util::NO_DIRECT_INTERACTION) { |
55 base::string16 message; | 55 base::string16 message; |
56 gfx::Range message_link_range = gfx::Range(); | 56 gfx::Range message_link_range = gfx::Range(); |
57 PasswordTitleType type = | 57 PasswordTitleType type = |
58 form_to_save_->pending_credentials().federation_origin.unique() | 58 form_to_save_->pending_credentials().federation_origin.unique() |
59 ? PasswordTitleType::SAVE_PASSWORD | 59 ? PasswordTitleType::SAVE_PASSWORD |
60 : PasswordTitleType::SAVE_ACCOUNT; | 60 : PasswordTitleType::SAVE_ACCOUNT; |
(...skipping 28 matching lines...) Expand all Loading... |
89 infobar_response_ = password_manager::metrics_util::CLICKED_SAVE; | 89 infobar_response_ = password_manager::metrics_util::CLICKED_SAVE; |
90 return true; | 90 return true; |
91 } | 91 } |
92 | 92 |
93 bool SavePasswordInfoBarDelegate::Cancel() { | 93 bool SavePasswordInfoBarDelegate::Cancel() { |
94 DCHECK(form_to_save_.get()); | 94 DCHECK(form_to_save_.get()); |
95 form_to_save_->PermanentlyBlacklist(); | 95 form_to_save_->PermanentlyBlacklist(); |
96 infobar_response_ = password_manager::metrics_util::CLICKED_NEVER; | 96 infobar_response_ = password_manager::metrics_util::CLICKED_NEVER; |
97 return true; | 97 return true; |
98 } | 98 } |
OLD | NEW |