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

Side by Side Diff: chrome/browser/extensions/api/experience_sampling_private/experience_sampling.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header 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/extensions/api/experience_sampling_private/experience_s ampling.h" 5 #include "chrome/browser/extensions/api/experience_sampling_private/experience_s ampling.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 16 matching lines...) Expand all
27 const char ExperienceSamplingEvent::kMaliciousDownload[] = 27 const char ExperienceSamplingEvent::kMaliciousDownload[] =
28 "download_warning_malicious"; 28 "download_warning_malicious";
29 const char ExperienceSamplingEvent::kDangerousDownload[] = 29 const char ExperienceSamplingEvent::kDangerousDownload[] =
30 "download_warning_dangerous"; 30 "download_warning_dangerous";
31 const char ExperienceSamplingEvent::kDownloadDangerPrompt[] = 31 const char ExperienceSamplingEvent::kDownloadDangerPrompt[] =
32 "download_danger_prompt"; 32 "download_danger_prompt";
33 const char ExperienceSamplingEvent::kExtensionInstallDialog[] = 33 const char ExperienceSamplingEvent::kExtensionInstallDialog[] =
34 "extension_install_dialog_"; 34 "extension_install_dialog_";
35 35
36 // static 36 // static
37 scoped_ptr<ExperienceSamplingEvent> ExperienceSamplingEvent::Create( 37 std::unique_ptr<ExperienceSamplingEvent> ExperienceSamplingEvent::Create(
38 const std::string& element_name, 38 const std::string& element_name,
39 const GURL& destination, 39 const GURL& destination,
40 const GURL& referrer) { 40 const GURL& referrer) {
41 Profile* profile = NULL; 41 Profile* profile = NULL;
42 if (g_browser_process->profile_manager()) 42 if (g_browser_process->profile_manager())
43 profile = g_browser_process->profile_manager()->GetLastUsedProfile(); 43 profile = g_browser_process->profile_manager()->GetLastUsedProfile();
44 if (!profile) 44 if (!profile)
45 return scoped_ptr<ExperienceSamplingEvent>(); 45 return std::unique_ptr<ExperienceSamplingEvent>();
46 return scoped_ptr<ExperienceSamplingEvent>(new ExperienceSamplingEvent( 46 return std::unique_ptr<ExperienceSamplingEvent>(new ExperienceSamplingEvent(
47 element_name, destination, referrer, profile)); 47 element_name, destination, referrer, profile));
48 } 48 }
49 49
50 // static 50 // static
51 scoped_ptr<ExperienceSamplingEvent> ExperienceSamplingEvent::Create( 51 std::unique_ptr<ExperienceSamplingEvent> ExperienceSamplingEvent::Create(
52 const std::string& element_name) { 52 const std::string& element_name) {
53 return ExperienceSamplingEvent::Create(element_name, GURL(), GURL()); 53 return ExperienceSamplingEvent::Create(element_name, GURL(), GURL());
54 } 54 }
55 55
56 ExperienceSamplingEvent::ExperienceSamplingEvent( 56 ExperienceSamplingEvent::ExperienceSamplingEvent(
57 const std::string& element_name, 57 const std::string& element_name,
58 const GURL& destination, 58 const GURL& destination,
59 const GURL& referrer, 59 const GURL& referrer,
60 content::BrowserContext* browser_context) 60 content::BrowserContext* browser_context)
61 : has_viewed_details_(false), 61 : has_viewed_details_(false),
(...skipping 13 matching lines...) Expand all
75 // Check if this is from an incognito context. If it is, don't create and send 75 // Check if this is from an incognito context. If it is, don't create and send
76 // any events. 76 // any events.
77 if (browser_context_ && browser_context_->IsOffTheRecord()) 77 if (browser_context_ && browser_context_->IsOffTheRecord())
78 return; 78 return;
79 api::experience_sampling_private::UserDecision decision; 79 api::experience_sampling_private::UserDecision decision;
80 decision.name = decision_name; 80 decision.name = decision_name;
81 decision.learn_more = has_viewed_learn_more(); 81 decision.learn_more = has_viewed_learn_more();
82 decision.details = has_viewed_details(); 82 decision.details = has_viewed_details();
83 decision.time = base::Time::Now().ToJsTime(); 83 decision.time = base::Time::Now().ToJsTime();
84 84
85 scoped_ptr<base::ListValue> args(new base::ListValue()); 85 std::unique_ptr<base::ListValue> args(new base::ListValue());
86 args->Append(ui_element_.ToValue().release()); 86 args->Append(ui_element_.ToValue().release());
87 args->Append(decision.ToValue().release()); 87 args->Append(decision.ToValue().release());
88 scoped_ptr<Event> event( 88 std::unique_ptr<Event> event(
89 new Event(events::EXPERIENCE_SAMPLING_PRIVATE_ON_DECISION, 89 new Event(events::EXPERIENCE_SAMPLING_PRIVATE_ON_DECISION,
90 api::experience_sampling_private::OnDecision::kEventName, 90 api::experience_sampling_private::OnDecision::kEventName,
91 std::move(args))); 91 std::move(args)));
92 EventRouter* router = EventRouter::Get(browser_context_); 92 EventRouter* router = EventRouter::Get(browser_context_);
93 if (router) 93 if (router)
94 router->BroadcastEvent(std::move(event)); 94 router->BroadcastEvent(std::move(event));
95 } 95 }
96 96
97 void ExperienceSamplingEvent::CreateOnDisplayedEvent() { 97 void ExperienceSamplingEvent::CreateOnDisplayedEvent() {
98 // Check if this is from an incognito context. If it is, don't create and send 98 // Check if this is from an incognito context. If it is, don't create and send
99 // any events. 99 // any events.
100 if (browser_context_ && browser_context_->IsOffTheRecord()) 100 if (browser_context_ && browser_context_->IsOffTheRecord())
101 return; 101 return;
102 scoped_ptr<base::ListValue> args(new base::ListValue()); 102 std::unique_ptr<base::ListValue> args(new base::ListValue());
103 args->Append(ui_element_.ToValue().release()); 103 args->Append(ui_element_.ToValue().release());
104 scoped_ptr<Event> event( 104 std::unique_ptr<Event> event(
105 new Event(events::EXPERIENCE_SAMPLING_PRIVATE_ON_DISPLAYED, 105 new Event(events::EXPERIENCE_SAMPLING_PRIVATE_ON_DISPLAYED,
106 api::experience_sampling_private::OnDisplayed::kEventName, 106 api::experience_sampling_private::OnDisplayed::kEventName,
107 std::move(args))); 107 std::move(args)));
108 EventRouter* router = EventRouter::Get(browser_context_); 108 EventRouter* router = EventRouter::Get(browser_context_);
109 if (router) 109 if (router)
110 router->BroadcastEvent(std::move(event)); 110 router->BroadcastEvent(std::move(event));
111 } 111 }
112 112
113 } // namespace extensions 113 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698