| 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/tab_specific_content_settings.h" | 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
| 10 #include "chrome/browser/plugins/plugin_finder.h" | 10 #include "chrome/browser/plugins/plugin_finder.h" |
| 11 #include "chrome/browser/plugins/plugin_metadata.h" | 11 #include "chrome/browser/plugins/plugin_metadata.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 14 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 15 #include "components/content_settings/core/browser/host_content_settings_map.h" | 15 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 16 #include "components/infobars/core/infobar.h" | 16 #include "components/infobars/core/infobar.h" |
| 17 #include "components/url_formatter/url_formatter.h" | |
| 18 #include "content/public/browser/page_navigator.h" | 17 #include "content/public/browser/page_navigator.h" |
| 19 #include "content/public/browser/plugin_service.h" | 18 #include "content/public/browser/plugin_service.h" |
| 20 #include "content/public/browser/user_metrics.h" | 19 #include "content/public/browser/user_metrics.h" |
| 21 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 22 #include "content/public/common/referrer.h" | 21 #include "content/public/common/referrer.h" |
| 23 #include "content/public/common/webplugininfo.h" | 22 #include "content/public/common/webplugininfo.h" |
| 24 #include "grit/components_strings.h" | 23 #include "grit/components_strings.h" |
| 25 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
| 25 #include "net/base/net_util.h" |
| 26 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 27 | 27 |
| 28 | 28 |
| 29 // static | 29 // static |
| 30 void PepperBrokerInfoBarDelegate::Create( | 30 void PepperBrokerInfoBarDelegate::Create( |
| 31 content::WebContents* web_contents, | 31 content::WebContents* web_contents, |
| 32 const GURL& url, | 32 const GURL& url, |
| 33 const base::FilePath& plugin_path, | 33 const base::FilePath& plugin_path, |
| 34 const base::Callback<void(bool)>& callback) { | 34 const base::Callback<void(bool)>& callback) { |
| 35 Profile* profile = | 35 Profile* profile = |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 } | 97 } |
| 98 | 98 |
| 99 base::string16 PepperBrokerInfoBarDelegate::GetMessageText() const { | 99 base::string16 PepperBrokerInfoBarDelegate::GetMessageText() const { |
| 100 content::PluginService* plugin_service = | 100 content::PluginService* plugin_service = |
| 101 content::PluginService::GetInstance(); | 101 content::PluginService::GetInstance(); |
| 102 content::WebPluginInfo plugin; | 102 content::WebPluginInfo plugin; |
| 103 bool success = plugin_service->GetPluginInfoByPath(plugin_path_, &plugin); | 103 bool success = plugin_service->GetPluginInfoByPath(plugin_path_, &plugin); |
| 104 DCHECK(success); | 104 DCHECK(success); |
| 105 scoped_ptr<PluginMetadata> plugin_metadata( | 105 scoped_ptr<PluginMetadata> plugin_metadata( |
| 106 PluginFinder::GetInstance()->GetPluginMetadata(plugin)); | 106 PluginFinder::GetInstance()->GetPluginMetadata(plugin)); |
| 107 return l10n_util::GetStringFUTF16( | 107 return l10n_util::GetStringFUTF16(IDS_PEPPER_BROKER_MESSAGE, |
| 108 IDS_PEPPER_BROKER_MESSAGE, plugin_metadata->name(), | 108 plugin_metadata->name(), |
| 109 url_formatter::FormatUrl(url_.GetOrigin(), languages_)); | 109 net::FormatUrl(url_.GetOrigin(), |
| 110 languages_)); |
| 110 } | 111 } |
| 111 | 112 |
| 112 base::string16 PepperBrokerInfoBarDelegate::GetButtonLabel( | 113 base::string16 PepperBrokerInfoBarDelegate::GetButtonLabel( |
| 113 InfoBarButton button) const { | 114 InfoBarButton button) const { |
| 114 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | 115 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? |
| 115 IDS_PEPPER_BROKER_ALLOW_BUTTON : IDS_PEPPER_BROKER_DENY_BUTTON); | 116 IDS_PEPPER_BROKER_ALLOW_BUTTON : IDS_PEPPER_BROKER_DENY_BUTTON); |
| 116 } | 117 } |
| 117 | 118 |
| 118 bool PepperBrokerInfoBarDelegate::Accept() { | 119 bool PepperBrokerInfoBarDelegate::Accept() { |
| 119 DispatchCallback(true); | 120 DispatchCallback(true); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 146 base::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny")); | 147 base::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny")); |
| 147 callback_.Run(result); | 148 callback_.Run(result); |
| 148 callback_ = base::Callback<void(bool)>(); | 149 callback_ = base::Callback<void(bool)>(); |
| 149 content_settings_->SetContentSetting( | 150 content_settings_->SetContentSetting( |
| 150 ContentSettingsPattern::FromURLNoWildcard(url_), | 151 ContentSettingsPattern::FromURLNoWildcard(url_), |
| 151 ContentSettingsPattern::Wildcard(), | 152 ContentSettingsPattern::Wildcard(), |
| 152 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | 153 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
| 153 std::string(), result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | 154 std::string(), result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); |
| 154 tab_content_settings_->SetPepperBrokerAllowed(result); | 155 tab_content_settings_->SetPepperBrokerAllowed(result); |
| 155 } | 156 } |
| OLD | NEW |