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" | |
11 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
12 #include "chrome/browser/plugins/plugin_finder.h" | 11 #include "chrome/browser/plugins/plugin_finder.h" |
13 #include "chrome/browser/plugins/plugin_metadata.h" | 12 #include "chrome/browser/plugins/plugin_metadata.h" |
14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
16 #include "content/public/browser/page_navigator.h" | 15 #include "content/public/browser/page_navigator.h" |
17 #include "content/public/browser/plugin_service.h" | 16 #include "content/public/browser/plugin_service.h" |
18 #include "content/public/browser/user_metrics.h" | 17 #include "content/public/browser/user_metrics.h" |
19 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
20 #include "content/public/common/referrer.h" | 19 #include "content/public/common/referrer.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 ContentSetting setting = | 88 ContentSetting setting = |
90 content_settings->GetContentSetting(url, url, | 89 content_settings->GetContentSetting(url, url, |
91 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | 90 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
92 std::string()); | 91 std::string()); |
93 | 92 |
94 if (setting == CONTENT_SETTING_ASK) { | 93 if (setting == CONTENT_SETTING_ASK) { |
95 content::RecordAction( | 94 content::RecordAction( |
96 content::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); | 95 content::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); |
97 InfoBarService* infobar_service = | 96 InfoBarService* infobar_service = |
98 InfoBarService::FromWebContents(web_contents); | 97 InfoBarService::FromWebContents(web_contents); |
99 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( | 98 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
100 scoped_ptr<ConfirmInfoBarDelegate>(new PepperBrokerInfoBarDelegate( | 99 new PepperBrokerInfoBarDelegate( |
101 url, plugin_path, | 100 infobar_service, url, plugin_path, |
102 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), | 101 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), |
103 content_settings, tab_content_settings, callback)))); | 102 content_settings, tab_content_settings, callback))); |
104 return; | 103 return; |
105 } | 104 } |
106 | 105 |
107 bool allowed = (setting == CONTENT_SETTING_ALLOW); | 106 bool allowed = (setting == CONTENT_SETTING_ALLOW); |
108 content::RecordAction(allowed ? | 107 content::RecordAction(allowed ? |
109 content::UserMetricsAction("PPAPI.BrokerSettingAllow") : | 108 content::UserMetricsAction("PPAPI.BrokerSettingAllow") : |
110 content::UserMetricsAction("PPAPI.BrokerSettingDeny")); | 109 content::UserMetricsAction("PPAPI.BrokerSettingDeny")); |
111 tab_content_settings->SetPepperBrokerAllowed(allowed); | 110 tab_content_settings->SetPepperBrokerAllowed(allowed); |
112 callback.Run(allowed); | 111 callback.Run(allowed); |
113 } | 112 } |
114 | 113 |
115 PepperBrokerInfoBarDelegate::PepperBrokerInfoBarDelegate( | 114 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(), | 122 : ConfirmInfoBarDelegate(infobar_service), |
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 |