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

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

Issue 567913002: Whitelist Widevine CDM for plugin UMA on all platforms. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « chrome/renderer/pepper/pepper_uma_host.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/strings/string_util.h"
10 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/render_messages.h" 12 #include "chrome/common/render_messages.h"
12 #include "chrome/renderer/chrome_content_renderer_client.h" 13 #include "chrome/renderer/chrome_content_renderer_client.h"
13 #include "content/public/renderer/pepper_plugin_instance.h" 14 #include "content/public/renderer/pepper_plugin_instance.h"
14 #include "content/public/renderer/render_thread.h" 15 #include "content/public/renderer/render_thread.h"
15 #include "content/public/renderer/renderer_ppapi_host.h" 16 #include "content/public/renderer/renderer_ppapi_host.h"
16 #include "extensions/common/constants.h" 17 #include "extensions/common/constants.h"
17 #include "extensions/common/extension.h" 18 #include "extensions/common/extension.h"
18 #include "ppapi/c/pp_errors.h" 19 #include "ppapi/c/pp_errors.h"
19 #include "ppapi/host/dispatch_host_message.h" 20 #include "ppapi/host/dispatch_host_message.h"
20 #include "ppapi/host/host_message_context.h" 21 #include "ppapi/host/host_message_context.h"
21 #include "ppapi/host/ppapi_host.h" 22 #include "ppapi/host/ppapi_host.h"
22 #include "ppapi/proxy/ppapi_messages.h" 23 #include "ppapi/proxy/ppapi_messages.h"
23 24
24 namespace { 25 namespace {
25 26
26 const char* const kPredefinedAllowedUMAOrigins[] = { 27 const char* const kPredefinedAllowedUMAOrigins[] = {
27 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see http://crbug.com/317833 28 "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see http://crbug.com/317833
28 "4EB74897CB187C7633357C2FE832E0AD6A44883A" // see http://crbug.com/317833 29 "4EB74897CB187C7633357C2FE832E0AD6A44883A" // see http://crbug.com/317833
29 }; 30 };
30 31
31 const char* const kWhitelistedHistogramPrefixes[] = { 32 const char* const kWhitelistedHistogramPrefixes[] = {
32 "22F67DA2061FFC4DC9A4974036348D9C38C22919" // see http://crbug.com/390221 33 "22F67DA2061FFC4DC9A4974036348D9C38C22919" // see http://crbug.com/390221
33 }; 34 };
34 35
35 const char* const kWhitelistedPluginBaseNames[] = { 36 // Name patterns in this list should be as specific as possible to avoid
36 "libwidevinecdmadapter.so", // see http://crbug.com/368743 37 // over-whitelisting unexpected plugins.
37 "libpdf.so" // see http://crbug.com/405305 38 const char* const kWhitelistedPluginNamePatterns[] = {
39 "*widevinecdmadapter.*", // see http://crbug.com/368743 and
ddorwin 2014/09/12 16:11:08 How good is the pattern matching? Can we do someth
xhwang 2014/09/12 16:33:58 No, it only supports * and ?. Probably I can find
40 // http://crbug.com/410630
41 "libpdf.so" // see http://crbug.com/405305
38 }; 42 };
39 43
40 std::string HashPrefix(const std::string& histogram) { 44 std::string HashPrefix(const std::string& histogram) {
41 const std::string id_hash = 45 const std::string id_hash =
42 base::SHA1HashString(histogram.substr(0, histogram.find('.'))); 46 base::SHA1HashString(histogram.substr(0, histogram.find('.')));
43 DCHECK_EQ(id_hash.length(), base::kSHA1Length); 47 DCHECK_EQ(id_hash.length(), base::kSHA1Length);
44 return base::HexEncode(id_hash.c_str(), id_hash.length()); 48 return base::HexEncode(id_hash.c_str(), id_hash.length());
45 } 49 }
46 50
47 } // namespace 51 } // namespace
48 52
49 PepperUMAHost::PepperUMAHost(content::RendererPpapiHost* host, 53 PepperUMAHost::PepperUMAHost(content::RendererPpapiHost* host,
50 PP_Instance instance, 54 PP_Instance instance,
51 PP_Resource resource) 55 PP_Resource resource)
52 : ResourceHost(host->GetPpapiHost(), instance, resource), 56 : ResourceHost(host->GetPpapiHost(), instance, resource),
53 document_url_(host->GetDocumentURL(instance)), 57 document_url_(host->GetDocumentURL(instance)),
54 is_plugin_in_process_(host->IsRunningInProcess()) { 58 is_plugin_in_process_(host->IsRunningInProcess()) {
55 if (host->GetPluginInstance(instance)) { 59 if (host->GetPluginInstance(instance)) {
56 plugin_base_name_ = 60 plugin_base_name_ =
57 host->GetPluginInstance(instance)->GetModulePath().BaseName(); 61 host->GetPluginInstance(instance)->GetModulePath().BaseName();
58 } 62 }
59 63
60 for (size_t i = 0; i < arraysize(kPredefinedAllowedUMAOrigins); ++i) 64 for (size_t i = 0; i < arraysize(kPredefinedAllowedUMAOrigins); ++i)
61 allowed_origins_.insert(kPredefinedAllowedUMAOrigins[i]); 65 allowed_origins_.insert(kPredefinedAllowedUMAOrigins[i]);
62 for (size_t i = 0; i < arraysize(kWhitelistedHistogramPrefixes); ++i) 66 for (size_t i = 0; i < arraysize(kWhitelistedHistogramPrefixes); ++i)
63 allowed_histogram_prefixes_.insert(kWhitelistedHistogramPrefixes[i]); 67 allowed_histogram_prefixes_.insert(kWhitelistedHistogramPrefixes[i]);
64 for (size_t i = 0; i < arraysize(kWhitelistedPluginBaseNames); ++i) 68 for (size_t i = 0; i < arraysize(kWhitelistedPluginNamePatterns); ++i)
65 allowed_plugin_base_names_.insert(kWhitelistedPluginBaseNames[i]); 69 allowed_plugin_name_patterns_.insert(kWhitelistedPluginNamePatterns[i]);
66 } 70 }
67 71
68 PepperUMAHost::~PepperUMAHost() {} 72 PepperUMAHost::~PepperUMAHost() {}
69 73
70 int32_t PepperUMAHost::OnResourceMessageReceived( 74 int32_t PepperUMAHost::OnResourceMessageReceived(
71 const IPC::Message& msg, 75 const IPC::Message& msg,
72 ppapi::host::HostMessageContext* context) { 76 ppapi::host::HostMessageContext* context) {
73 PPAPI_BEGIN_MESSAGE_MAP(PepperUMAHost, msg) 77 PPAPI_BEGIN_MESSAGE_MAP(PepperUMAHost, msg)
74 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UMA_HistogramCustomTimes, 78 PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UMA_HistogramCustomTimes,
75 OnHistogramCustomTimes) 79 OnHistogramCustomTimes)
(...skipping 16 matching lines...) Expand all
92 if (is_plugin_in_process_ && histogram.find("NaCl.") == 0) { 96 if (is_plugin_in_process_ && histogram.find("NaCl.") == 0) {
93 return true; 97 return true;
94 } 98 }
95 99
96 if (IsPluginWhitelisted() && 100 if (IsPluginWhitelisted() &&
97 allowed_histogram_prefixes_.find(HashPrefix(histogram)) != 101 allowed_histogram_prefixes_.find(HashPrefix(histogram)) !=
98 allowed_histogram_prefixes_.end()) { 102 allowed_histogram_prefixes_.end()) {
99 return true; 103 return true;
100 } 104 }
101 105
102 if (allowed_plugin_base_names_.find(plugin_base_name_.MaybeAsASCII()) != 106 std::string plugin_base_name_string = plugin_base_name_.MaybeAsASCII();
103 allowed_plugin_base_names_.end()) { 107 std::set<std::string>::const_iterator iter =
ddorwin 2014/09/12 16:11:08 Why is this outside the for loop?
xhwang 2014/09/12 16:33:57 I hated the long line... will fix :) ~~
104 return true; 108 allowed_plugin_name_patterns_.begin();
109 for (; iter != allowed_plugin_name_patterns_.end(); ++iter) {
110 if (MatchPattern(plugin_base_name_string, *iter))
111 return true;
105 } 112 }
106 113
107 LOG(ERROR) << "Host or histogram name is not allowed to use the UMA API."; 114 LOG(ERROR) << "Host or histogram name is not allowed to use the UMA API.";
108 return false; 115 return false;
109 } 116 }
110 117
111 #define RETURN_IF_BAD_ARGS(_min, _max, _buckets) \ 118 #define RETURN_IF_BAD_ARGS(_min, _max, _buckets) \
112 do { \ 119 do { \
113 if (_min >= _max || _buckets <= 1) \ 120 if (_min >= _max || _buckets <= 1) \
114 return PP_ERROR_BADARGUMENT; \ 121 return PP_ERROR_BADARGUMENT; \
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 ppapi::host::HostMessageContext* context) { 198 ppapi::host::HostMessageContext* context) {
192 if (!IsPluginWhitelisted()) 199 if (!IsPluginWhitelisted())
193 return PP_ERROR_NOACCESS; 200 return PP_ERROR_NOACCESS;
194 bool enabled = false; 201 bool enabled = false;
195 content::RenderThread::Get()->Send( 202 content::RenderThread::Get()->Send(
196 new ChromeViewHostMsg_IsCrashReportingEnabled(&enabled)); 203 new ChromeViewHostMsg_IsCrashReportingEnabled(&enabled));
197 if (enabled) 204 if (enabled)
198 return PP_OK; 205 return PP_OK;
199 return PP_ERROR_FAILED; 206 return PP_ERROR_FAILED;
200 } 207 }
OLDNEW
« no previous file with comments | « 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