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 EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_DELEGATE_H_
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_DELEGATE_H_
8 #include "extensions/browser/guest_view/guest_view_base.h"
11 struct WebFindOptions
;
17 } // namespace content
19 namespace extensions
{
22 class WebViewInternalFindFunction
;
25 namespace web_view_internal
{
27 struct ContextMenuItem
;
28 } // namespace web_view_internal
31 // A delegate class of WebViewGuest that are not a part of chrome.
32 class WebViewGuestDelegate
{
34 explicit WebViewGuestDelegate(WebViewGuest
* web_view_guest
);
35 virtual ~WebViewGuestDelegate();
37 typedef std::vector
<linked_ptr
<api::web_view_internal::ContextMenuItem
> >
40 // Begin or continue a find request.
42 const base::string16
& search_text
,
43 const blink::WebFindOptions
& options
,
44 WebViewInternalFindFunction
* find_function
) = 0;
46 // Result of string search in the page.
47 virtual void FindReply(content::WebContents
* source
,
49 int number_of_matches
,
50 const gfx::Rect
& selection_rect
,
51 int active_match_ordinal
,
52 bool final_update
) = 0;
54 // Returns the current zoom factor.
55 virtual double GetZoom() = 0;
57 // Called when context menu operation was handled.
58 virtual bool HandleContextMenu(const content::ContextMenuParams
& params
) = 0;
60 // Called to attach helpers just after additional initialization is performed.
61 virtual void OnAttachWebViewHelpers(content::WebContents
* contents
) = 0;
63 // Called to perform some cleanup prior to destruction.
64 virtual void OnEmbedderDestroyed() = 0;
66 // Called when the guest WebContents commits a provisional load in any frame.
67 virtual void OnDidCommitProvisionalLoadForFrame(bool is_main_frame
) = 0;
69 // Called just after additional initialization is performed.
70 virtual void OnDidInitialize() = 0;
72 virtual void OnDocumentLoadedInFrame(
73 content::RenderFrameHost
* render_frame_host
) = 0;
75 // Called immediately after the guest WebContents has been destroyed.
76 virtual void OnGuestDestroyed() = 0;
78 // Called to cancel all find sessions in progress.
79 virtual void OnRenderProcessGone() = 0;
81 // Called when to set the zoom factor.
82 virtual void OnSetZoom(double zoom_factor
) = 0;
84 // Shows the context menu for the guest.
85 // |items| acts as a filter. This restricts the current context's default
86 // menu items to contain only the items from |items|.
87 // |items| == NULL means no filtering will be applied.
88 virtual void OnShowContextMenu(
90 const MenuItemVector
* items
) = 0;
92 // Conclude a find request to clear highlighting.
93 virtual void StopFinding(content::StopFindAction
) = 0;
95 WebViewGuest
* web_view_guest() const { return web_view_guest_
; }
98 WebViewGuest
* const web_view_guest_
;
100 DISALLOW_COPY_AND_ASSIGN(WebViewGuestDelegate
);
103 } // namespace extensions
105 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_DELEGATE_H_