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

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

Issue 399773002: Experience sampling insturmentation for SSL and Safe Browsing interstitials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sampling-api
Patch Set: Clean up experience sampling header file changes Created 6 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/safe_browsing_blocking_page.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 ui_element_.time = base::Time::Now().ToJsTime(); 54 ui_element_.time = base::Time::Now().ToJsTime();
55 } 55 }
56 56
57 ExperienceSamplingEvent::~ExperienceSamplingEvent() { 57 ExperienceSamplingEvent::~ExperienceSamplingEvent() {
58 } 58 }
59 59
60 void ExperienceSamplingEvent::CreateUserDecisionEvent( 60 void ExperienceSamplingEvent::CreateUserDecisionEvent(
61 const std::string& decision_name) { 61 const std::string& decision_name) {
62 // Check if this is from an incognito context. If it is, don't create and send 62 // Check if this is from an incognito context. If it is, don't create and send
63 // any events. 63 // any events.
64 if (browser_context_->IsOffTheRecord()) 64 if (browser_context_ && browser_context_->IsOffTheRecord())
65 return; 65 return;
66 api::experience_sampling_private::UserDecision decision; 66 api::experience_sampling_private::UserDecision decision;
67 decision.name = decision_name; 67 decision.name = decision_name;
68 decision.learn_more = has_viewed_learn_more(); 68 decision.learn_more = has_viewed_learn_more();
69 decision.details = has_viewed_details(); 69 decision.details = has_viewed_details();
70 decision.time = base::Time::Now().ToJsTime(); 70 decision.time = base::Time::Now().ToJsTime();
71 71
72 scoped_ptr<base::ListValue> args(new base::ListValue()); 72 scoped_ptr<base::ListValue> args(new base::ListValue());
73 args->Append(ui_element_.ToValue().release()); 73 args->Append(ui_element_.ToValue().release());
74 args->Append(decision.ToValue().release()); 74 args->Append(decision.ToValue().release());
75 scoped_ptr<Event> event(new Event( 75 scoped_ptr<Event> event(new Event(
76 api::experience_sampling_private::OnDecision::kEventName, args.Pass())); 76 api::experience_sampling_private::OnDecision::kEventName, args.Pass()));
77 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); 77 EventRouter* router = EventRouter::Get(browser_context_);
78 if (router)
79 router->BroadcastEvent(event.Pass());
78 } 80 }
79 81
80 void ExperienceSamplingEvent::CreateOnDisplayedEvent() { 82 void ExperienceSamplingEvent::CreateOnDisplayedEvent() {
81 // Check if this is from an incognito context. If it is, don't create and send 83 // Check if this is from an incognito context. If it is, don't create and send
82 // any events. 84 // any events.
83 if (browser_context_->IsOffTheRecord()) 85 if (browser_context_ && browser_context_->IsOffTheRecord())
84 return; 86 return;
85 scoped_ptr<base::ListValue> args(new base::ListValue()); 87 scoped_ptr<base::ListValue> args(new base::ListValue());
86 args->Append(ui_element_.ToValue().release()); 88 args->Append(ui_element_.ToValue().release());
87 scoped_ptr<Event> event(new Event( 89 scoped_ptr<Event> event(new Event(
88 api::experience_sampling_private::OnDisplayed::kEventName, args.Pass())); 90 api::experience_sampling_private::OnDisplayed::kEventName, args.Pass()));
89 EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); 91 EventRouter* router = EventRouter::Get(browser_context_);
92 if (router)
93 router->BroadcastEvent(event.Pass());
90 } 94 }
91 95
92 } // namespace extensions 96 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/safe_browsing_blocking_page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698