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_find_helper.h"
10 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
11 #include "extensions/browser/guest_view/web_view/web_view_guest_delegate.h"
13 #if defined(OS_CHROMEOS)
14 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h"
17 class RenderViewContextMenu
;
20 class SimpleMenuModel
;
23 class ChromeWebViewGuestDelegate
: public extensions::WebViewGuestDelegate
{
25 explicit ChromeWebViewGuestDelegate(
26 extensions::WebViewGuest
* web_view_guest
);
27 virtual ~ChromeWebViewGuestDelegate();
29 // WebViewGuestDelegate implementation.
31 const base::string16
& search_text
,
32 const blink::WebFindOptions
& options
,
33 extensions::WebViewInternalFindFunction
* find_function
)
35 virtual void FindReply(content::WebContents
* source
,
37 int number_of_matches
,
38 const gfx::Rect
& selection_rect
,
39 int active_match_ordinal
,
40 bool final_update
) OVERRIDE
;
41 virtual double GetZoom() OVERRIDE
;
42 virtual bool HandleContextMenu(
43 const content::ContextMenuParams
& params
) OVERRIDE
;
44 virtual void OnAttachWebViewHelpers(content::WebContents
* contents
) OVERRIDE
;
45 virtual void OnEmbedderDestroyed() OVERRIDE
;
46 virtual void OnDidCommitProvisionalLoadForFrame(bool is_main_frame
) OVERRIDE
;
47 virtual void OnDidInitialize() OVERRIDE
;
48 virtual void OnDocumentLoadedInFrame(
49 content::RenderFrameHost
* render_frame_host
) OVERRIDE
;
50 virtual void OnGuestDestroyed() OVERRIDE
;
51 virtual void OnRenderProcessGone() OVERRIDE
;
52 virtual void OnSetZoom(double zoom_factor
) OVERRIDE
;
53 virtual void OnShowContextMenu(
55 const MenuItemVector
* items
) OVERRIDE
;
56 virtual void StopFinding(content::StopFindAction
) OVERRIDE
;
59 friend void extensions::WebViewFindHelper::DispatchFindUpdateEvent(
63 content::WebContents
* guest_web_contents() const {
64 return web_view_guest()->web_contents();
67 // Returns the top level items (ignoring submenus) as Value.
68 static scoped_ptr
<base::ListValue
> MenuModelToValue(
69 const ui::SimpleMenuModel
& menu_model
);
71 void InjectChromeVoxIfNeeded(content::RenderViewHost
* render_view_host
);
73 #if defined(OS_CHROMEOS)
74 // Notification of a change in the state of an accessibility setting.
75 void OnAccessibilityStatusChanged(
76 const chromeos::AccessibilityStatusEventDetails
& details
);
79 // Handles find requests and replies for the webview find API.
80 extensions::WebViewFindHelper find_helper_
;
82 // A counter to generate a unique request id for a context menu request.
83 // We only need the ids to be unique for a given WebViewGuest.
84 int pending_context_menu_request_id_
;
86 // Set to |true| if ChromeVox was already injected in main frame.
87 bool chromevox_injected_
;
89 // Stores the current zoom factor.
90 double current_zoom_factor_
;
92 // Holds the RenderViewContextMenu that has been built but yet to be
93 // shown. This is .Reset() after ShowContextMenu().
94 scoped_ptr
<RenderViewContextMenu
> pending_menu_
;
96 #if defined(OS_CHROMEOS)
97 // Subscription to receive notifications on changes to a11y settings.
98 scoped_ptr
<chromeos::AccessibilityStatusSubscription
>
99 accessibility_subscription_
;
102 DISALLOW_COPY_AND_ASSIGN(ChromeWebViewGuestDelegate
);
105 #endif // CHROME_BROWSER_GUEST_VIEW_WEB_VIEW_CHROME_WEB_VIEW_GUEST_DELEGATE_H_