- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / ntp / android / context_menu_handler.h
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 "ui/base/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 setting whether incognito mode is disabled.
31   void GetIncognitoDisabled(const base::ListValue* args);
32
33   // Callback for the "showContextMenu" message.
34   void HandleShowContextMenu(const base::ListValue* args);
35
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.
38
39   // Callback for the "openInNewTab" message.
40   void HandleOpenInNewTab(const base::ListValue* args);
41
42   // Callback for the "openInIncognitoTab" message.
43   void HandleOpenInIncognitoTab(const base::ListValue* args);
44
45  private:
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);
49
50   // Used to get a WeakPtr to self on the UI thread.
51   base::WeakPtrFactory<ContextMenuHandler> weak_ptr_factory_;
52
53   DISALLOW_COPY_AND_ASSIGN(ContextMenuHandler);
54 };
55
56 #endif  // CHROME_BROWSER_UI_WEBUI_NTP_ANDROID_CONTEXT_MENU_HANDLER_H_