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

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: sync Created 8 years 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/content_settings/host_content_settings_map.h" 7 #include "chrome/browser/content_settings/host_content_settings_map.h"
8 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
8 #include "chrome/browser/infobars/infobar_tab_helper.h" 9 #include "chrome/browser/infobars/infobar_tab_helper.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"
(...skipping 20 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 // TODO(wad): Add ephemeral device ID support for broker in guest mode. 41 // TODO(wad): Add ephemeral device ID support for broker in guest mode.
41 if (Profile::IsGuestSession()) { 42 if (Profile::IsGuestSession()) {
42 callback.Run(false); 43 callback.Run(false);
43 return; 44 return;
44 } 45 }
45 46
46 Profile* profile = 47 Profile* profile =
47 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 48 Profile::FromBrowserContext(web_contents->GetBrowserContext());
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 InfoBarTabHelper* infobar_helper = 76 InfoBarTabHelper* infobar_helper =
72 InfoBarTabHelper::FromWebContents(web_contents); 77 InfoBarTabHelper::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_helper->AddInfoBar( 80 infobar_helper->AddInfoBar(
76 new PepperBrokerInfoBarDelegate( 81 new PepperBrokerInfoBarDelegate(
77 infobar_helper, url, plugin_path, languages, content_settings, 82 infobar_helper, 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 PepperBrokerInfoBarDelegate::PepperBrokerInfoBarDelegate( 91 PepperBrokerInfoBarDelegate::PepperBrokerInfoBarDelegate(
87 InfoBarTabHelper* helper, 92 InfoBarTabHelper* helper,
88 const GURL& url, 93 const GURL& url,
89 const FilePath& plugin_path, 94 const FilePath& plugin_path,
90 const std::string& languages, 95 const std::string& languages,
91 HostContentSettingsMap* content_settings, 96 HostContentSettingsMap* content_settings,
97 TabSpecificContentSettings* tab_content_settings,
92 const base::Callback<void(bool)>& callback) 98 const base::Callback<void(bool)>& callback)
93 : ConfirmInfoBarDelegate(helper), 99 : ConfirmInfoBarDelegate(helper),
94 url_(url), 100 url_(url),
95 plugin_path_(plugin_path), 101 plugin_path_(plugin_path),
96 languages_(languages), 102 languages_(languages),
97 content_settings_(content_settings), 103 content_settings_(content_settings),
104 tab_content_settings_(tab_content_settings),
98 callback_(callback) { 105 callback_(callback) {
99 } 106 }
100 107
101 PepperBrokerInfoBarDelegate::~PepperBrokerInfoBarDelegate() { 108 PepperBrokerInfoBarDelegate::~PepperBrokerInfoBarDelegate() {
102 if (!callback_.is_null()) 109 if (!callback_.is_null())
103 callback_.Run(false); 110 callback_.Run(false);
104 } 111 }
105 112
106 string16 PepperBrokerInfoBarDelegate::GetMessageText() const { 113 string16 PepperBrokerInfoBarDelegate::GetMessageText() const {
107 content::PluginService* plugin_service = 114 content::PluginService* plugin_service =
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
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