| 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 <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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 std::unique_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()); |
| 87 args->Append(decision.ToValue().release()); | 87 args->Append(decision.ToValue()); |
| 88 std::unique_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 std::unique_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()); |
| 104 std::unique_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 |
| OLD | NEW |