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"
16 class RenderViewContextMenuBase
;
19 class SimpleMenuModel
;
22 namespace extensions
{
24 class ChromeWebViewGuestDelegate
: public WebViewGuestDelegate
{
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
;
33 bool ShouldHandleFindRequestsForEmbedder() const override
;
35 WebViewGuest
* web_view_guest() const { return web_view_guest_
; }
38 content::WebContents
* guest_web_contents() const {
39 return web_view_guest()->web_contents();
42 void SetContextMenuPosition(const gfx::Point
& position
) override
;
44 // Returns the top level items (ignoring submenus) as Value.
45 static scoped_ptr
<base::ListValue
> MenuModelToValue(
46 const ui::SimpleMenuModel
& menu_model
);
48 void InjectChromeVoxIfNeeded(content::RenderViewHost
* render_view_host
);
50 #if defined(OS_CHROMEOS)
51 // Notification of a change in the state of an accessibility setting.
52 void OnAccessibilityStatusChanged(
53 const chromeos::AccessibilityStatusEventDetails
& details
);
56 // A counter to generate a unique request id for a context menu request.
57 // We only need the ids to be unique for a given WebViewGuest.
58 int pending_context_menu_request_id_
;
60 // Set to |true| if ChromeVox was already injected in main frame.
61 bool chromevox_injected_
;
63 // Holds the RenderViewContextMenuBase that has been built but yet to be
64 // shown. This is .reset() after ShowContextMenu().
65 scoped_ptr
<RenderViewContextMenuBase
> pending_menu_
;
67 #if defined(OS_CHROMEOS)
68 // Subscription to receive notifications on changes to a11y settings.
69 scoped_ptr
<chromeos::AccessibilityStatusSubscription
>
70 accessibility_subscription_
;
73 WebViewGuest
* const web_view_guest_
;
75 scoped_ptr
<gfx::Point
> context_menu_position_
;
77 // This is used to ensure pending tasks will not fire after this object is
79 base::WeakPtrFactory
<ChromeWebViewGuestDelegate
> weak_ptr_factory_
;
81 DISALLOW_COPY_AND_ASSIGN(ChromeWebViewGuestDelegate
);
84 } // namespace extensions
86 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_