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. |
(...skipping 13 matching lines...) Expand all Loading... |
54 | 50 |
55 base::FilePath plugin_file_name = plugin_path.BaseName(); | 51 base::FilePath plugin_file_name = plugin_path.BaseName(); |
56 if (plugin_file_name.value() == FILE_PATH_LITERAL(kWidevinePluginFileName) && | 52 if (plugin_file_name.value() == FILE_PATH_LITERAL(kWidevinePluginFileName) && |
57 url.DomainIs(kNetflixDomain)) { | 53 url.DomainIs(kNetflixDomain)) { |
58 tab_content_settings->SetPepperBrokerAllowed(true); | 54 tab_content_settings->SetPepperBrokerAllowed(true); |
59 callback.Run(true); | 55 callback.Run(true); |
60 return; | 56 return; |
61 } | 57 } |
62 #endif | 58 #endif |
63 | 59 |
64 #if defined(GOOGLE_TV) | |
65 // On GoogleTV, Netflix crypto/mdx plugin and DRM server adapter plugin can | |
66 // only come pre-installed with the OS, so we're willing to auto-grant access | |
67 // to them. PluginRootName should be matched with PEPPER_PLUGIN_ROOT | |
68 // in PepperPluginManager.java. | |
69 const char kPluginRootName[] = "/system/lib/pepperplugin"; | |
70 const char kNetflixCryptoPluginFileName[] = "libnrddpicrypto.so"; | |
71 const char kNetflixMdxPluginFileName[] = "libnrdmdx.so"; | |
72 const char kDrmServerAdapterPluginFileName[] = "libdrmserveradapter.so"; | |
73 base::FilePath::StringType plugin_dir_name = plugin_path.DirName().value(); | |
74 base::FilePath::StringType plugin_file_name = plugin_path.BaseName().value(); | |
75 if (base::android::IsRunningInWebapp() && | |
76 plugin_dir_name == FILE_PATH_LITERAL(kPluginRootName) && | |
77 (plugin_file_name == FILE_PATH_LITERAL(kNetflixCryptoPluginFileName) || | |
78 plugin_file_name == FILE_PATH_LITERAL(kNetflixMdxPluginFileName) || | |
79 plugin_file_name == | |
80 FILE_PATH_LITERAL(kDrmServerAdapterPluginFileName))) { | |
81 tab_content_settings->SetPepperBrokerAllowed(true); | |
82 callback.Run(true); | |
83 return; | |
84 } | |
85 #endif | |
86 | |
87 HostContentSettingsMap* content_settings = | 60 HostContentSettingsMap* content_settings = |
88 profile->GetHostContentSettingsMap(); | 61 profile->GetHostContentSettingsMap(); |
89 ContentSetting setting = | 62 ContentSetting setting = |
90 content_settings->GetContentSetting(url, url, | 63 content_settings->GetContentSetting(url, url, |
91 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | 64 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
92 std::string()); | 65 std::string()); |
93 | 66 |
94 if (setting == CONTENT_SETTING_ASK) { | 67 if (setting == CONTENT_SETTING_ASK) { |
95 content::RecordAction( | 68 content::RecordAction( |
96 content::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); | 69 content::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 content::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny")); | 160 content::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny")); |
188 callback_.Run(result); | 161 callback_.Run(result); |
189 callback_ = base::Callback<void(bool)>(); | 162 callback_ = base::Callback<void(bool)>(); |
190 content_settings_->SetContentSetting( | 163 content_settings_->SetContentSetting( |
191 ContentSettingsPattern::FromURLNoWildcard(url_), | 164 ContentSettingsPattern::FromURLNoWildcard(url_), |
192 ContentSettingsPattern::Wildcard(), | 165 ContentSettingsPattern::Wildcard(), |
193 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | 166 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
194 std::string(), result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | 167 std::string(), result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); |
195 tab_content_settings_->SetPepperBrokerAllowed(result); | 168 tab_content_settings_->SetPepperBrokerAllowed(result); |
196 } | 169 } |
OLD | NEW |