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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_CONTEXT_MENU_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_CONTEXT_MENU_HANDLER_H_
8 #include "base/memory/weak_ptr.h"
9 #include "content/public/browser/web_ui_message_handler.h"
10 #include "ui/base/window_open_disposition.h"
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
{
22 virtual ~ContextMenuHandler();
24 // WebUIMessageHandler override and implementation.
25 virtual void RegisterMessages() OVERRIDE
;
27 // Invoked (by on_item_selected_callback_) when an item has been selected.
28 void OnItemSelected(int item_id
);
30 // Callback for setting whether incognito mode is disabled.
31 void GetIncognitoDisabled(const base::ListValue
* args
);
33 // Callback for the "showContextMenu" message.
34 void HandleShowContextMenu(const base::ListValue
* args
);
36 // Below are the message that are so far only triggered by the context menu.
37 // They should be moved to other files if they become used from other places.
39 // Callback for the "openInNewTab" message.
40 void HandleOpenInNewTab(const base::ListValue
* args
);
42 // Callback for the "openInIncognitoTab" message.
43 void HandleOpenInIncognitoTab(const base::ListValue
* args
);
46 // Opens the URL stored as the first value of |args| with the given
47 // |disposition|. The URL will always be opened as an AUTO_BOOKMARK.
48 void OpenUrl(const base::ListValue
* args
, WindowOpenDisposition disposition
);
50 // Used to get a WeakPtr to self on the UI thread.
51 base::WeakPtrFactory
<ContextMenuHandler
> weak_ptr_factory_
;
53 DISALLOW_COPY_AND_ASSIGN(ContextMenuHandler
);
56 #endif // CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_CONTEXT_MENU_HANDLER_H_