summaryrefslogtreecommitdiffstats
path: root/chrome/browser/external_tab_container.cc
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-12 03:50:39 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-12 03:50:39 +0000
commite943d666020b7275d7fb70db625b47f69712d3b3 (patch)
treed56f0d56bb766103e8c51566f46197966a689cb1 /chrome/browser/external_tab_container.cc
parentd66688b2a167882dad56fcb6d963d918ed413052 (diff)
downloadchromium_src-e943d666020b7275d7fb70db625b47f69712d3b3.zip
chromium_src-e943d666020b7275d7fb70db625b47f69712d3b3.tar.gz
chromium_src-e943d666020b7275d7fb70db625b47f69712d3b3.tar.bz2
Allow external hosts to handle the context menu and thus be able to customize it.
Changes include 1. A HandleContextMenu function which can be implemented by a TabContentsDelegate. Currently only ExternalTabContainer implements this. 2. Removed InitMenu calls from the RenderViewContextMenu subclass constructors, We need the subclasses to be able to override individual AddMenuItem calls. The newly added RenderViewContextMenuExternalWin class derives from RenderViewContextMenuWin whose constructor calls InitMenu. This happens at a time when the vtable is not yet setup. To fix this we added an Init function to the RenderViewContextMenu base class which then calls a virtual function DoInit, which derived classes can override to perform specific initializations. 3. Added automation messages to send over context menu events to external hosts and back amit, please review everything. estade please review changes to tab_contents_view_gtk.cc and render_view_context_menu_gtk.cc. pinkerton please review changes to tab_contents_view_mac.mm and render_view_context_menu_mac.mm Review URL: http://codereview.chromium.org/119429 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18250 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/external_tab_container.cc')
-rw-r--r--chrome/browser/external_tab_container.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index 14ee79e..2dbf706 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -13,12 +13,15 @@
#include "chrome/browser/load_notification_details.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/provisional_load_details.h"
+#include "chrome/browser/tab_contents/render_view_context_menu_external_win.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/views/tab_contents/tab_contents_container.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/notification_service.h"
#include "chrome/test/automation/automation_messages.h"
+#include "grit/generated_resources.h"
+
static const wchar_t kWindowObjectKey[] = L"ChromeWindowObject";
// TODO(sanjeevr): The external_accel_table_ and external_accel_entry_count_
@@ -96,6 +99,9 @@ bool ExternalTabContainer::Init(Profile* profile,
SetParent(GetNativeView(), parent);
::ShowWindow(tab_contents_->GetNativeView(), SW_SHOWNA);
+
+ disabled_context_menu_ids_.push_back(
+ IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD);
return true;
}
@@ -253,6 +259,40 @@ bool ExternalTabContainer::TakeFocus(bool reverse) {
return true;
}
+bool ExternalTabContainer::HandleContextMenu(const ContextMenuParams& params) {
+ if (!automation_) {
+ NOTREACHED();
+ return false;
+ }
+
+ external_context_menu_.reset(
+ new RenderViewContextMenuExternalWin(tab_contents(),
+ params,
+ GetNativeView(),
+ disabled_context_menu_ids_));
+ external_context_menu_->Init();
+
+ POINT screen_pt = { params.x, params.y };
+ MapWindowPoints(GetNativeView(), HWND_DESKTOP, &screen_pt, 1);
+
+ automation_->Send(
+ new AutomationMsg_ForwardContextMenuToExternalHost(0, tab_handle_,
+ external_context_menu_->GetMenuHandle(), screen_pt.x, screen_pt.y,
+ external_context_menu_->GetTPMAlignFlags()));
+
+ return true;
+}
+
+bool ExternalTabContainer::ExecuteContextMenuCommand(int command) {
+ if (!external_context_menu_.get()) {
+ NOTREACHED();
+ return false;
+ }
+
+ external_context_menu_->ExecuteCommand(command);
+ return true;
+}
+
////////////////////////////////////////////////////////////////////////////////
// ExternalTabContainer, NotificationObserver implementation: