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_service.h" | 11 #include "chrome/browser/infobars/infobar_service.h" |
11 #include "chrome/browser/plugins/plugin_finder.h" | 12 #include "chrome/browser/plugins/plugin_finder.h" |
12 #include "chrome/browser/plugins/plugin_metadata.h" | 13 #include "chrome/browser/plugins/plugin_metadata.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
15 #include "content/public/browser/page_navigator.h" | 16 #include "content/public/browser/page_navigator.h" |
16 #include "content/public/browser/plugin_service.h" | 17 #include "content/public/browser/plugin_service.h" |
17 #include "content/public/browser/user_metrics.h" | 18 #include "content/public/browser/user_metrics.h" |
18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
19 #include "content/public/common/referrer.h" | 20 #include "content/public/common/referrer.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 ContentSetting setting = | 89 ContentSetting setting = |
89 content_settings->GetContentSetting(url, url, | 90 content_settings->GetContentSetting(url, url, |
90 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | 91 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
91 std::string()); | 92 std::string()); |
92 | 93 |
93 if (setting == CONTENT_SETTING_ASK) { | 94 if (setting == CONTENT_SETTING_ASK) { |
94 content::RecordAction( | 95 content::RecordAction( |
95 content::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); | 96 content::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); |
96 InfoBarService* infobar_service = | 97 InfoBarService* infobar_service = |
97 InfoBarService::FromWebContents(web_contents); | 98 InfoBarService::FromWebContents(web_contents); |
98 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( | 99 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( |
99 new PepperBrokerInfoBarDelegate( | 100 scoped_ptr<ConfirmInfoBarDelegate>(new PepperBrokerInfoBarDelegate( |
100 infobar_service, url, plugin_path, | 101 url, plugin_path, |
101 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), | 102 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), |
102 content_settings, tab_content_settings, callback))); | 103 content_settings, tab_content_settings, callback)))); |
103 return; | 104 return; |
104 } | 105 } |
105 | 106 |
106 bool allowed = (setting == CONTENT_SETTING_ALLOW); | 107 bool allowed = (setting == CONTENT_SETTING_ALLOW); |
107 content::RecordAction(allowed ? | 108 content::RecordAction(allowed ? |
108 content::UserMetricsAction("PPAPI.BrokerSettingAllow") : | 109 content::UserMetricsAction("PPAPI.BrokerSettingAllow") : |
109 content::UserMetricsAction("PPAPI.BrokerSettingDeny")); | 110 content::UserMetricsAction("PPAPI.BrokerSettingDeny")); |
110 tab_content_settings->SetPepperBrokerAllowed(allowed); | 111 tab_content_settings->SetPepperBrokerAllowed(allowed); |
111 callback.Run(allowed); | 112 callback.Run(allowed); |
112 } | 113 } |
113 | 114 |
114 PepperBrokerInfoBarDelegate::PepperBrokerInfoBarDelegate( | 115 PepperBrokerInfoBarDelegate::PepperBrokerInfoBarDelegate( |
115 InfoBarService* infobar_service, | |
116 const GURL& url, | 116 const GURL& url, |
117 const base::FilePath& plugin_path, | 117 const base::FilePath& plugin_path, |
118 const std::string& languages, | 118 const std::string& languages, |
119 HostContentSettingsMap* content_settings, | 119 HostContentSettingsMap* content_settings, |
120 TabSpecificContentSettings* tab_content_settings, | 120 TabSpecificContentSettings* tab_content_settings, |
121 const base::Callback<void(bool)>& callback) | 121 const base::Callback<void(bool)>& callback) |
122 : ConfirmInfoBarDelegate(infobar_service), | 122 : ConfirmInfoBarDelegate(), |
123 url_(url), | 123 url_(url), |
124 plugin_path_(plugin_path), | 124 plugin_path_(plugin_path), |
125 languages_(languages), | 125 languages_(languages), |
126 content_settings_(content_settings), | 126 content_settings_(content_settings), |
127 tab_content_settings_(tab_content_settings), | 127 tab_content_settings_(tab_content_settings), |
128 callback_(callback) { | 128 callback_(callback) { |
129 } | 129 } |
130 | 130 |
131 PepperBrokerInfoBarDelegate::~PepperBrokerInfoBarDelegate() { | 131 PepperBrokerInfoBarDelegate::~PepperBrokerInfoBarDelegate() { |
132 if (!callback_.is_null()) | 132 if (!callback_.is_null()) |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 content::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny")); | 187 content::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny")); |
188 callback_.Run(result); | 188 callback_.Run(result); |
189 callback_ = base::Callback<void(bool)>(); | 189 callback_ = base::Callback<void(bool)>(); |
190 content_settings_->SetContentSetting( | 190 content_settings_->SetContentSetting( |
191 ContentSettingsPattern::FromURLNoWildcard(url_), | 191 ContentSettingsPattern::FromURLNoWildcard(url_), |
192 ContentSettingsPattern::Wildcard(), | 192 ContentSettingsPattern::Wildcard(), |
193 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | 193 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
194 std::string(), result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | 194 std::string(), result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); |
195 tab_content_settings_->SetPepperBrokerAllowed(result); | 195 tab_content_settings_->SetPepperBrokerAllowed(result); |
196 } | 196 } |
OLD | NEW |