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/plugins/plugin_infobar_delegates.h" | 5 #include "chrome/browser/plugins/plugin_infobar_delegates.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 } | 74 } |
75 | 75 |
76 int PluginInfoBarDelegate::GetIconID() const { | 76 int PluginInfoBarDelegate::GetIconID() const { |
77 return IDR_INFOBAR_PLUGIN_INSTALL; | 77 return IDR_INFOBAR_PLUGIN_INSTALL; |
78 } | 78 } |
79 | 79 |
80 base::string16 PluginInfoBarDelegate::GetLinkText() const { | 80 base::string16 PluginInfoBarDelegate::GetLinkText() const { |
81 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 81 return l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
82 } | 82 } |
83 | 83 |
84 | |
85 // UnauthorizedPluginInfoBarDelegate ------------------------------------------ | |
sky
2014/12/15 16:45:40
If there are any dead includes please nuke them.
Will Harris
2014/12/15 19:23:46
Done.
| |
86 | |
87 // static | |
88 void UnauthorizedPluginInfoBarDelegate::Create( | |
89 InfoBarService* infobar_service, | |
90 HostContentSettingsMap* content_settings, | |
91 const base::string16& name, | |
92 const std::string& identifier) { | |
93 infobar_service->AddInfoBar(ConfirmInfoBarDelegate::CreateInfoBar( | |
94 scoped_ptr<ConfirmInfoBarDelegate>(new UnauthorizedPluginInfoBarDelegate( | |
95 content_settings, name, identifier)))); | |
96 | |
97 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown")); | |
98 std::string utf8_name(base::UTF16ToUTF8(name)); | |
99 if (utf8_name == PluginMetadata::kJavaGroupName) { | |
100 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Shown.Java")); | |
101 } else if (utf8_name == PluginMetadata::kQuickTimeGroupName) { | |
102 content::RecordAction( | |
103 UserMetricsAction("BlockedPluginInfobar.Shown.QuickTime")); | |
104 } else if (utf8_name == PluginMetadata::kShockwaveGroupName) { | |
105 content::RecordAction( | |
106 UserMetricsAction("BlockedPluginInfobar.Shown.Shockwave")); | |
107 } else if (utf8_name == PluginMetadata::kRealPlayerGroupName) { | |
108 content::RecordAction( | |
109 UserMetricsAction("BlockedPluginInfobar.Shown.RealPlayer")); | |
110 } else if (utf8_name == PluginMetadata::kWindowsMediaPlayerGroupName) { | |
111 content::RecordAction( | |
112 UserMetricsAction("BlockedPluginInfobar.Shown.WindowsMediaPlayer")); | |
113 } | |
114 } | |
115 | |
116 UnauthorizedPluginInfoBarDelegate::UnauthorizedPluginInfoBarDelegate( | |
117 HostContentSettingsMap* content_settings, | |
118 const base::string16& name, | |
119 const std::string& identifier) | |
120 : PluginInfoBarDelegate(identifier), | |
121 content_settings_(content_settings), | |
122 name_(name) { | |
123 } | |
124 | |
125 UnauthorizedPluginInfoBarDelegate::~UnauthorizedPluginInfoBarDelegate() { | |
126 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Closed")); | |
127 } | |
128 | |
129 std::string UnauthorizedPluginInfoBarDelegate::GetLearnMoreURL() const { | |
130 return chrome::kBlockedPluginLearnMoreURL; | |
131 } | |
132 | |
133 base::string16 UnauthorizedPluginInfoBarDelegate::GetMessageText() const { | |
134 return l10n_util::GetStringFUTF16(IDS_PLUGIN_NOT_AUTHORIZED, name_); | |
135 } | |
136 | |
137 base::string16 UnauthorizedPluginInfoBarDelegate::GetButtonLabel( | |
138 InfoBarButton button) const { | |
139 return l10n_util::GetStringUTF16((button == BUTTON_OK) ? | |
140 IDS_PLUGIN_ENABLE_TEMPORARILY : IDS_PLUGIN_ENABLE_ALWAYS); | |
141 } | |
142 | |
143 bool UnauthorizedPluginInfoBarDelegate::Accept() { | |
144 content::RecordAction( | |
145 UserMetricsAction("BlockedPluginInfobar.AllowThisTime")); | |
146 LoadBlockedPlugins(); | |
147 return true; | |
148 } | |
149 | |
150 bool UnauthorizedPluginInfoBarDelegate::Cancel() { | |
151 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.AlwaysAllow")); | |
152 const GURL& url = InfoBarService::WebContentsFromInfoBar(infobar())->GetURL(); | |
153 content_settings_->AddExceptionForURL(url, url, CONTENT_SETTINGS_TYPE_PLUGINS, | |
154 CONTENT_SETTING_ALLOW); | |
155 LoadBlockedPlugins(); | |
156 return true; | |
157 } | |
158 | |
159 void UnauthorizedPluginInfoBarDelegate::InfoBarDismissed() { | |
160 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.Dismissed")); | |
161 } | |
162 | |
163 bool UnauthorizedPluginInfoBarDelegate::LinkClicked( | |
164 WindowOpenDisposition disposition) { | |
165 content::RecordAction(UserMetricsAction("BlockedPluginInfobar.LearnMore")); | |
166 return PluginInfoBarDelegate::LinkClicked(disposition); | |
167 } | |
168 | |
169 | |
170 #if defined(ENABLE_PLUGIN_INSTALLATION) | 84 #if defined(ENABLE_PLUGIN_INSTALLATION) |
171 | 85 |
172 // OutdatedPluginInfoBarDelegate ---------------------------------------------- | 86 // OutdatedPluginInfoBarDelegate ---------------------------------------------- |
173 | 87 |
174 void OutdatedPluginInfoBarDelegate::Create( | 88 void OutdatedPluginInfoBarDelegate::Create( |
175 InfoBarService* infobar_service, | 89 InfoBarService* infobar_service, |
176 PluginInstaller* installer, | 90 PluginInstaller* installer, |
177 scoped_ptr<PluginMetadata> plugin_metadata) { | 91 scoped_ptr<PluginMetadata> plugin_metadata) { |
178 // Copy the name out of |plugin_metadata| now, since the Pass() call below | 92 // Copy the name out of |plugin_metadata| now, since the Pass() call below |
179 // will make it impossible to get at. | 93 // will make it impossible to get at. |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
521 "https://support.google.com/chrome/?p=ib_redirect_to_desktop"), | 435 "https://support.google.com/chrome/?p=ib_redirect_to_desktop"), |
522 content::Referrer(), | 436 content::Referrer(), |
523 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, | 437 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, |
524 ui::PAGE_TRANSITION_LINK, false)); | 438 ui::PAGE_TRANSITION_LINK, false)); |
525 return false; | 439 return false; |
526 } | 440 } |
527 | 441 |
528 #endif // defined(OS_WIN) | 442 #endif // defined(OS_WIN) |
529 | 443 |
530 #endif // defined(ENABLE_PLUGIN_INSTALLATION) | 444 #endif // defined(ENABLE_PLUGIN_INSTALLATION) |
OLD | NEW |