| 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/weak_ptr.h" |
| 9 #include "content/public/browser/web_ui_message_handler.h" |
| 10 #include "webkit/glue/window_open_disposition.h" |
| 11 |
| 12 namespace base { |
| 13 class ListValue; |
| 14 } |
| 15 |
| 16 // The handler for JavaScript messages related to the context menus. |
| 17 // It's the job of the actual HTML page to intercept the contextmenu event, |
| 18 // disable it and show its own custom menu. |
| 19 class ContextMenuHandler : public content::WebUIMessageHandler { |
| 20 public: |
| 21 ContextMenuHandler(); |
| 22 virtual ~ContextMenuHandler(); |
| 23 |
| 24 // WebUIMessageHandler override and implementation. |
| 25 virtual void RegisterMessages() OVERRIDE; |
| 26 |
| 27 // Invoked (by on_item_selected_callback_) when an item has been selected. |
| 28 void OnItemSelected(int item_id); |
| 29 |
| 30 // Callback for the "showContextMenu" message. |
| 31 void HandleShowContextMenu(const base::ListValue* args); |
| 32 |
| 33 // Below are the message that are so far only triggered by the context menu. |
| 34 // They should be moved to other files if they become used from other places. |
| 35 |
| 36 // Callback for the "openInNewTab" message. |
| 37 void HandleOpenInNewTab(const base::ListValue* args); |
| 38 |
| 39 // Callback for the "openInIncognitoTab" message. |
| 40 void HandleOpenInIncognitoTab(const base::ListValue* args); |
| 41 |
| 42 private: |
| 43 // Opens the URL stored as the first value of |args| with the given |
| 44 // |disposition|. The URL will always be opened as an AUTO_BOOKMARK. |
| 45 void OpenUrl(const base::ListValue* args, WindowOpenDisposition disposition); |
| 46 |
| 47 // Used to get a WeakPtr to self on the UI thread. |
| 48 base::WeakPtrFactory<ContextMenuHandler> weak_ptr_factory_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(ContextMenuHandler); |
| 51 }; |
| 52 |
| 53 #endif // CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_CONTEXT_MENU_HANDLER_H_ |
| OLD | NEW |