Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / plugins / plugin_info_message_filter.cc
index 50bbc75..d5b4ab3 100644 (file)
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/browser/content_settings/content_settings_utils.h"
 #include "chrome/browser/content_settings/host_content_settings_map.h"
-#include "chrome/browser/extensions/extension_renderer_state.h"
 #include "chrome/browser/plugins/chrome_plugin_service_filter.h"
 #include "chrome/browser/plugins/plugin_finder.h"
 #include "chrome/browser/plugins/plugin_metadata.h"
 #include "chrome/browser/plugins/plugin_prefs.h"
 #include "chrome/browser/profiles/profile.h"
-#include "chrome/common/chrome_content_client.h"
-#include "chrome/common/content_settings.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/render_messages.h"
+#include "components/content_settings/core/common/content_settings.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/plugin_service.h"
 #include "content/public/browser/plugin_service_filter.h"
 
 #include "widevine_cdm_version.h"  // In SHARED_INTERMEDIATE_DIR.
 
+#if defined(ENABLE_EXTENSIONS)
+#include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
+#endif
+
 #if defined(OS_WIN)
 #include "base/win/metro.h"
 #endif
 
+#if !defined(DISABLE_NACL)
+#include "components/nacl/common/nacl_constants.h"
+#endif
+
 using content::PluginService;
 using content::WebPluginInfo;
 
@@ -44,9 +50,11 @@ bool ShouldUseJavaScriptSettingForPlugin(const WebPluginInfo& plugin) {
     return false;
   }
 
+#if !defined(DISABLE_NACL)
   // Treat Native Client invocations like JavaScript.
-  if (plugin.name == base::ASCIIToUTF16(ChromeContentClient::kNaClPluginName))
+  if (plugin.name == base::ASCIIToUTF16(nacl::kNaClPluginName))
     return true;
+#endif
 
 #if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
   // Treat CDM invocations like JavaScript.
@@ -190,6 +198,7 @@ void PluginInfoMessageFilter::PluginsLoaded(
 }
 
 #if defined(ENABLE_PEPPER_CDMS)
+
 void PluginInfoMessageFilter::OnIsInternalPluginAvailableForMimeType(
     const std::string& mime_type,
     bool* is_available,
@@ -242,12 +251,14 @@ void PluginInfoMessageFilter::Context::DecidePluginStatus(
   if (plugin.type == WebPluginInfo::PLUGIN_TYPE_NPAPI) {
     CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
     // NPAPI plugins are not supported inside <webview> guests.
-    if (ExtensionRendererState::GetInstance()->IsWebViewRenderer(
-            render_process_id_)) {
+#if defined(ENABLE_EXTENSIONS)
+    if (extensions::WebViewRendererState::GetInstance()->IsGuest(
+        render_process_id_)) {
       status->value =
           ChromeViewHostMsg_GetPluginInfo_Status::kNPAPINotSupported;
       return;
     }
+#endif
   }
 
   ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT;
@@ -319,10 +330,12 @@ void PluginInfoMessageFilter::Context::DecidePluginStatus(
     // the guest. In order to do this, set the status to 'Unauthorized' here,
     // and update the status as appropriate depending on the response from the
     // embedder.
-    if (ExtensionRendererState::GetInstance()->IsWebViewRenderer(
-            render_process_id_)) {
+#if defined(ENABLE_EXTENSIONS)
+    if (extensions::WebViewRendererState::GetInstance()->IsGuest(
+        render_process_id_))
       status->value = ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized;
-    }
+
+#endif
   }
 }
 
@@ -387,21 +400,29 @@ void PluginInfoMessageFilter::Context::GetPluginContentSetting(
   content_settings::SettingInfo info;
   bool uses_plugin_specific_setting = false;
   if (ShouldUseJavaScriptSettingForPlugin(plugin)) {
-    value.reset(
-        host_content_settings_map_->GetWebsiteSetting(
-            policy_url, policy_url, CONTENT_SETTINGS_TYPE_JAVASCRIPT,
-            std::string(), &info));
+    value = host_content_settings_map_->GetWebsiteSetting(
+        policy_url,
+        policy_url,
+        CONTENT_SETTINGS_TYPE_JAVASCRIPT,
+        std::string(),
+        &info);
   } else {
     content_settings::SettingInfo specific_info;
-    scoped_ptr<base::Value> specific_setting(
+    scoped_ptr<base::Value> specific_setting =
         host_content_settings_map_->GetWebsiteSetting(
-            policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS, resource,
-            &specific_info));
+            policy_url,
+            plugin_url,
+            CONTENT_SETTINGS_TYPE_PLUGINS,
+            resource,
+            &specific_info);
     content_settings::SettingInfo general_info;
-    scoped_ptr<base::Value> general_setting(
+    scoped_ptr<base::Value> general_setting =
         host_content_settings_map_->GetWebsiteSetting(
-            policy_url, plugin_url, CONTENT_SETTINGS_TYPE_PLUGINS,
-            std::string(), &general_info));
+            policy_url,
+            plugin_url,
+            CONTENT_SETTINGS_TYPE_PLUGINS,
+            std::string(),
+            &general_info);
 
     // If there is a plugin-specific setting, we use it, unless the general
     // setting was set by policy, in which case it takes precedence.