Chromium Code Reviews| 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" |
| 11 #include "chrome/common/extensions/api/experience_sampling_private.h" | 11 #include "chrome/common/extensions/api/experience_sampling_private.h" |
| 12 #include "extensions/browser/event_router.h" | 12 #include "extensions/browser/event_router.h" |
| 13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
| 14 | 14 |
| 15 namespace extensions { | 15 namespace extensions { |
| 16 | 16 |
| 17 // String constants for SamplingEvent. | 17 // String constants for user decision events. |
|
msw
2014/08/14 01:48:33
nit: Move these comments to the header with the de
Chris Thompson
2014/08/14 15:43:44
Done.
| |
| 18 const char ExperienceSamplingEvent::kProceed[] = "proceed"; | 18 const char ExperienceSamplingEvent::kProceed[] = "proceed"; |
| 19 const char ExperienceSamplingEvent::kDeny[] = "deny"; | 19 const char ExperienceSamplingEvent::kDeny[] = "deny"; |
| 20 const char ExperienceSamplingEvent::kIgnore[] = "ignore"; | |
| 20 const char ExperienceSamplingEvent::kCancel[] = "cancel"; | 21 const char ExperienceSamplingEvent::kCancel[] = "cancel"; |
| 21 const char ExperienceSamplingEvent::kReload[] = "reload"; | 22 const char ExperienceSamplingEvent::kReload[] = "reload"; |
| 22 | 23 |
| 24 // String constants for event names. | |
| 25 const char ExperienceSamplingEvent::kEventNameMaliciousDownload[] = | |
| 26 "download_warning_malicious"; | |
| 27 const char ExperienceSamplingEvent::kEventNameDangerousDownload[] = | |
| 28 "download_warning_dangerous"; | |
| 29 | |
| 23 // static | 30 // static |
| 24 scoped_ptr<ExperienceSamplingEvent> ExperienceSamplingEvent::Create( | 31 scoped_ptr<ExperienceSamplingEvent> ExperienceSamplingEvent::Create( |
| 25 const std::string& element_name, | 32 const std::string& element_name, |
| 26 const GURL& destination, | 33 const GURL& destination, |
| 27 const GURL& referrer) { | 34 const GURL& referrer) { |
| 28 Profile* profile = NULL; | 35 Profile* profile = NULL; |
| 29 if (g_browser_process->profile_manager()) | 36 if (g_browser_process->profile_manager()) |
| 30 profile = g_browser_process->profile_manager()->GetLastUsedProfile(); | 37 profile = g_browser_process->profile_manager()->GetLastUsedProfile(); |
| 31 if (!profile) | 38 if (!profile) |
| 32 return scoped_ptr<ExperienceSamplingEvent>(); | 39 return scoped_ptr<ExperienceSamplingEvent>(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 scoped_ptr<base::ListValue> args(new base::ListValue()); | 94 scoped_ptr<base::ListValue> args(new base::ListValue()); |
| 88 args->Append(ui_element_.ToValue().release()); | 95 args->Append(ui_element_.ToValue().release()); |
| 89 scoped_ptr<Event> event(new Event( | 96 scoped_ptr<Event> event(new Event( |
| 90 api::experience_sampling_private::OnDisplayed::kEventName, args.Pass())); | 97 api::experience_sampling_private::OnDisplayed::kEventName, args.Pass())); |
| 91 EventRouter* router = EventRouter::Get(browser_context_); | 98 EventRouter* router = EventRouter::Get(browser_context_); |
| 92 if (router) | 99 if (router) |
| 93 router->BroadcastEvent(event.Pass()); | 100 router->BroadcastEvent(event.Pass()); |
| 94 } | 101 } |
| 95 | 102 |
| 96 } // namespace extensions | 103 } // namespace extensions |
| OLD | NEW |