Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_CONTEXT_MENU_HANDLER_H_ | |
| 6 #define CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_CONTEXT_MENU_HANDLER_H_ | |
| 7 | |
| 8 #include "base/memory/ref_counted.h" | |
| 9 #include "content/public/browser/web_ui_message_handler.h" | |
| 10 | |
| 11 namespace base { | |
| 12 class ListValue; | |
| 13 } | |
| 14 | |
| 15 class OnContextMenuItemSelectedCallBack; | |
| 16 | |
| 17 // 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.
| |
| 18 // 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.
| |
| 19 // disable it and show its own custom menu. | |
| 20 class ContextMenuHandler : public content::WebUIMessageHandler { | |
| 21 public: | |
| 22 ContextMenuHandler(); | |
| 23 virtual ~ContextMenuHandler(); | |
| 24 | |
| 25 // WebUIMessageHandler override and implementation. | |
| 26 virtual void RegisterMessages() OVERRIDE; | |
| 27 | |
| 28 // Invoked (by on_item_selected_callback_) when an item has been selected. | |
| 29 void OnItemSelected(int item_id); | |
| 30 | |
| 31 // Callback for the "showContextMenu" message. | |
| 32 void HandleShowContextMenu(const base::ListValue* args); | |
| 33 | |
| 34 // Below are the message that are so far only triggered by the context menu. | |
| 35 // They should be moved to other files if they become used from other places. | |
| 36 | |
| 37 // Callback for the "openInNewTab" message. | |
| 38 void HandleOpenInNewTab(const base::ListValue* args); | |
| 39 | |
| 40 // Callback for the "openInIncognitoTab" message. | |
| 41 void HandleOpenInIncognitoTab(const base::ListValue* args); | |
| 42 | |
| 43 // Called by the OnContextMenuItemSelectedCallBack. | |
| 44 void SetOnItemSelectedCallback(OnContextMenuItemSelectedCallBack* callback); | |
| 45 | |
| 46 private: | |
| 47 // Clears our reference to the callback and clears the callback's reference to | |
| 48 // us. | |
| 49 void ReleaseCallback(); | |
| 50 | |
| 51 // The callback invoked when an item is selected. That callback might outlive | |
| 52 // us, so we make sure to clear the reference the callback has to us when | |
| 53 // we are destroyed. | |
| 54 scoped_refptr<OnContextMenuItemSelectedCallBack> on_item_selected_callback_; | |
| 55 | |
| 56 DISALLOW_COPY_AND_ASSIGN(ContextMenuHandler); | |
| 57 }; | |
| 58 | |
| 59 #endif // CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_CONTEXT_MENU_HANDLER_H_ | |
| OLD | NEW |