1 // Copyright 2015 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_EXTENSION_VIEW_EXTENSION_VIEW_GUEST_H_
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_EXTENSION_VIEW_EXTENSION_VIEW_GUEST_H_
8 #include "base/macros.h"
9 #include "components/guest_view/browser/guest_view.h"
10 #include "extensions/browser/extension_function_dispatcher.h"
11 #include "extensions/browser/guest_view/extension_view/extension_view_guest_delegate.h"
18 namespace extensions
{
20 class ExtensionViewGuest
21 : public guest_view::GuestView
<ExtensionViewGuest
>,
22 public ExtensionFunctionDispatcher::Delegate
{
24 static const char Type
[];
25 static guest_view::GuestViewBase
* Create(
26 content::WebContents
* owner_web_contents
);
28 // Request navigating the guest to the provided |src| URL.
29 void NavigateGuest(const std::string
& src
, bool force_navigation
);
31 // GuestViewBase implementation.
32 bool CanRunInDetachedState() const override
;
33 void CreateWebContents(const base::DictionaryValue
& create_params
,
34 const WebContentsCreatedCallback
& callback
) override
;
35 void DidInitialize(const base::DictionaryValue
& create_params
) override
;
36 void DidAttachToEmbedder() override
;
37 const char* GetAPINamespace() const override
;
38 int GetTaskPrefix() const override
;
40 // content::WebContentsObserver implementation.
41 void DidCommitProvisionalLoadForFrame(
42 content::RenderFrameHost
* render_frame_host
,
44 ui::PageTransition transition_type
) override
;
45 void DidNavigateMainFrame(
46 const content::LoadCommittedDetails
& details
,
47 const content::FrameNavigateParams
& params
) override
;
48 bool OnMessageReceived(const IPC::Message
& message
) override
;
51 ExtensionViewGuest(content::WebContents
* owner_web_contents
);
52 ~ExtensionViewGuest() override
;
53 void OnRequest(const ExtensionHostMsg_Request_Params
& params
);
55 // Applies attributes to the extensionview.
56 void ApplyAttributes(const base::DictionaryValue
& params
);
58 scoped_ptr
<extensions::ExtensionFunctionDispatcher
>
59 extension_function_dispatcher_
;
60 scoped_ptr
<extensions::ExtensionViewGuestDelegate
>
61 extension_view_guest_delegate_
;
65 DISALLOW_COPY_AND_ASSIGN(ExtensionViewGuest
);
68 } // namespace extensions
70 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_EXTENSION_VIEW_EXTENSION_VIEW_GUEST_H_