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

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

Issue 1858513002: chrome/browser/password_manager: scoped_ptr -> unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows -- revert unwanted change Created 4 years, 8 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/save_password_infobar_delegate.h" 5 #include "chrome/browser/password_manager/save_password_infobar_delegate.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h"
9 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
10 #include "chrome/browser/infobars/infobar_service.h" 11 #include "chrome/browser/infobars/infobar_service.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/sync/profile_sync_service_factory.h" 13 #include "chrome/browser/sync/profile_sync_service_factory.h"
13 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h" 14 #include "chrome/browser/ui/passwords/manage_passwords_view_utils.h"
14 #include "chrome/grit/chromium_strings.h" 15 #include "chrome/grit/chromium_strings.h"
15 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
16 #include "components/browser_sync/browser/profile_sync_service.h" 17 #include "components/browser_sync/browser/profile_sync_service.h"
17 #include "components/infobars/core/infobar.h" 18 #include "components/infobars/core/infobar.h"
18 #include "components/password_manager/core/browser/password_bubble_experiment.h" 19 #include "components/password_manager/core/browser/password_bubble_experiment.h"
19 #include "components/password_manager/core/browser/password_manager_client.h" 20 #include "components/password_manager/core/browser/password_manager_client.h"
20 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
21 #include "grit/theme_resources.h" 22 #include "grit/theme_resources.h"
22 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
23 #include "url/origin.h" 24 #include "url/origin.h"
24 25
25 // static 26 // static
26 void SavePasswordInfoBarDelegate::Create( 27 void SavePasswordInfoBarDelegate::Create(
27 content::WebContents* web_contents, 28 content::WebContents* web_contents,
28 scoped_ptr<password_manager::PasswordFormManager> form_to_save) { 29 std::unique_ptr<password_manager::PasswordFormManager> form_to_save) {
29 Profile* profile = 30 Profile* profile =
30 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 31 Profile::FromBrowserContext(web_contents->GetBrowserContext());
31 sync_driver::SyncService* sync_service = 32 sync_driver::SyncService* sync_service =
32 ProfileSyncServiceFactory::GetForProfile(profile); 33 ProfileSyncServiceFactory::GetForProfile(profile);
33 bool is_smartlock_branding_enabled = 34 bool is_smartlock_branding_enabled =
34 password_bubble_experiment::IsSmartLockBrandingSavePromptEnabled( 35 password_bubble_experiment::IsSmartLockBrandingSavePromptEnabled(
35 sync_service); 36 sync_service);
36 bool should_show_first_run_experience = 37 bool should_show_first_run_experience =
37 password_bubble_experiment::ShouldShowSavePromptFirstRunExperience( 38 password_bubble_experiment::ShouldShowSavePromptFirstRunExperience(
38 sync_service, profile->GetPrefs()); 39 sync_service, profile->GetPrefs());
39 InfoBarService::FromWebContents(web_contents) 40 InfoBarService::FromWebContents(web_contents)
40 ->AddInfoBar(CreateSavePasswordInfoBar(make_scoped_ptr( 41 ->AddInfoBar(CreateSavePasswordInfoBar(base::WrapUnique(
41 new SavePasswordInfoBarDelegate(web_contents, std::move(form_to_save), 42 new SavePasswordInfoBarDelegate(web_contents, std::move(form_to_save),
42 is_smartlock_branding_enabled, 43 is_smartlock_branding_enabled,
43 should_show_first_run_experience)))); 44 should_show_first_run_experience))));
44 } 45 }
45 46
46 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { 47 SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() {
47 password_manager::metrics_util::LogUIDismissalReason(infobar_response_); 48 password_manager::metrics_util::LogUIDismissalReason(infobar_response_);
48 49
49 if (should_show_first_run_experience_) { 50 if (should_show_first_run_experience_) {
50 Profile* profile = 51 Profile* profile =
51 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); 52 Profile::FromBrowserContext(web_contents_->GetBrowserContext());
52 password_bubble_experiment::RecordSavePromptFirstRunExperienceWasShown( 53 password_bubble_experiment::RecordSavePromptFirstRunExperienceWasShown(
53 profile->GetPrefs()); 54 profile->GetPrefs());
54 } 55 }
55 } 56 }
56 57
57 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( 58 SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate(
58 content::WebContents* web_contents, 59 content::WebContents* web_contents,
59 scoped_ptr<password_manager::PasswordFormManager> form_to_save, 60 std::unique_ptr<password_manager::PasswordFormManager> form_to_save,
60 bool is_smartlock_branding_enabled, 61 bool is_smartlock_branding_enabled,
61 bool should_show_first_run_experience) 62 bool should_show_first_run_experience)
62 : PasswordManagerInfoBarDelegate(), 63 : PasswordManagerInfoBarDelegate(),
63 form_to_save_(std::move(form_to_save)), 64 form_to_save_(std::move(form_to_save)),
64 infobar_response_(password_manager::metrics_util::NO_DIRECT_INTERACTION), 65 infobar_response_(password_manager::metrics_util::NO_DIRECT_INTERACTION),
65 should_show_first_run_experience_(should_show_first_run_experience), 66 should_show_first_run_experience_(should_show_first_run_experience),
66 web_contents_(web_contents) { 67 web_contents_(web_contents) {
67 base::string16 message; 68 base::string16 message;
68 gfx::Range message_link_range = gfx::Range(); 69 gfx::Range message_link_range = gfx::Range();
69 PasswordTittleType type = 70 PasswordTittleType type =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 infobar_response_ = password_manager::metrics_util::CLICKED_SAVE; 109 infobar_response_ = password_manager::metrics_util::CLICKED_SAVE;
109 return true; 110 return true;
110 } 111 }
111 112
112 bool SavePasswordInfoBarDelegate::Cancel() { 113 bool SavePasswordInfoBarDelegate::Cancel() {
113 DCHECK(form_to_save_.get()); 114 DCHECK(form_to_save_.get());
114 form_to_save_->PermanentlyBlacklist(); 115 form_to_save_->PermanentlyBlacklist();
115 infobar_response_ = password_manager::metrics_util::CLICKED_NEVER; 116 infobar_response_ = password_manager::metrics_util::CLICKED_NEVER;
116 return true; 117 return true;
117 } 118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698