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

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

Issue 7812020: Moved the following IPC messages used by the chrome NPAPI plugin installer out of content (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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
« no previous file with comments | « chrome/browser/plugin_observer.h ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/plugin_observer.h" 5 #include "chrome/browser/plugin_observer.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.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/google/google_util.h" 9 #include "chrome/browser/google/google_util.h"
10 #include "chrome/browser/plugin_installer_infobar_delegate.h"
11 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 11 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
13 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" 12 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
15 #include "chrome/common/render_messages.h" 14 #include "chrome/common/render_messages.h"
16 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
17 #include "content/browser/renderer_host/render_view_host.h" 16 #include "content/browser/renderer_host/render_view_host.h"
18 #include "content/browser/user_metrics.h" 17 #include "content/browser/user_metrics.h"
19 #include "content/common/view_messages.h" 18 #include "content/common/view_messages.h"
20 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
21 #include "grit/theme_resources_standard.h" 20 #include "grit/theme_resources_standard.h"
22 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
24 #include "webkit/plugins/npapi/default_plugin_shared.h"
25 #include "webkit/plugins/npapi/plugin_group.h" 23 #include "webkit/plugins/npapi/plugin_group.h"
26 #include "webkit/plugins/npapi/plugin_list.h" 24 #include "webkit/plugins/npapi/plugin_list.h"
27 #include "webkit/plugins/webplugininfo.h" 25 #include "webkit/plugins/webplugininfo.h"
28 26
29 namespace { 27 namespace {
30 28
31 // PluginInfoBarDelegate ------------------------------------------------------ 29 // PluginInfoBarDelegate ------------------------------------------------------
32 30
33 class PluginInfoBarDelegate : public ConfirmInfoBarDelegate { 31 class PluginInfoBarDelegate : public ConfirmInfoBarDelegate {
34 public: 32 public:
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 PluginObserver::PluginObserver(TabContentsWrapper* tab_contents) 285 PluginObserver::PluginObserver(TabContentsWrapper* tab_contents)
288 : TabContentsObserver(tab_contents->tab_contents()), 286 : TabContentsObserver(tab_contents->tab_contents()),
289 tab_contents_(tab_contents) { 287 tab_contents_(tab_contents) {
290 } 288 }
291 289
292 PluginObserver::~PluginObserver() { 290 PluginObserver::~PluginObserver() {
293 } 291 }
294 292
295 bool PluginObserver::OnMessageReceived(const IPC::Message& message) { 293 bool PluginObserver::OnMessageReceived(const IPC::Message& message) {
296 IPC_BEGIN_MESSAGE_MAP(PluginObserver, message) 294 IPC_BEGIN_MESSAGE_MAP(PluginObserver, message)
297 IPC_MESSAGE_HANDLER(ViewHostMsg_MissingPluginStatus, OnMissingPluginStatus)
298 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin) 295 IPC_MESSAGE_HANDLER(ViewHostMsg_CrashedPlugin, OnCrashedPlugin)
299 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin, 296 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_BlockedOutdatedPlugin,
300 OnBlockedOutdatedPlugin) 297 OnBlockedOutdatedPlugin)
301 IPC_MESSAGE_UNHANDLED(return false) 298 IPC_MESSAGE_UNHANDLED(return false)
302 IPC_END_MESSAGE_MAP() 299 IPC_END_MESSAGE_MAP()
303 300
304 return true; 301 return true;
305 } 302 }
306 303
307 PluginInstallerInfoBarDelegate* PluginObserver::GetPluginInstaller() {
308 if (plugin_installer_ == NULL)
309 plugin_installer_.reset(new PluginInstallerInfoBarDelegate(tab_contents()));
310 return plugin_installer_->AsPluginInstallerInfoBarDelegate();
311 }
312
313 void PluginObserver::OnMissingPluginStatus(int status) {
314 // TODO(PORT): pull in when plug-ins work
315 #if defined(OS_WIN)
316 if (status == webkit::npapi::default_plugin::MISSING_PLUGIN_AVAILABLE) {
317 tab_contents_->AddInfoBar(
318 new PluginInstallerInfoBarDelegate(tab_contents()));
319 return;
320 }
321
322 DCHECK_EQ(webkit::npapi::default_plugin::MISSING_PLUGIN_USER_STARTED_DOWNLOAD,
323 status);
324 for (size_t i = 0; i < tab_contents_->infobar_count(); ++i) {
325 InfoBarDelegate* delegate = tab_contents_->GetInfoBarDelegateAt(i);
326 if (delegate->AsPluginInstallerInfoBarDelegate() != NULL) {
327 tab_contents_->RemoveInfoBar(delegate);
328 return;
329 }
330 }
331 #endif
332 }
333
334 void PluginObserver::OnCrashedPlugin(const FilePath& plugin_path) { 304 void PluginObserver::OnCrashedPlugin(const FilePath& plugin_path) {
335 DCHECK(!plugin_path.value().empty()); 305 DCHECK(!plugin_path.value().empty());
336 306
337 string16 plugin_name = plugin_path.LossyDisplayName(); 307 string16 plugin_name = plugin_path.LossyDisplayName();
338 webkit::WebPluginInfo plugin_info; 308 webkit::WebPluginInfo plugin_info;
339 if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( 309 if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath(
340 plugin_path, &plugin_info) && 310 plugin_path, &plugin_info) &&
341 !plugin_info.name.empty()) { 311 !plugin_info.name.empty()) {
342 plugin_name = plugin_info.name; 312 plugin_name = plugin_info.name;
343 #if defined(OS_MACOSX) 313 #if defined(OS_MACOSX)
(...skipping 12 matching lines...) Expand all
356 true)); 326 true));
357 } 327 }
358 328
359 void PluginObserver::OnBlockedOutdatedPlugin(const string16& name, 329 void PluginObserver::OnBlockedOutdatedPlugin(const string16& name,
360 const GURL& update_url) { 330 const GURL& update_url) {
361 tab_contents_->AddInfoBar(update_url.is_empty() ? 331 tab_contents_->AddInfoBar(update_url.is_empty() ?
362 static_cast<InfoBarDelegate*>(new BlockedPluginInfoBarDelegate( 332 static_cast<InfoBarDelegate*>(new BlockedPluginInfoBarDelegate(
363 tab_contents(), name)) : 333 tab_contents(), name)) :
364 new OutdatedPluginInfoBarDelegate(tab_contents(), name, update_url)); 334 new OutdatedPluginInfoBarDelegate(tab_contents(), name, update_url));
365 } 335 }
OLDNEW
« no previous file with comments | « chrome/browser/plugin_observer.h ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698