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

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: 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
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..bd5f6b1ef3a1d2219fca6899ec2f1b3504711984
--- /dev/null
+++ b/chrome/browser/ui/webui/ntp/android/context_menu_handler.h
@@ -0,0 +1,59 @@
+// 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/ref_counted.h"
+#include "content/public/browser/web_ui_message_handler.h"
+
+namespace base {
+class ListValue;
+}
+
+class OnContextMenuItemSelectedCallBack;
+
+// The handler for Javascript messages related to the context menus.
Evan Stade 2012/08/22 00:24:51 nit: JavaScript
Ted C 2012/08/22 20:55:50 Done.
+// Its the job of the actual HTML page to intercept the contextmenu event,
Evan Stade 2012/08/22 00:24:51 nit: It's
Ted C 2012/08/22 20:55:50 Done.
+// 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);
+
+ // Called by the OnContextMenuItemSelectedCallBack.
+ void SetOnItemSelectedCallback(OnContextMenuItemSelectedCallBack* callback);
+
+ private:
+ // Clears our reference to the callback and clears the callback's reference to
+ // us.
+ void ReleaseCallback();
+
+ // The callback invoked when an item is selected. That callback might outlive
+ // us, so we make sure to clear the reference the callback has to us when
+ // we are destroyed.
+ scoped_refptr<OnContextMenuItemSelectedCallBack> on_item_selected_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(ContextMenuHandler);
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_CONTEXT_MENU_HANDLER_H_

Powered by Google App Engine
This is Rietveld 408576698