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" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | 49 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
50 std::string()); | 50 std::string()); |
51 | 51 |
52 if (setting == CONTENT_SETTING_ASK) { | 52 if (setting == CONTENT_SETTING_ASK) { |
53 content::RecordAction( | 53 content::RecordAction( |
54 base::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); | 54 base::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); |
55 InfoBarService* infobar_service = | 55 InfoBarService* infobar_service = |
56 InfoBarService::FromWebContents(web_contents); | 56 InfoBarService::FromWebContents(web_contents); |
57 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( | 57 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( |
58 scoped_ptr<ConfirmInfoBarDelegate>(new PepperBrokerInfoBarDelegate( | 58 scoped_ptr<ConfirmInfoBarDelegate>(new PepperBrokerInfoBarDelegate( |
59 url, plugin_path, | 59 web_contents, |
| 60 url, |
| 61 plugin_path, |
60 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), | 62 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), |
61 content_settings, tab_content_settings, callback)))); | 63 content_settings, |
| 64 tab_content_settings, |
| 65 callback)))); |
62 return; | 66 return; |
63 } | 67 } |
64 | 68 |
65 bool allowed = (setting == CONTENT_SETTING_ALLOW); | 69 bool allowed = (setting == CONTENT_SETTING_ALLOW); |
66 content::RecordAction(allowed ? | 70 content::RecordAction(allowed ? |
67 base::UserMetricsAction("PPAPI.BrokerSettingAllow") : | 71 base::UserMetricsAction("PPAPI.BrokerSettingAllow") : |
68 base::UserMetricsAction("PPAPI.BrokerSettingDeny")); | 72 base::UserMetricsAction("PPAPI.BrokerSettingDeny")); |
69 tab_content_settings->SetPepperBrokerAllowed(allowed); | 73 tab_content_settings->SetPepperBrokerAllowed(allowed); |
70 callback.Run(allowed); | 74 callback.Run(allowed); |
71 } | 75 } |
72 | 76 |
73 PepperBrokerInfoBarDelegate::PepperBrokerInfoBarDelegate( | 77 PepperBrokerInfoBarDelegate::PepperBrokerInfoBarDelegate( |
| 78 content::WebContents* web_contents, |
74 const GURL& url, | 79 const GURL& url, |
75 const base::FilePath& plugin_path, | 80 const base::FilePath& plugin_path, |
76 const std::string& languages, | 81 const std::string& languages, |
77 HostContentSettingsMap* content_settings, | 82 HostContentSettingsMap* content_settings, |
78 TabSpecificContentSettings* tab_content_settings, | 83 TabSpecificContentSettings* tab_content_settings, |
79 const base::Callback<void(bool)>& callback) | 84 const base::Callback<void(bool)>& callback) |
80 : ConfirmInfoBarDelegate(), | 85 : ContentConfirmInfoBarDelegate(web_contents), |
81 url_(url), | 86 url_(url), |
82 plugin_path_(plugin_path), | 87 plugin_path_(plugin_path), |
83 languages_(languages), | 88 languages_(languages), |
84 content_settings_(content_settings), | 89 content_settings_(content_settings), |
85 tab_content_settings_(tab_content_settings), | 90 tab_content_settings_(tab_content_settings), |
86 callback_(callback) { | 91 callback_(callback) {} |
87 } | |
88 | 92 |
89 PepperBrokerInfoBarDelegate::~PepperBrokerInfoBarDelegate() { | 93 PepperBrokerInfoBarDelegate::~PepperBrokerInfoBarDelegate() { |
90 if (!callback_.is_null()) | 94 if (!callback_.is_null()) |
91 callback_.Run(false); | 95 callback_.Run(false); |
92 } | 96 } |
93 | 97 |
94 int PepperBrokerInfoBarDelegate::GetIconID() const { | 98 int PepperBrokerInfoBarDelegate::GetIconID() const { |
95 return IDR_INFOBAR_PLUGIN_INSTALL; | 99 return IDR_INFOBAR_PLUGIN_INSTALL; |
96 } | 100 } |
97 | 101 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 base::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny")); | 149 base::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny")); |
146 callback_.Run(result); | 150 callback_.Run(result); |
147 callback_ = base::Callback<void(bool)>(); | 151 callback_ = base::Callback<void(bool)>(); |
148 content_settings_->SetContentSetting( | 152 content_settings_->SetContentSetting( |
149 ContentSettingsPattern::FromURLNoWildcard(url_), | 153 ContentSettingsPattern::FromURLNoWildcard(url_), |
150 ContentSettingsPattern::Wildcard(), | 154 ContentSettingsPattern::Wildcard(), |
151 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, | 155 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, |
152 std::string(), result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | 156 std::string(), result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); |
153 tab_content_settings_->SetPepperBrokerAllowed(result); | 157 tab_content_settings_->SetPepperBrokerAllowed(result); |
154 } | 158 } |
OLD | NEW |