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

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

Issue 402293002: Experience sampling instrumentation for dangerous downloads warnings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sampling-api
Patch Set: Updating string constants in Cocoa too 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
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"
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 // static
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
23 // static 24 // static
25 const char ExperienceSamplingEvent::kMaliciousDownload[] =
26 "download_warning_malicious";
27 const char ExperienceSamplingEvent::kDangerousDownload[] =
28 "download_warning_dangerous";
29 const char ExperienceSamplingEvent::kDownloadDangerPrompt[] =
30 "download_danger_prompt";
31
32 // static
24 scoped_ptr<ExperienceSamplingEvent> ExperienceSamplingEvent::Create( 33 scoped_ptr<ExperienceSamplingEvent> ExperienceSamplingEvent::Create(
25 const std::string& element_name, 34 const std::string& element_name,
26 const GURL& destination, 35 const GURL& destination,
27 const GURL& referrer) { 36 const GURL& referrer) {
28 Profile* profile = NULL; 37 Profile* profile = NULL;
29 if (g_browser_process->profile_manager()) 38 if (g_browser_process->profile_manager())
30 profile = g_browser_process->profile_manager()->GetLastUsedProfile(); 39 profile = g_browser_process->profile_manager()->GetLastUsedProfile();
31 if (!profile) 40 if (!profile)
32 return scoped_ptr<ExperienceSamplingEvent>(); 41 return scoped_ptr<ExperienceSamplingEvent>();
33 return scoped_ptr<ExperienceSamplingEvent>(new ExperienceSamplingEvent( 42 return scoped_ptr<ExperienceSamplingEvent>(new ExperienceSamplingEvent(
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 scoped_ptr<base::ListValue> args(new base::ListValue()); 96 scoped_ptr<base::ListValue> args(new base::ListValue());
88 args->Append(ui_element_.ToValue().release()); 97 args->Append(ui_element_.ToValue().release());
89 scoped_ptr<Event> event(new Event( 98 scoped_ptr<Event> event(new Event(
90 api::experience_sampling_private::OnDisplayed::kEventName, args.Pass())); 99 api::experience_sampling_private::OnDisplayed::kEventName, args.Pass()));
91 EventRouter* router = EventRouter::Get(browser_context_); 100 EventRouter* router = EventRouter::Get(browser_context_);
92 if (router) 101 if (router)
93 router->BroadcastEvent(event.Pass()); 102 router->BroadcastEvent(event.Pass());
94 } 103 }
95 104
96 } // namespace extensions 105 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698