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/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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 api::experience_sampling_private::UserDecision decision; | 77 api::experience_sampling_private::UserDecision decision; |
78 decision.name = decision_name; | 78 decision.name = decision_name; |
79 decision.learn_more = has_viewed_learn_more(); | 79 decision.learn_more = has_viewed_learn_more(); |
80 decision.details = has_viewed_details(); | 80 decision.details = has_viewed_details(); |
81 decision.time = base::Time::Now().ToJsTime(); | 81 decision.time = base::Time::Now().ToJsTime(); |
82 | 82 |
83 scoped_ptr<base::ListValue> args(new base::ListValue()); | 83 scoped_ptr<base::ListValue> args(new base::ListValue()); |
84 args->Append(ui_element_.ToValue().release()); | 84 args->Append(ui_element_.ToValue().release()); |
85 args->Append(decision.ToValue().release()); | 85 args->Append(decision.ToValue().release()); |
86 scoped_ptr<Event> event(new Event( | 86 scoped_ptr<Event> event(new Event( |
87 api::experience_sampling_private::OnDecision::kEventName, args.Pass())); | 87 events::UNKNOWN, api::experience_sampling_private::OnDecision::kEventName, |
| 88 args.Pass())); |
88 EventRouter* router = EventRouter::Get(browser_context_); | 89 EventRouter* router = EventRouter::Get(browser_context_); |
89 if (router) | 90 if (router) |
90 router->BroadcastEvent(event.Pass()); | 91 router->BroadcastEvent(event.Pass()); |
91 } | 92 } |
92 | 93 |
93 void ExperienceSamplingEvent::CreateOnDisplayedEvent() { | 94 void ExperienceSamplingEvent::CreateOnDisplayedEvent() { |
94 // Check if this is from an incognito context. If it is, don't create and send | 95 // Check if this is from an incognito context. If it is, don't create and send |
95 // any events. | 96 // any events. |
96 if (browser_context_ && browser_context_->IsOffTheRecord()) | 97 if (browser_context_ && browser_context_->IsOffTheRecord()) |
97 return; | 98 return; |
98 scoped_ptr<base::ListValue> args(new base::ListValue()); | 99 scoped_ptr<base::ListValue> args(new base::ListValue()); |
99 args->Append(ui_element_.ToValue().release()); | 100 args->Append(ui_element_.ToValue().release()); |
100 scoped_ptr<Event> event(new Event( | 101 scoped_ptr<Event> event(new Event( |
| 102 events::UNKNOWN, |
101 api::experience_sampling_private::OnDisplayed::kEventName, args.Pass())); | 103 api::experience_sampling_private::OnDisplayed::kEventName, args.Pass())); |
102 EventRouter* router = EventRouter::Get(browser_context_); | 104 EventRouter* router = EventRouter::Get(browser_context_); |
103 if (router) | 105 if (router) |
104 router->BroadcastEvent(event.Pass()); | 106 router->BroadcastEvent(event.Pass()); |
105 } | 107 } |
106 | 108 |
107 } // namespace extensions | 109 } // namespace extensions |
OLD | NEW |