Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(804)

Side by Side Diff: chrome/browser/pepper_broker_infobar_delegate.cc

Issue 11488009: Add content settings page action for Pepper broker authorization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/api/infobars/infobar_service.h" 7 #include "chrome/browser/api/infobars/infobar_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/plugins/plugin_finder.h" 10 #include "chrome/browser/plugins/plugin_finder.h"
10 #include "chrome/browser/plugins/plugin_metadata.h" 11 #include "chrome/browser/plugins/plugin_metadata.h"
11 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
14 #include "content/public/browser/page_navigator.h" 15 #include "content/public/browser/page_navigator.h"
15 #include "content/public/browser/plugin_service.h" 16 #include "content/public/browser/plugin_service.h"
16 #include "content/public/browser/user_metrics.h" 17 #include "content/public/browser/user_metrics.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 #include "content/public/common/referrer.h" 19 #include "content/public/common/referrer.h"
(...skipping 19 matching lines...) Expand all
38 const FilePath& plugin_path, 39 const FilePath& plugin_path,
39 const base::Callback<void(bool)>& callback) { 40 const base::Callback<void(bool)>& callback) {
40 Profile* profile = 41 Profile* profile =
41 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 42 Profile::FromBrowserContext(web_contents->GetBrowserContext());
42 // TODO(wad): Add ephemeral device ID support for broker in guest mode. 43 // TODO(wad): Add ephemeral device ID support for broker in guest mode.
43 if (profile->IsGuestSession()) { 44 if (profile->IsGuestSession()) {
44 callback.Run(false); 45 callback.Run(false);
45 return; 46 return;
46 } 47 }
47 48
49 TabSpecificContentSettings* tab_content_settings =
50 TabSpecificContentSettings::FromWebContents(web_contents);
48 HostContentSettingsMap* content_settings = 51 HostContentSettingsMap* content_settings =
49 profile->GetHostContentSettingsMap(); 52 profile->GetHostContentSettingsMap();
50 ContentSetting setting = 53 ContentSetting setting =
51 content_settings->GetContentSetting(url, url, 54 content_settings->GetContentSetting(url, url,
52 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, 55 CONTENT_SETTINGS_TYPE_PPAPI_BROKER,
53 std::string()); 56 std::string());
54 switch (setting) { 57 switch (setting) {
55 case CONTENT_SETTING_ALLOW: { 58 case CONTENT_SETTING_ALLOW: {
56 content::RecordAction( 59 content::RecordAction(
57 content::UserMetricsAction("PPAPI.BrokerSettingAllow")); 60 content::UserMetricsAction("PPAPI.BrokerSettingAllow"));
61 tab_content_settings->SetPepperBrokerAllowed(true);
58 callback.Run(true); 62 callback.Run(true);
59 break; 63 break;
60 } 64 }
61 case CONTENT_SETTING_BLOCK: { 65 case CONTENT_SETTING_BLOCK: {
62 content::RecordAction( 66 content::RecordAction(
63 content::UserMetricsAction("PPAPI.BrokerSettingDeny")); 67 content::UserMetricsAction("PPAPI.BrokerSettingDeny"));
68 tab_content_settings->SetPepperBrokerAllowed(false);
64 callback.Run(false); 69 callback.Run(false);
65 break; 70 break;
66 } 71 }
67 case CONTENT_SETTING_ASK: { 72 case CONTENT_SETTING_ASK: {
68 content::RecordAction( 73 content::RecordAction(
69 content::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); 74 content::UserMetricsAction("PPAPI.BrokerInfobarDisplayed"));
70 75
71 InfoBarService* infobar_service = 76 InfoBarService* infobar_service =
72 InfoBarService::FromWebContents(web_contents); 77 InfoBarService::FromWebContents(web_contents);
73 std::string languages = 78 std::string languages =
74 profile->GetPrefs()->GetString(prefs::kAcceptLanguages); 79 profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
75 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( 80 infobar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>(
76 new PepperBrokerInfoBarDelegate( 81 new PepperBrokerInfoBarDelegate(
77 infobar_service, url, plugin_path, languages, content_settings, 82 infobar_service, url, plugin_path, languages, content_settings,
78 callback))); 83 tab_content_settings, callback)));
79 break; 84 break;
80 } 85 }
81 default: 86 default:
82 NOTREACHED(); 87 NOTREACHED();
83 } 88 }
84 } 89 }
85 90
86 string16 PepperBrokerInfoBarDelegate::GetMessageText() const { 91 string16 PepperBrokerInfoBarDelegate::GetMessageText() const {
87 content::PluginService* plugin_service = 92 content::PluginService* plugin_service =
88 content::PluginService::GetInstance(); 93 content::PluginService::GetInstance();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 148 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
144 IDR_INFOBAR_PLUGIN_INSTALL); 149 IDR_INFOBAR_PLUGIN_INSTALL);
145 } 150 }
146 151
147 PepperBrokerInfoBarDelegate::PepperBrokerInfoBarDelegate( 152 PepperBrokerInfoBarDelegate::PepperBrokerInfoBarDelegate(
148 InfoBarService* infobar_service, 153 InfoBarService* infobar_service,
149 const GURL& url, 154 const GURL& url,
150 const FilePath& plugin_path, 155 const FilePath& plugin_path,
151 const std::string& languages, 156 const std::string& languages,
152 HostContentSettingsMap* content_settings, 157 HostContentSettingsMap* content_settings,
158 TabSpecificContentSettings* tab_content_settings,
153 const base::Callback<void(bool)>& callback) 159 const base::Callback<void(bool)>& callback)
154 : ConfirmInfoBarDelegate(infobar_service), 160 : ConfirmInfoBarDelegate(infobar_service),
155 url_(url), 161 url_(url),
156 plugin_path_(plugin_path), 162 plugin_path_(plugin_path),
157 languages_(languages), 163 languages_(languages),
158 content_settings_(content_settings), 164 content_settings_(content_settings),
165 tab_content_settings_(tab_content_settings),
159 callback_(callback) { 166 callback_(callback) {
160 } 167 }
161 168
162 PepperBrokerInfoBarDelegate::~PepperBrokerInfoBarDelegate() { 169 PepperBrokerInfoBarDelegate::~PepperBrokerInfoBarDelegate() {
163 if (!callback_.is_null()) 170 if (!callback_.is_null())
164 callback_.Run(false); 171 callback_.Run(false);
165 } 172 }
166 173
167 void PepperBrokerInfoBarDelegate::DispatchCallback(bool result) { 174 void PepperBrokerInfoBarDelegate::DispatchCallback(bool result) {
168 content::RecordAction(result ? 175 content::RecordAction(result ?
169 content::UserMetricsAction("PPAPI.BrokerInfobarClickedAllow") : 176 content::UserMetricsAction("PPAPI.BrokerInfobarClickedAllow") :
170 content::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny")); 177 content::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny"));
171 callback_.Run(result); 178 callback_.Run(result);
172 callback_ = base::Callback<void(bool)>(); 179 callback_ = base::Callback<void(bool)>();
173 content_settings_->SetContentSetting( 180 content_settings_->SetContentSetting(
174 ContentSettingsPattern::FromURLNoWildcard(url_), 181 ContentSettingsPattern::FromURLNoWildcard(url_),
175 ContentSettingsPattern::Wildcard(), 182 ContentSettingsPattern::Wildcard(),
176 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, 183 CONTENT_SETTINGS_TYPE_PPAPI_BROKER,
177 std::string(), result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); 184 std::string(), result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK);
185 tab_content_settings_->SetPepperBrokerAllowed(result);
178 } 186 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698