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

Side by Side Diff: chrome/renderer/pepper/pepper_uma_host.cc

Issue 281853003: Whitelist libwidevinecdmadapter.so for pepper UMA reporting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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/renderer/pepper/pepper_uma_host.h" 5 #include "chrome/renderer/pepper/pepper_uma_host.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/sha1.h" 8 #include "base/sha1.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/render_messages.h" 11 #include "chrome/common/render_messages.h"
12 #include "chrome/renderer/chrome_content_renderer_client.h" 12 #include "chrome/renderer/chrome_content_renderer_client.h"
13 #include "content/public/renderer/pepper_plugin_instance.h"
13 #include "content/public/renderer/render_thread.h" 14 #include "content/public/renderer/render_thread.h"
14 #include "content/public/renderer/renderer_ppapi_host.h" 15 #include "content/public/renderer/renderer_ppapi_host.h"
15 #include "extensions/common/constants.h" 16 #include "extensions/common/constants.h"
16 #include "extensions/common/extension.h" 17 #include "extensions/common/extension.h"
17 #include "ppapi/c/pp_errors.h" 18 #include "ppapi/c/pp_errors.h"
18 #include "ppapi/host/dispatch_host_message.h" 19 #include "ppapi/host/dispatch_host_message.h"
19 #include "ppapi/host/host_message_context.h" 20 #include "ppapi/host/host_message_context.h"
20 #include "ppapi/host/ppapi_host.h" 21 #include "ppapi/host/ppapi_host.h"
21 #include "ppapi/proxy/ppapi_messages.h" 22 #include "ppapi/proxy/ppapi_messages.h"
22 23
23 namespace { 24 namespace {
24 25
25 const char* const kPredefinedAllowedUMAOrigins[] = { 26 const char* const kPredefinedAllowedUMAOrigins[] = {
26 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see http://crbug.com/317833 27 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see http://crbug.com/317833
27 "4EB74897CB187C7633357C2FE832E0AD6A44883A" // see http://crbug.com/317833 28 "4EB74897CB187C7633357C2FE832E0AD6A44883A" // see http://crbug.com/317833
28 }; 29 };
29 30
30 const char* const kWhitelistedHistogramPrefixes[] = { 31 const char* const kWhitelistedHistogramPrefixes[] = {
31 "CD190EA2B764EDF0BB97552A638D32072F3CFD41", // see http://crbug.com/317833 32 "CD190EA2B764EDF0BB97552A638D32072F3CFD41", // see http://crbug.com/317833
32 }; 33 };
33 34
35 const char* const kWhitelistedPluginFileNames[] = {
36 "libwidevinecdmadapter.so", // see http://crbug.com/368743
ddorwin 2014/05/14 02:41:54 Could/should we just add a histogram prefix?
elijahtaylor1 2014/05/14 17:17:21 I'm assuming this is chromeos only or something?
xhwang 2014/05/14 17:41:28 This is the name on linux and cros, and I only car
ddorwin 2014/05/14 19:41:19 Should we ifdef it to make this clear? Other platf
xhwang 2014/05/14 19:56:32 Yeah, arraysize doesn't work with empty array. I'l
37 };
38
34 std::string HashPrefix(const std::string& histogram) { 39 std::string HashPrefix(const std::string& histogram) {
35 const std::string id_hash = 40 const std::string id_hash =
36 base::SHA1HashString(histogram.substr(0, histogram.find('.'))); 41 base::SHA1HashString(histogram.substr(0, histogram.find('.')));
37 DCHECK_EQ(id_hash.length(), base::kSHA1Length); 42 DCHECK_EQ(id_hash.length(), base::kSHA1Length);
38 return base::HexEncode(id_hash.c_str(), id_hash.length()); 43 return base::HexEncode(id_hash.c_str(), id_hash.length());
39 } 44 }
40 45
41 } // namespace 46 } // namespace
42 47
43 PepperUMAHost::PepperUMAHost(content::RendererPpapiHost* host, 48 PepperUMAHost::PepperUMAHost(content::RendererPpapiHost* host,
44 PP_Instance instance, 49 PP_Instance instance,
45 PP_Resource resource) 50 PP_Resource resource)
46 : ResourceHost(host->GetPpapiHost(), instance, resource), 51 : ResourceHost(host->GetPpapiHost(), instance, resource),
47 document_url_(host->GetDocumentURL(instance)), 52 document_url_(host->GetDocumentURL(instance)),
48 is_plugin_in_process_(host->IsRunningInProcess()) { 53 is_plugin_in_process_(host->IsRunningInProcess()) {
54 if (host->GetPluginInstance(instance)) {
55 plugin_file_name_ =
56 host->GetPluginInstance(instance)->GetModulePath().BaseName();
57 }
58
49 for (size_t i = 0; i < arraysize(kPredefinedAllowedUMAOrigins); ++i) 59 for (size_t i = 0; i < arraysize(kPredefinedAllowedUMAOrigins); ++i)
50 allowed_origins_.insert(kPredefinedAllowedUMAOrigins[i]); 60 allowed_origins_.insert(kPredefinedAllowedUMAOrigins[i]);
51 for (size_t i = 0; i < arraysize(kWhitelistedHistogramPrefixes); ++i) 61 for (size_t i = 0; i < arraysize(kWhitelistedHistogramPrefixes); ++i)
52 allowed_histogram_prefixes_.insert(kWhitelistedHistogramPrefixes[i]); 62 allowed_histogram_prefixes_.insert(kWhitelistedHistogramPrefixes[i]);
63 for (size_t i = 0; i < arraysize(kWhitelistedPluginFileNames); ++i)
64 allowed_plugin_file_names_.insert(kWhitelistedPluginFileNames[i]);
53 } 65 }
54 66
55 PepperUMAHost::~PepperUMAHost() {} 67 PepperUMAHost::~PepperUMAHost() {}
56 68
57 int32_t PepperUMAHost::OnResourceMessageReceived( 69 int32_t PepperUMAHost::OnResourceMessageReceived(
58 const IPC::Message& msg, 70 const IPC::Message& msg,
59 ppapi::host::HostMessageContext* context) { 71 ppapi::host::HostMessageContext* context) {
60 IPC_BEGIN_MESSAGE_MAP(PepperUMAHost, msg) 72 IPC_BEGIN_MESSAGE_MAP(PepperUMAHost, msg)
61 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UMA_HistogramCustomTimes, 73 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UMA_HistogramCustomTimes,
62 OnHistogramCustomTimes); 74 OnHistogramCustomTimes);
(...skipping 16 matching lines...) Expand all
79 if (is_plugin_in_process_ && histogram.find("NaCl.") == 0) { 91 if (is_plugin_in_process_ && histogram.find("NaCl.") == 0) {
80 return true; 92 return true;
81 } 93 }
82 94
83 if (IsPluginWhitelisted() && 95 if (IsPluginWhitelisted() &&
84 allowed_histogram_prefixes_.find(HashPrefix(histogram)) != 96 allowed_histogram_prefixes_.find(HashPrefix(histogram)) !=
85 allowed_histogram_prefixes_.end()) { 97 allowed_histogram_prefixes_.end()) {
86 return true; 98 return true;
87 } 99 }
88 100
101 if (allowed_plugin_file_names_.find(plugin_file_name_.MaybeAsASCII()) !=
102 allowed_plugin_file_names_.end()) {
103 return true;
104 }
105
89 LOG(ERROR) << "Host or histogram name is not allowed to use the UMA API."; 106 LOG(ERROR) << "Host or histogram name is not allowed to use the UMA API.";
90 return false; 107 return false;
91 } 108 }
92 109
93 #define RETURN_IF_BAD_ARGS(_min, _max, _buckets) \ 110 #define RETURN_IF_BAD_ARGS(_min, _max, _buckets) \
94 do { \ 111 do { \
95 if (_min >= _max || _buckets <= 1) \ 112 if (_min >= _max || _buckets <= 1) \
96 return PP_ERROR_BADARGUMENT; \ 113 return PP_ERROR_BADARGUMENT; \
97 } while (0) 114 } while (0)
98 115
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 ppapi::host::HostMessageContext* context) { 190 ppapi::host::HostMessageContext* context) {
174 if (!IsPluginWhitelisted()) 191 if (!IsPluginWhitelisted())
175 return PP_ERROR_NOACCESS; 192 return PP_ERROR_NOACCESS;
176 bool enabled = false; 193 bool enabled = false;
177 content::RenderThread::Get()->Send( 194 content::RenderThread::Get()->Send(
178 new ChromeViewHostMsg_IsCrashReportingEnabled(&enabled)); 195 new ChromeViewHostMsg_IsCrashReportingEnabled(&enabled));
179 if (enabled) 196 if (enabled)
180 return PP_OK; 197 return PP_OK;
181 return PP_ERROR_FAILED; 198 return PP_ERROR_FAILED;
182 } 199 }
OLDNEW
« chrome/renderer/pepper/pepper_uma_host.h ('K') | « chrome/renderer/pepper/pepper_uma_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698