Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / guest_view / web_view / chrome_web_view_guest_delegate.h
blob1392f3b4528cbf2ac816ebf2e6f331c4b630c107
1 // Copyright 2014 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_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_
6 #define CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_
8 #include "chrome/browser/extensions/api/web_view/chrome_web_view_internal_api.h"
9 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
10 #include "extensions/browser/guest_view/web_view/web_view_guest_delegate.h"
12 #if defined(OS_CHROMEOS)
13 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
14 #endif
16 class RenderViewContextMenuBase;
18 namespace ui {
19 class SimpleMenuModel;
20 } // namespace ui
22 namespace extensions {
24 class ChromeWebViewGuestDelegate : public WebViewGuestDelegate {
25 public :
26 explicit ChromeWebViewGuestDelegate(WebViewGuest* web_view_guest);
27 ~ChromeWebViewGuestDelegate() override;
29 // WebViewGuestDelegate implementation.
30 bool HandleContextMenu(const content::ContextMenuParams& params) override;
31 void OnDidInitialize() override;
32 void OnShowContextMenu(int request_id, const MenuItemVector* items) override;
34 WebViewGuest* web_view_guest() const { return web_view_guest_; }
36 private:
37 content::WebContents* guest_web_contents() const {
38 return web_view_guest()->web_contents();
41 // Returns the top level items (ignoring submenus) as Value.
42 static scoped_ptr<base::ListValue> MenuModelToValue(
43 const ui::SimpleMenuModel& menu_model);
45 void InjectChromeVoxIfNeeded(content::RenderViewHost* render_view_host);
47 #if defined(OS_CHROMEOS)
48 // Notification of a change in the state of an accessibility setting.
49 void OnAccessibilityStatusChanged(
50 const chromeos::AccessibilityStatusEventDetails& details);
51 #endif
53 // A counter to generate a unique request id for a context menu request.
54 // We only need the ids to be unique for a given WebViewGuest.
55 int pending_context_menu_request_id_;
57 // Set to |true| if ChromeVox was already injected in main frame.
58 bool chromevox_injected_;
60 // Holds the RenderViewContextMenuBase that has been built but yet to be
61 // shown. This is .reset() after ShowContextMenu().
62 scoped_ptr<RenderViewContextMenuBase> pending_menu_;
64 #if defined(OS_CHROMEOS)
65 // Subscription to receive notifications on changes to a11y settings.
66 scoped_ptr<chromeos::AccessibilityStatusSubscription>
67 accessibility_subscription_;
68 #endif
70 WebViewGuest* const web_view_guest_;
72 // This is used to ensure pending tasks will not fire after this object is
73 // destroyed.
74 base::WeakPtrFactory<ChromeWebViewGuestDelegate> weak_ptr_factory_;
76 DISALLOW_COPY_AND_ASSIGN(ChromeWebViewGuestDelegate);
79 } // namespace extensions
81 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_