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

Side by Side Diff: chrome/browser/plugins/plugin_infobar_delegates.cc

Issue 10967081: Remove dependency of plugin infobar delegates on PluginObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: dfgdsfgxc Created 8 years, 3 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/plugins/plugin_infobar_delegates.h" 5 #include "chrome/browser/plugins/plugin_infobar_delegates.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/api/infobars/infobar_service.h" 8 #include "chrome/browser/api/infobars/infobar_service.h"
9 #include "chrome/browser/content_settings/host_content_settings_map.h" 9 #include "chrome/browser/content_settings/host_content_settings_map.h"
10 #include "chrome/browser/google/google_util.h" 10 #include "chrome/browser/google/google_util.h"
11 #include "chrome/browser/lifetime/application_lifetime.h" 11 #include "chrome/browser/lifetime/application_lifetime.h"
12 #include "chrome/browser/plugins/plugin_observer.h"
13 #include "chrome/browser/ui/tab_contents/tab_contents.h" 12 #include "chrome/browser/ui/tab_contents/tab_contents.h"
14 #include "chrome/common/render_messages.h" 13 #include "chrome/common/render_messages.h"
15 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
16 #include "content/public/browser/render_view_host.h" 15 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/user_metrics.h" 16 #include "content/public/browser/user_metrics.h"
18 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
19 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
20 #include "grit/locale_settings.h" 19 #include "grit/locale_settings.h"
21 #include "grit/theme_resources.h" 20 #include "grit/theme_resources.h"
22 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 WindowOpenDisposition disposition) { 147 WindowOpenDisposition disposition) {
149 content::RecordAction( 148 content::RecordAction(
150 UserMetricsAction("BlockedPluginInfobar.LearnMore")); 149 UserMetricsAction("BlockedPluginInfobar.LearnMore"));
151 return PluginInfoBarDelegate::LinkClicked(disposition); 150 return PluginInfoBarDelegate::LinkClicked(disposition);
152 } 151 }
153 152
154 #if defined(ENABLE_PLUGIN_INSTALLATION) 153 #if defined(ENABLE_PLUGIN_INSTALLATION)
155 // OutdatedPluginInfoBarDelegate ---------------------------------------------- 154 // OutdatedPluginInfoBarDelegate ----------------------------------------------
156 155
157 InfoBarDelegate* OutdatedPluginInfoBarDelegate::Create( 156 InfoBarDelegate* OutdatedPluginInfoBarDelegate::Create(
158 PluginObserver* observer, 157 content::WebContents* web_contents,
159 PluginInstaller* installer) { 158 PluginInstaller* installer) {
160 string16 message; 159 string16 message;
161 switch (installer->state()) { 160 switch (installer->state()) {
162 case PluginInstaller::INSTALLER_STATE_IDLE: 161 case PluginInstaller::INSTALLER_STATE_IDLE:
163 message = l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT, 162 message = l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT,
164 installer->name()); 163 installer->name());
165 break; 164 break;
166 case PluginInstaller::INSTALLER_STATE_DOWNLOADING: 165 case PluginInstaller::INSTALLER_STATE_DOWNLOADING:
167 message = l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING, 166 message = l10n_util::GetStringFUTF16(IDS_PLUGIN_DOWNLOADING,
168 installer->name()); 167 installer->name());
169 break; 168 break;
170 } 169 }
171 return new OutdatedPluginInfoBarDelegate( 170 return new OutdatedPluginInfoBarDelegate(
172 observer, installer, message); 171 web_contents, installer, message);
173 } 172 }
174 173
175 OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate( 174 OutdatedPluginInfoBarDelegate::OutdatedPluginInfoBarDelegate(
176 PluginObserver* observer, 175 content::WebContents* web_contents,
177 PluginInstaller* installer, 176 PluginInstaller* installer,
178 const string16& message) 177 const string16& message)
179 : PluginInfoBarDelegate( 178 : PluginInfoBarDelegate(
180 InfoBarService::FromTabContents( 179 InfoBarService::FromTabContents(
181 TabContents::FromWebContents(observer->web_contents())), 180 TabContents::FromWebContents(web_contents)),
182 installer->name(), 181 installer->name(),
183 installer->identifier()), 182 installer->identifier()),
184 WeakPluginInstallerObserver(installer), 183 WeakPluginInstallerObserver(installer),
185 observer_(observer),
186 message_(message) { 184 message_(message) {
187 content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown")); 185 content::RecordAction(UserMetricsAction("OutdatedPluginInfobar.Shown"));
188 std::string name = UTF16ToUTF8(installer->name()); 186 std::string name = UTF16ToUTF8(installer->name());
189 if (name == webkit::npapi::PluginGroup::kJavaGroupName) 187 if (name == webkit::npapi::PluginGroup::kJavaGroupName)
190 content::RecordAction( 188 content::RecordAction(
191 UserMetricsAction("OutdatedPluginInfobar.Shown.Java")); 189 UserMetricsAction("OutdatedPluginInfobar.Shown.Java"));
192 else if (name == webkit::npapi::PluginGroup::kQuickTimeGroupName) 190 else if (name == webkit::npapi::PluginGroup::kQuickTimeGroupName)
193 content::RecordAction( 191 content::RecordAction(
194 UserMetricsAction("OutdatedPluginInfobar.Shown.QuickTime")); 192 UserMetricsAction("OutdatedPluginInfobar.Shown.QuickTime"));
195 else if (name == webkit::npapi::PluginGroup::kShockwaveGroupName) 193 else if (name == webkit::npapi::PluginGroup::kShockwaveGroupName)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 if (installer()->state() != PluginInstaller::INSTALLER_STATE_IDLE) { 227 if (installer()->state() != PluginInstaller::INSTALLER_STATE_IDLE) {
230 NOTREACHED(); 228 NOTREACHED();
231 return false; 229 return false;
232 } 230 }
233 231
234 content::WebContents* web_contents = owner()->GetWebContents(); 232 content::WebContents* web_contents = owner()->GetWebContents();
235 if (installer()->url_for_display()) { 233 if (installer()->url_for_display()) {
236 installer()->OpenDownloadURL(web_contents); 234 installer()->OpenDownloadURL(web_contents);
237 } else { 235 } else {
238 installer()->StartInstalling( 236 installer()->StartInstalling(
239 TabContents::FromWebContents(observer_->web_contents())); 237 TabContents::FromWebContents(web_contents));
240 } 238 }
241 return false; 239 return false;
242 } 240 }
243 241
244 bool OutdatedPluginInfoBarDelegate::Cancel() { 242 bool OutdatedPluginInfoBarDelegate::Cancel() {
245 content::RecordAction( 243 content::RecordAction(
246 UserMetricsAction("OutdatedPluginInfobar.AllowThisTime")); 244 UserMetricsAction("OutdatedPluginInfobar.AllowThisTime"));
247 LoadBlockedPlugins(); 245 LoadBlockedPlugins();
248 return true; 246 return true;
249 } 247 }
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 "https://support.google.com/chrome/?ib_display_in_desktop")); 483 "https://support.google.com/chrome/?ib_display_in_desktop"));
486 OpenURLParams params( 484 OpenURLParams params(
487 url, Referrer(), 485 url, Referrer(),
488 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition, 486 (disposition == CURRENT_TAB) ? NEW_FOREGROUND_TAB : disposition,
489 content::PAGE_TRANSITION_LINK, false); 487 content::PAGE_TRANSITION_LINK, false);
490 owner()->GetWebContents()->OpenURL(params); 488 owner()->GetWebContents()->OpenURL(params);
491 return false; 489 return false;
492 } 490 }
493 #endif // defined(OS_WIN) 491 #endif // defined(OS_WIN)
494 #endif // defined(ENABLE_PLUGIN_INSTALLATION) 492 #endif // defined(ENABLE_PLUGIN_INSTALLATION)
OLDNEW
« no previous file with comments | « chrome/browser/plugins/plugin_infobar_delegates.h ('k') | chrome/browser/plugins/plugin_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698