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

Unified Diff: chrome/browser/ui/webui/ntp/android/context_menu_handler.h

Issue 10861042: Add Android's context menu handler used on the NTP. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Resolve Evan's comments. Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | chrome/browser/ui/webui/ntp/android/context_menu_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/ntp/android/context_menu_handler.h
diff --git a/chrome/browser/ui/webui/ntp/android/context_menu_handler.h b/chrome/browser/ui/webui/ntp/android/context_menu_handler.h
new file mode 100644
index 0000000000000000000000000000000000000000..2075cdcafb9918a6162d7bd666f0f7881261f578
--- /dev/null
+++ b/chrome/browser/ui/webui/ntp/android/context_menu_handler.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2012 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_BROWSER_UI_WEBUI_NTP_ANDROID_CONTEXT_MENU_HANDLER_H_
+#define CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_CONTEXT_MENU_HANDLER_H_
+
+#include "base/memory/weak_ptr.h"
+#include "content/public/browser/web_ui_message_handler.h"
+#include "webkit/glue/window_open_disposition.h"
+
+namespace base {
+class ListValue;
+}
+
+// The handler for JavaScript messages related to the context menus.
+// It's the job of the actual HTML page to intercept the contextmenu event,
+// disable it and show its own custom menu.
+class ContextMenuHandler : public content::WebUIMessageHandler {
+ public:
+ ContextMenuHandler();
+ virtual ~ContextMenuHandler();
+
+ // WebUIMessageHandler override and implementation.
+ virtual void RegisterMessages() OVERRIDE;
+
+ // Invoked (by on_item_selected_callback_) when an item has been selected.
+ void OnItemSelected(int item_id);
+
+ // Callback for the "showContextMenu" message.
+ void HandleShowContextMenu(const base::ListValue* args);
+
+ // Below are the message that are so far only triggered by the context menu.
+ // They should be moved to other files if they become used from other places.
+
+ // Callback for the "openInNewTab" message.
+ void HandleOpenInNewTab(const base::ListValue* args);
+
+ // Callback for the "openInIncognitoTab" message.
+ void HandleOpenInIncognitoTab(const base::ListValue* args);
+
+ private:
+ // Opens the URL stored as the first value of |args| with the given
+ // |disposition|. The URL will always be opened as an AUTO_BOOKMARK.
+ void OpenUrl(const base::ListValue* args, WindowOpenDisposition disposition);
+
+ // Used to get a WeakPtr to self on the UI thread.
+ base::WeakPtrFactory<ContextMenuHandler> weak_ptr_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ContextMenuHandler);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_CONTEXT_MENU_HANDLER_H_
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | chrome/browser/ui/webui/ntp/android/context_menu_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698