| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/pepper_broker_infobar_delegate.h" | 5 #include "chrome/browser/pepper_broker_infobar_delegate.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/content_settings/host_content_settings_map.h" | 8 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 10 #include "chrome/browser/infobars/infobar.h" | 10 #include "chrome/browser/infobars/infobar.h" |
| 11 #include "chrome/browser/infobars/infobar_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
| 12 #include "chrome/browser/plugins/plugin_finder.h" | 12 #include "chrome/browser/plugins/plugin_finder.h" |
| 13 #include "chrome/browser/plugins/plugin_metadata.h" | 13 #include "chrome/browser/plugins/plugin_metadata.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 16 #include "content/public/browser/page_navigator.h" | 16 #include "content/public/browser/page_navigator.h" |
| 17 #include "content/public/browser/plugin_service.h" | 17 #include "content/public/browser/plugin_service.h" |
| 18 #include "content/public/browser/user_metrics.h" | 18 #include "content/public/browser/user_metrics.h" |
| 19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/common/referrer.h" | 20 #include "content/public/common/referrer.h" |
| 21 #include "content/public/common/webplugininfo.h" | 21 #include "content/public/common/webplugininfo.h" |
| 22 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 23 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
| 24 #include "net/base/net_util.h" | 24 #include "net/base/net_util.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 26 | 26 |
| 27 #if defined(GOOGLE_TV) | |
| 28 #include "base/android/context_types.h" | |
| 29 #endif | |
| 30 | |
| 31 | 27 |
| 32 // static | 28 // static |
| 33 void PepperBrokerInfoBarDelegate::Create( | 29 void PepperBrokerInfoBarDelegate::Create( |
| 34 content::WebContents* web_contents, | 30 content::WebContents* web_contents, |
| 35 const GURL& url, | 31 const GURL& url, |
| 36 const base::FilePath& plugin_path, | 32 const base::FilePath& plugin_path, |
| 37 const base::Callback<void(bool)>& callback) { | 33 const base::Callback<void(bool)>& callback) { |
| 38 Profile* profile = | 34 Profile* profile = |
| 39 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 35 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 40 // TODO(wad): Add ephemeral device ID support for broker in guest mode. | 36 // TODO(wad): Add ephemeral device ID support for broker in guest mode. |
| 41 if (profile->IsGuestSession()) { | 37 if (profile->IsGuestSession()) { |
| 42 callback.Run(false); | 38 callback.Run(false); |
| 43 return; | 39 return; |
| 44 } | 40 } |
| 45 | 41 |
| 46 TabSpecificContentSettings* tab_content_settings = | 42 TabSpecificContentSettings* tab_content_settings = |
| 47 TabSpecificContentSettings::FromWebContents(web_contents); | 43 TabSpecificContentSettings::FromWebContents(web_contents); |
| 48 | 44 |
| 49 #if defined(GOOGLE_TV) | |
| 50 // On GoogleTV, Netflix crypto/mdx plugin and DRM server adapter plugin can | |
| 51 // only come pre-installed with the OS, so we're willing to auto-grant access | |
| 52 // to them. PluginRootName should be matched with PEPPER_PLUGIN_ROOT | |
| 53 // in PepperPluginManager.java. | |
| 54 const char kPluginRootName[] = "/system/lib/pepperplugin"; | |
| 55 const char kNetflixCryptoPluginFileName[] = "libnrddpicrypto.so"; | |
| 56 const char kNetflixMdxPluginFileName[] = "libnrdmdx.so"; | |
| 57 const char kDrmServerAdapterPluginFileName[] = "libdrmserveradapter.so"; | |
| 58 base::FilePath::StringType plugin_dir_name = plugin_path.DirName().value(); | |
| 59 base::FilePath::StringType plugin_file_name = plugin_path.BaseName().value(); | |
| 60 if (base::android::IsRunningInWebapp() && | |
| 61 plugin_dir_name == FILE_PATH_LITERAL(kPluginRootName) && | |
| 62 (plugin_file_name == FILE_PATH_LITERAL(kNetflixCryptoPluginFileName) || | |
| 63 plugin_file_name == FILE_PATH_LITERAL(kNetflixMdxPluginFileName) || | |
| 64 plugin_file_name == | |
| 65 FILE_PATH_LITERAL(kDrmServerAdapterPluginFileName))) { | |
| 66 tab_content_settings->SetPepperBrokerAllowed(true); | |
| 67 callback.Run(true); | |
| 68 return; | |
| 69 } | |
| 70 #endif | |
| 71 | |
| 72 HostContentSettingsMap* content_settings = | 45 HostContentSettingsMap* content_settings = |
| 73 profile->GetHostContentSettingsMap(); | 46 profile->GetHostContentSettingsMap(); |
| 74 ContentSetting setting = | 47 ContentSetting setting = |
| 75 content_settings->GetContentSetting(url, url, | 48 content_settings->GetContentSetting(url, url, |
| 76 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | 49 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
| 77 std::string()); | 50 std::string()); |
| 78 | 51 |
| 79 if (setting == CONTENT_SETTING_ASK) { | 52 if (setting == CONTENT_SETTING_ASK) { |
| 80 content::RecordAction( | 53 content::RecordAction( |
| 81 base::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); | 54 base::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 base::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny")); | 145 base::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny")); |
| 173 callback_.Run(result); | 146 callback_.Run(result); |
| 174 callback_ = base::Callback<void(bool)>(); | 147 callback_ = base::Callback<void(bool)>(); |
| 175 content_settings_->SetContentSetting( | 148 content_settings_->SetContentSetting( |
| 176 ContentSettingsPattern::FromURLNoWildcard(url_), | 149 ContentSettingsPattern::FromURLNoWildcard(url_), |
| 177 ContentSettingsPattern::Wildcard(), | 150 ContentSettingsPattern::Wildcard(), |
| 178 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | 151 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
| 179 std::string(), result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | 152 std::string(), result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); |
| 180 tab_content_settings_->SetPepperBrokerAllowed(result); | 153 tab_content_settings_->SetPepperBrokerAllowed(result); |
| 181 } | 154 } |
| OLD | NEW |