| 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> |
| 8 |
| 7 #include "base/values.h" | 9 #include "base/values.h" |
| 8 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 11 #include "chrome/common/extensions/api/experience_sampling_private.h" | 13 #include "chrome/common/extensions/api/experience_sampling_private.h" |
| 12 #include "extensions/browser/event_router.h" | 14 #include "extensions/browser/event_router.h" |
| 13 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 14 | 16 |
| 15 namespace extensions { | 17 namespace extensions { |
| 16 | 18 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 return; | 78 return; |
| 77 api::experience_sampling_private::UserDecision decision; | 79 api::experience_sampling_private::UserDecision decision; |
| 78 decision.name = decision_name; | 80 decision.name = decision_name; |
| 79 decision.learn_more = has_viewed_learn_more(); | 81 decision.learn_more = has_viewed_learn_more(); |
| 80 decision.details = has_viewed_details(); | 82 decision.details = has_viewed_details(); |
| 81 decision.time = base::Time::Now().ToJsTime(); | 83 decision.time = base::Time::Now().ToJsTime(); |
| 82 | 84 |
| 83 scoped_ptr<base::ListValue> args(new base::ListValue()); | 85 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 84 args->Append(ui_element_.ToValue().release()); | 86 args->Append(ui_element_.ToValue().release()); |
| 85 args->Append(decision.ToValue().release()); | 87 args->Append(decision.ToValue().release()); |
| 86 scoped_ptr<Event> event(new Event( | 88 scoped_ptr<Event> event( |
| 87 events::EXPERIENCE_SAMPLING_PRIVATE_ON_DECISION, | 89 new Event(events::EXPERIENCE_SAMPLING_PRIVATE_ON_DECISION, |
| 88 api::experience_sampling_private::OnDecision::kEventName, args.Pass())); | 90 api::experience_sampling_private::OnDecision::kEventName, |
| 91 std::move(args))); |
| 89 EventRouter* router = EventRouter::Get(browser_context_); | 92 EventRouter* router = EventRouter::Get(browser_context_); |
| 90 if (router) | 93 if (router) |
| 91 router->BroadcastEvent(event.Pass()); | 94 router->BroadcastEvent(std::move(event)); |
| 92 } | 95 } |
| 93 | 96 |
| 94 void ExperienceSamplingEvent::CreateOnDisplayedEvent() { | 97 void ExperienceSamplingEvent::CreateOnDisplayedEvent() { |
| 95 // 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 |
| 96 // any events. | 99 // any events. |
| 97 if (browser_context_ && browser_context_->IsOffTheRecord()) | 100 if (browser_context_ && browser_context_->IsOffTheRecord()) |
| 98 return; | 101 return; |
| 99 scoped_ptr<base::ListValue> args(new base::ListValue()); | 102 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 100 args->Append(ui_element_.ToValue().release()); | 103 args->Append(ui_element_.ToValue().release()); |
| 101 scoped_ptr<Event> event(new Event( | 104 scoped_ptr<Event> event( |
| 102 events::EXPERIENCE_SAMPLING_PRIVATE_ON_DISPLAYED, | 105 new Event(events::EXPERIENCE_SAMPLING_PRIVATE_ON_DISPLAYED, |
| 103 api::experience_sampling_private::OnDisplayed::kEventName, args.Pass())); | 106 api::experience_sampling_private::OnDisplayed::kEventName, |
| 107 std::move(args))); |
| 104 EventRouter* router = EventRouter::Get(browser_context_); | 108 EventRouter* router = EventRouter::Get(browser_context_); |
| 105 if (router) | 109 if (router) |
| 106 router->BroadcastEvent(event.Pass()); | 110 router->BroadcastEvent(std::move(event)); |
| 107 } | 111 } |
| 108 | 112 |
| 109 } // namespace extensions | 113 } // namespace extensions |
| OLD | NEW |