summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/renderer/blocked_plugin.cc37
-rw-r--r--chrome/renderer/blocked_plugin.h25
-rw-r--r--chrome/renderer/custom_menu_listener.h22
-rw-r--r--chrome/renderer/render_view.cc32
-rw-r--r--chrome/renderer/render_view.h20
5 files changed, 41 insertions, 95 deletions
diff --git a/chrome/renderer/blocked_plugin.cc b/chrome/renderer/blocked_plugin.cc
index 0a470f2..a1c9aff 100644
--- a/chrome/renderer/blocked_plugin.cc
+++ b/chrome/renderer/blocked_plugin.cc
@@ -9,6 +9,7 @@
#include "base/string_piece.h"
#include "base/values.h"
#include "chrome/common/jstemplate_builder.h"
+#include "chrome/common/render_messages.h"
#include "chrome/renderer/render_view.h"
#include "grit/generated_resources.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
@@ -49,9 +50,10 @@ BlockedPlugin::BlockedPlugin(RenderView* render_view,
const WebPreferences& preferences,
int template_id,
const string16& message)
- : render_view_(render_view),
+ : RenderViewObserver(render_view),
frame_(frame),
- plugin_params_(params) {
+ plugin_params_(params),
+ custom_menu_showing_(false) {
const base::StringPiece template_html(
ResourceBundle::GetSharedInstance().GetRawDataResource(template_id));
@@ -71,13 +73,9 @@ BlockedPlugin::BlockedPlugin(RenderView* render_view,
preferences,
html_data,
GURL(kBlockedPluginDataURL));
-
- render_view_->RegisterBlockedPlugin(this);
}
BlockedPlugin::~BlockedPlugin() {
- render_view_->CustomMenuListenerDestroyed(this);
- render_view_->UnregisterBlockedPlugin(this);
}
void BlockedPlugin::BindWebFrame(WebFrame* frame) {
@@ -118,11 +116,29 @@ void BlockedPlugin::ShowContextMenu(const WebKit::WebMouseEvent& event) {
menu_data.customItems.swap(custom_items);
menu_data.mousePosition = WebPoint(event.windowX, event.windowY);
- render_view_->showContextMenu(NULL, menu_data);
- render_view_->CustomMenuListenerInstall(this);
+ render_view()->showContextMenu(NULL, menu_data);
+ custom_menu_showing_ = true;
+}
+
+bool BlockedPlugin::OnMessageReceived(const IPC::Message& message) {
+ if (custom_menu_showing_ &&
+ message.type() == ViewMsg_CustomContextMenuAction::ID) {
+ ViewMsg_CustomContextMenuAction::Dispatch(
+ &message, this, this, &BlockedPlugin::OnMenuItemSelected);
+ return true;
+ }
+
+ // Don't want to swallow these messages.
+ if (message.type() == ViewMsg_LoadBlockedPlugins::ID) {
+ LoadPlugin();
+ } else if (message.type() == ViewMsg_ContextMenuClosed::ID) {
+ custom_menu_showing_ = false;
+ }
+
+ return false;
}
-void BlockedPlugin::MenuItemSelected(unsigned id) {
+void BlockedPlugin::OnMenuItemSelected(unsigned id) {
if (id == kMenuActionLoad) {
LoadPlugin();
} else if (id == kMenuActionRemove) {
@@ -136,8 +152,7 @@ void BlockedPlugin::LoadPlugin() {
CHECK(plugin_);
WebPluginContainer* container = plugin_->container();
WebPlugin* new_plugin =
- render_view_->CreatePluginNoCheck(frame_,
- plugin_params_);
+ render_view()->CreatePluginNoCheck(frame_, plugin_params_);
if (new_plugin && new_plugin->initialize(container)) {
container->setPlugin(new_plugin);
container->invalidate();
diff --git a/chrome/renderer/blocked_plugin.h b/chrome/renderer/blocked_plugin.h
index defe925..ad1c27e 100644
--- a/chrome/renderer/blocked_plugin.h
+++ b/chrome/renderer/blocked_plugin.h
@@ -6,14 +6,12 @@
#define CHROME_RENDERER_BLOCKED_PLUGIN_H_
#pragma once
-#include "chrome/renderer/custom_menu_listener.h"
+#include "chrome/renderer/render_view_observer.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
#include "webkit/glue/cpp_bound_class.h"
#include "webkit/plugins/npapi/webview_plugin.h"
class GURL;
-class RenderView;
-
namespace webkit {
namespace npapi {
@@ -21,9 +19,9 @@ class PluginGroup;
}
}
-class BlockedPlugin : public CppBoundClass,
- public webkit::npapi::WebViewPlugin::Delegate,
- public CustomMenuListener {
+class BlockedPlugin : public RenderViewObserver,
+ public CppBoundClass,
+ public webkit::npapi::WebViewPlugin::Delegate {
public:
BlockedPlugin(RenderView* render_view,
WebKit::WebFrame* frame,
@@ -40,15 +38,17 @@ class BlockedPlugin : public CppBoundClass,
virtual void WillDestroyPlugin();
virtual void ShowContextMenu(const WebKit::WebMouseEvent&);
- // CustomMenuListener methods:
- virtual void MenuItemSelected(unsigned id);
+ private:
+ virtual ~BlockedPlugin();
+
+ // RenderViewObserver methods:
+ virtual bool OnMessageReceived(const IPC::Message& message);
+
+ void OnMenuItemSelected(unsigned id);
// Load the blocked plugin.
void LoadPlugin();
- private:
- virtual ~BlockedPlugin();
-
// Javascript callbacks:
// Load the blocked plugin by calling LoadPlugin().
// Takes no arguments, and returns nothing.
@@ -61,12 +61,13 @@ class BlockedPlugin : public CppBoundClass,
// Hide the blocked plugin.
void HidePlugin();
- RenderView* render_view_;
WebKit::WebFrame* frame_;
WebKit::WebPluginParams plugin_params_;
webkit::npapi::WebViewPlugin* plugin_;
// The name of the plugin that was blocked.
string16 name_;
+ // True iff we're showing a custom menu.
+ bool custom_menu_showing_;
};
#endif // CHROME_RENDERER_BLOCKED_PLUGIN_H_
diff --git a/chrome/renderer/custom_menu_listener.h b/chrome/renderer/custom_menu_listener.h
deleted file mode 100644
index 5c61358..0000000
--- a/chrome/renderer/custom_menu_listener.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_RENDERER_CUSTOM_MENU_LISTENER_H_
-#define CHROME_RENDERER_CUSTOM_MENU_LISTENER_H_
-#pragma once
-
-// CustomMenuListener is an interface that can be registered with RenderView by
-// classes that wish to use custom context menus. There is a single callback,
-// MenuItemSelected(), which fires when a custom menu item was chosen by the
-// user.
-class CustomMenuListener {
- public:
- virtual void MenuItemSelected(unsigned id) = 0;
-
- protected:
- virtual ~CustomMenuListener() {}
-};
-
-#endif // CHROME_RENDERER_CUSTOM_MENU_LISTENER_H_
-
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 1b68b03..9b71058 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -565,8 +565,7 @@ RenderView::RenderView(RenderThreadBase* render_thread,
device_orientation_dispatcher_(NULL),
accessibility_ack_pending_(false),
pending_app_icon_requests_(0),
- session_storage_namespace_id_(session_storage_namespace_id),
- custom_menu_listener_(NULL) {
+ session_storage_namespace_id_(session_storage_namespace_id) {
#if defined(OS_MACOSX)
// On Mac, the select popups are rendered by the browser.
// Note that we don't do this in RenderMain otherwise this would not be called
@@ -931,15 +930,6 @@ WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame,
return CreateNPAPIPlugin(frame, params, info.path, mime_type);
}
-void RenderView::CustomMenuListenerInstall(CustomMenuListener* listening) {
- custom_menu_listener_ = listening;
-}
-
-void RenderView::CustomMenuListenerDestroyed(CustomMenuListener* dead) {
- if (custom_menu_listener_ == dead)
- custom_menu_listener_ = NULL;
-}
-
void RenderView::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) {
plugin_delegates_.insert(delegate);
// If the renderer is visible, set initial visibility and focus state.
@@ -960,14 +950,6 @@ void RenderView::UnregisterPluginDelegate(WebPluginDelegateProxy* delegate) {
plugin_delegates_.erase(delegate);
}
-void RenderView::RegisterBlockedPlugin(BlockedPlugin* blocked_plugin) {
- blocked_plugins_.insert(blocked_plugin);
-}
-
-void RenderView::UnregisterBlockedPlugin(BlockedPlugin* blocked_plugin) {
- blocked_plugins_.erase(blocked_plugin);
-}
-
bool RenderView::OnMessageReceived(const IPC::Message& message) {
WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL;
if (main_frame)
@@ -1043,7 +1025,6 @@ bool RenderView::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences)
IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL)
IPC_MESSAGE_HANDLER(ViewMsg_InstallMissingPlugin, OnInstallMissingPlugin)
- IPC_MESSAGE_HANDLER(ViewMsg_LoadBlockedPlugins, OnLoadBlockedPlugins)
IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse)
IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage,
@@ -2448,7 +2429,6 @@ bool RenderView::runModalBeforeUnloadDialog(
void RenderView::showContextMenu(
WebFrame* frame, const WebContextMenuData& data) {
- custom_menu_listener_ = NULL;
ContextMenuParams params = ContextMenuParams(data);
if (!params.misspelled_word.empty() && RenderThread::current()) {
int misspelled_offset, misspelled_length;
@@ -4678,10 +4658,7 @@ void RenderView::OnSetAltErrorPageURL(const GURL& url) {
}
void RenderView::OnCustomContextMenuAction(unsigned action) {
- if (custom_menu_listener_)
- custom_menu_listener_->MenuItemSelected(action);
- else
- webview()->performCustomContextMenuAction(action);
+ webview()->performCustomContextMenuAction(action);
}
void RenderView::OnTranslatePage(int page_id,
@@ -4702,11 +4679,6 @@ void RenderView::OnInstallMissingPlugin() {
first_default_plugin_->InstallMissingPlugin();
}
-void RenderView::OnLoadBlockedPlugins() {
- while (!blocked_plugins_.empty())
- (*blocked_plugins_.begin())->LoadPlugin();
-}
-
void RenderView::OnFileChooserResponse(const std::vector<FilePath>& paths) {
// This could happen if we navigated to a different page before the user
// closed the chooser.
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 388854d..dfbcf7d 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -57,7 +57,6 @@
class AudioMessageFilter;
class BlockedPlugin;
-class CustomMenuListener;
class DictionaryValue;
class DeviceOrientationDispatcher;
class DevToolsAgent;
@@ -352,15 +351,6 @@ class RenderView : public RenderWidget,
// only by gears and this function can be deleted when we remove gears.
uint32 GetCPBrowsingContext();
- // Handles registering and deregistering customer handlers for custom
- // context menu events.
- // To install a custom context menu, call showContextMenu() with your
- // custom entries, followed immediately by CustomMenuListenerInstall() to
- // register a listener for when a custom menu item is selected. Note that
- // subsequent calls to showContextMenu() will clear the custom listener.
- void CustomMenuListenerInstall(CustomMenuListener* listening);
- void CustomMenuListenerDestroyed(CustomMenuListener* dead);
-
#if defined(OS_MACOSX)
// Enables/disabled plugin IME for the given plugin.
void SetPluginImeEnabled(bool enabled, int plugin_id);
@@ -387,9 +377,6 @@ class RenderView : public RenderWidget,
void RegisterPluginDelegate(WebPluginDelegateProxy* delegate);
void UnregisterPluginDelegate(WebPluginDelegateProxy* delegate);
- void RegisterBlockedPlugin(BlockedPlugin* blocked_plugin);
- void UnregisterBlockedPlugin(BlockedPlugin* blocked_plugin);
-
// IPC::Channel::Listener implementation -------------------------------------
virtual bool OnMessageReceived(const IPC::Message& msg);
@@ -892,7 +879,6 @@ class RenderView : public RenderWidget,
const std::string& origin,
const std::string& target);
void OnInstallMissingPlugin();
- void OnLoadBlockedPlugins();
void OnMediaPlayerActionAt(const gfx::Point& location,
const WebKit::WebMediaPlayerAction& action);
void OnMoveOrResizeStarted();
@@ -1332,9 +1318,6 @@ class RenderView : public RenderWidget,
// destroyed yet. Pepper v2 plugins are tracked by the pepper_delegate_.
std::set<WebPluginDelegatePepper*> current_oldstyle_pepper_plugins_;
- // A list of all BlockedPlugins so they can all be loaded if needed.
- std::set<BlockedPlugin*> blocked_plugins_;
-
// Helper objects ------------------------------------------------------------
ScopedRunnableMethodFactory<RenderView> page_info_method_factory_;
@@ -1465,9 +1448,6 @@ class RenderView : public RenderWidget,
// The external popup for the currently showing select popup.
scoped_ptr<ExternalPopupMenu> external_popup_menu_;
- // The custom menu event listener, if any.
- CustomMenuListener* custom_menu_listener_;
-
// The node that the context menu was pressed over.
WebKit::WebNode context_menu_node_;