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

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

Issue 1841653003: Drop |languages| from {Format,Elide}Url* and IDNToUnicode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typo in elide_url.cc Created 4 years, 8 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
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_factory.h" 7 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
8 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 8 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
9 #include "chrome/browser/infobars/infobar_service.h" 9 #include "chrome/browser/infobars/infobar_service.h"
10 #include "chrome/browser/plugins/plugin_finder.h" 10 #include "chrome/browser/plugins/plugin_finder.h"
11 #include "chrome/browser/plugins/plugin_metadata.h" 11 #include "chrome/browser/plugins/plugin_metadata.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/pref_names.h"
14 #include "chrome/grit/generated_resources.h" 13 #include "chrome/grit/generated_resources.h"
15 #include "components/content_settings/core/browser/host_content_settings_map.h" 14 #include "components/content_settings/core/browser/host_content_settings_map.h"
16 #include "components/infobars/core/infobar.h" 15 #include "components/infobars/core/infobar.h"
17 #include "components/prefs/pref_service.h"
18 #include "components/url_formatter/elide_url.h" 16 #include "components/url_formatter/elide_url.h"
19 #include "content/public/browser/page_navigator.h" 17 #include "content/public/browser/page_navigator.h"
20 #include "content/public/browser/plugin_service.h" 18 #include "content/public/browser/plugin_service.h"
21 #include "content/public/browser/user_metrics.h" 19 #include "content/public/browser/user_metrics.h"
22 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
23 #include "content/public/common/referrer.h" 21 #include "content/public/common/referrer.h"
24 #include "content/public/common/webplugininfo.h" 22 #include "content/public/common/webplugininfo.h"
25 #include "grit/components_strings.h" 23 #include "grit/components_strings.h"
26 #include "grit/theme_resources.h" 24 #include "grit/theme_resources.h"
27 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
(...skipping 23 matching lines...) Expand all
51 CONTENT_SETTINGS_TYPE_PPAPI_BROKER, 49 CONTENT_SETTINGS_TYPE_PPAPI_BROKER,
52 std::string()); 50 std::string());
53 51
54 if (setting == CONTENT_SETTING_ASK) { 52 if (setting == CONTENT_SETTING_ASK) {
55 content::RecordAction( 53 content::RecordAction(
56 base::UserMetricsAction("PPAPI.BrokerInfobarDisplayed")); 54 base::UserMetricsAction("PPAPI.BrokerInfobarDisplayed"));
57 InfoBarService* infobar_service = 55 InfoBarService* infobar_service =
58 InfoBarService::FromWebContents(web_contents); 56 InfoBarService::FromWebContents(web_contents);
59 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar( 57 infobar_service->AddInfoBar(infobar_service->CreateConfirmInfoBar(
60 scoped_ptr<ConfirmInfoBarDelegate>(new PepperBrokerInfoBarDelegate( 58 scoped_ptr<ConfirmInfoBarDelegate>(new PepperBrokerInfoBarDelegate(
61 url, plugin_path, 59 url, plugin_path, content_settings, tab_content_settings,
62 profile->GetPrefs()->GetString(prefs::kAcceptLanguages), 60 callback))));
63 content_settings, tab_content_settings, callback))));
64 return; 61 return;
65 } 62 }
66 63
67 bool allowed = (setting == CONTENT_SETTING_ALLOW); 64 bool allowed = (setting == CONTENT_SETTING_ALLOW);
68 content::RecordAction(allowed ? 65 content::RecordAction(allowed ?
69 base::UserMetricsAction("PPAPI.BrokerSettingAllow") : 66 base::UserMetricsAction("PPAPI.BrokerSettingAllow") :
70 base::UserMetricsAction("PPAPI.BrokerSettingDeny")); 67 base::UserMetricsAction("PPAPI.BrokerSettingDeny"));
71 tab_content_settings->SetPepperBrokerAllowed(allowed); 68 tab_content_settings->SetPepperBrokerAllowed(allowed);
72 callback.Run(allowed); 69 callback.Run(allowed);
73 } 70 }
74 71
75 PepperBrokerInfoBarDelegate::PepperBrokerInfoBarDelegate( 72 PepperBrokerInfoBarDelegate::PepperBrokerInfoBarDelegate(
76 const GURL& url, 73 const GURL& url,
77 const base::FilePath& plugin_path, 74 const base::FilePath& plugin_path,
78 const std::string& languages,
79 HostContentSettingsMap* content_settings, 75 HostContentSettingsMap* content_settings,
80 TabSpecificContentSettings* tab_content_settings, 76 TabSpecificContentSettings* tab_content_settings,
81 const base::Callback<void(bool)>& callback) 77 const base::Callback<void(bool)>& callback)
82 : ConfirmInfoBarDelegate(), 78 : ConfirmInfoBarDelegate(),
83 url_(url), 79 url_(url),
84 plugin_path_(plugin_path), 80 plugin_path_(plugin_path),
85 languages_(languages),
86 content_settings_(content_settings), 81 content_settings_(content_settings),
87 tab_content_settings_(tab_content_settings), 82 tab_content_settings_(tab_content_settings),
88 callback_(callback) { 83 callback_(callback) {
89 } 84 }
90 85
91 PepperBrokerInfoBarDelegate::~PepperBrokerInfoBarDelegate() { 86 PepperBrokerInfoBarDelegate::~PepperBrokerInfoBarDelegate() {
92 if (!callback_.is_null()) 87 if (!callback_.is_null())
93 callback_.Run(false); 88 callback_.Run(false);
94 } 89 }
95 90
96 infobars::InfoBarDelegate::InfoBarIdentifier 91 infobars::InfoBarDelegate::InfoBarIdentifier
97 PepperBrokerInfoBarDelegate::GetIdentifier() const { 92 PepperBrokerInfoBarDelegate::GetIdentifier() const {
98 return PEPPER_BROKER_INFOBAR_DELEGATE; 93 return PEPPER_BROKER_INFOBAR_DELEGATE;
99 } 94 }
100 95
101 int PepperBrokerInfoBarDelegate::GetIconId() const { 96 int PepperBrokerInfoBarDelegate::GetIconId() const {
102 return IDR_INFOBAR_PLUGIN_INSTALL; 97 return IDR_INFOBAR_PLUGIN_INSTALL;
103 } 98 }
104 99
105 base::string16 PepperBrokerInfoBarDelegate::GetMessageText() const { 100 base::string16 PepperBrokerInfoBarDelegate::GetMessageText() const {
106 content::PluginService* plugin_service = 101 content::PluginService* plugin_service =
107 content::PluginService::GetInstance(); 102 content::PluginService::GetInstance();
108 content::WebPluginInfo plugin; 103 content::WebPluginInfo plugin;
109 bool success = plugin_service->GetPluginInfoByPath(plugin_path_, &plugin); 104 bool success = plugin_service->GetPluginInfoByPath(plugin_path_, &plugin);
110 DCHECK(success); 105 DCHECK(success);
111 scoped_ptr<PluginMetadata> plugin_metadata( 106 scoped_ptr<PluginMetadata> plugin_metadata(
112 PluginFinder::GetInstance()->GetPluginMetadata(plugin)); 107 PluginFinder::GetInstance()->GetPluginMetadata(plugin));
113 return l10n_util::GetStringFUTF16( 108 return l10n_util::GetStringFUTF16(
114 IDS_PEPPER_BROKER_MESSAGE, plugin_metadata->name(), 109 IDS_PEPPER_BROKER_MESSAGE, plugin_metadata->name(),
115 url_formatter::FormatUrlForSecurityDisplay(url_, languages_)); 110 url_formatter::FormatUrlForSecurityDisplay(url_));
116 } 111 }
117 112
118 base::string16 PepperBrokerInfoBarDelegate::GetButtonLabel( 113 base::string16 PepperBrokerInfoBarDelegate::GetButtonLabel(
119 InfoBarButton button) const { 114 InfoBarButton button) const {
120 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? 115 return l10n_util::GetStringUTF16((button == BUTTON_OK) ?
121 IDS_PEPPER_BROKER_ALLOW_BUTTON : IDS_PEPPER_BROKER_DENY_BUTTON); 116 IDS_PEPPER_BROKER_ALLOW_BUTTON : IDS_PEPPER_BROKER_DENY_BUTTON);
122 } 117 }
123 118
124 bool PepperBrokerInfoBarDelegate::Accept() { 119 bool PepperBrokerInfoBarDelegate::Accept() {
125 DispatchCallback(true); 120 DispatchCallback(true);
(...skipping 17 matching lines...) Expand all
143 content::RecordAction(result ? 138 content::RecordAction(result ?
144 base::UserMetricsAction("PPAPI.BrokerInfobarClickedAllow") : 139 base::UserMetricsAction("PPAPI.BrokerInfobarClickedAllow") :
145 base::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny")); 140 base::UserMetricsAction("PPAPI.BrokerInfobarClickedDeny"));
146 callback_.Run(result); 141 callback_.Run(result);
147 callback_ = base::Callback<void(bool)>(); 142 callback_ = base::Callback<void(bool)>();
148 content_settings_->SetContentSettingDefaultScope( 143 content_settings_->SetContentSettingDefaultScope(
149 url_, GURL(), CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string(), 144 url_, GURL(), CONTENT_SETTINGS_TYPE_PPAPI_BROKER, std::string(),
150 result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); 145 result ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK);
151 tab_content_settings_->SetPepperBrokerAllowed(result); 146 tab_content_settings_->SetPepperBrokerAllowed(result);
152 } 147 }
OLDNEW
« no previous file with comments | « chrome/browser/pepper_broker_infobar_delegate.h ('k') | chrome/browser/permissions/permission_bubble_request_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698