| 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/renderer/pepper/pepper_uma_host.h" |    5 #include "chrome/renderer/pepper/pepper_uma_host.h" | 
|    6  |    6  | 
|    7 #include <stddef.h> |    7 #include <stddef.h> | 
|    8  |    8  | 
|    9 #include "base/macros.h" |    9 #include "base/macros.h" | 
|   10 #include "base/metrics/histogram.h" |   10 #include "base/metrics/histogram.h" | 
|   11 #include "base/sha1.h" |   11 #include "base/sha1.h" | 
|   12 #include "base/strings/string_number_conversions.h" |   12 #include "base/strings/string_number_conversions.h" | 
 |   13 #include "base/strings/string_util.h" | 
|   13 #include "chrome/common/chrome_content_client.h" |   14 #include "chrome/common/chrome_content_client.h" | 
|   14 #include "chrome/common/chrome_switches.h" |   15 #include "chrome/common/chrome_switches.h" | 
|   15 #include "chrome/common/render_messages.h" |   16 #include "chrome/common/render_messages.h" | 
|   16 #include "chrome/renderer/chrome_content_renderer_client.h" |   17 #include "chrome/renderer/chrome_content_renderer_client.h" | 
|   17 #include "content/public/renderer/pepper_plugin_instance.h" |   18 #include "content/public/renderer/pepper_plugin_instance.h" | 
|   18 #include "content/public/renderer/render_thread.h" |   19 #include "content/public/renderer/render_thread.h" | 
|   19 #include "content/public/renderer/renderer_ppapi_host.h" |   20 #include "content/public/renderer/renderer_ppapi_host.h" | 
|   20 #include "ppapi/c/pp_errors.h" |   21 #include "ppapi/c/pp_errors.h" | 
|   21 #include "ppapi/host/dispatch_host_message.h" |   22 #include "ppapi/host/dispatch_host_message.h" | 
|   22 #include "ppapi/host/host_message_context.h" |   23 #include "ppapi/host/host_message_context.h" | 
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  106 bool PepperUMAHost::IsPluginWhitelisted() { |  107 bool PepperUMAHost::IsPluginWhitelisted() { | 
|  107 #if defined(ENABLE_EXTENSIONS) |  108 #if defined(ENABLE_EXTENSIONS) | 
|  108   return ChromeContentRendererClient::IsExtensionOrSharedModuleWhitelisted( |  109   return ChromeContentRendererClient::IsExtensionOrSharedModuleWhitelisted( | 
|  109       document_url_, allowed_origins_); |  110       document_url_, allowed_origins_); | 
|  110 #else |  111 #else | 
|  111   return false; |  112   return false; | 
|  112 #endif |  113 #endif | 
|  113 } |  114 } | 
|  114  |  115  | 
|  115 bool PepperUMAHost::IsHistogramAllowed(const std::string& histogram) { |  116 bool PepperUMAHost::IsHistogramAllowed(const std::string& histogram) { | 
|  116   if (is_plugin_in_process_ && histogram.find("NaCl.") == 0) { |  117   if (is_plugin_in_process_ && | 
 |  118       base::StartsWith(histogram, "NaCl.", base::CompareCase::SENSITIVE)) { | 
|  117     return true; |  119     return true; | 
|  118   } |  120   } | 
|  119  |  121  | 
|  120   if (IsPluginWhitelisted() && |  122   if (IsPluginWhitelisted() && | 
|  121       ContainsKey(allowed_histogram_prefixes_, HashPrefix(histogram))) { |  123       ContainsKey(allowed_histogram_prefixes_, HashPrefix(histogram))) { | 
|  122     return true; |  124     return true; | 
|  123   } |  125   } | 
|  124  |  126  | 
|  125   if (ContainsKey(allowed_plugin_base_names_, |  127   if (ContainsKey(allowed_plugin_base_names_, | 
|  126                   plugin_base_name_.MaybeAsASCII())) { |  128                   plugin_base_name_.MaybeAsASCII())) { | 
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  214     ppapi::host::HostMessageContext* context) { |  216     ppapi::host::HostMessageContext* context) { | 
|  215   if (!IsPluginWhitelisted()) |  217   if (!IsPluginWhitelisted()) | 
|  216     return PP_ERROR_NOACCESS; |  218     return PP_ERROR_NOACCESS; | 
|  217   bool enabled = false; |  219   bool enabled = false; | 
|  218   content::RenderThread::Get()->Send( |  220   content::RenderThread::Get()->Send( | 
|  219       new ChromeViewHostMsg_IsCrashReportingEnabled(&enabled)); |  221       new ChromeViewHostMsg_IsCrashReportingEnabled(&enabled)); | 
|  220   if (enabled) |  222   if (enabled) | 
|  221     return PP_OK; |  223     return PP_OK; | 
|  222   return PP_ERROR_FAILED; |  224   return PP_ERROR_FAILED; | 
|  223 } |  225 } | 
| OLD | NEW |