Chromecast on Android buildfix: don't try to create a RendererFactory.
[chromium-blink-merge.git] / extensions / browser / guest_view / app_view / app_view_guest.h
blobf19e4790df12f91ad7349ae5aba2201b28508deb
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_APP_VIEW_APP_VIEW_GUEST_H_
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_
8 #include "base/id_map.h"
9 #include "extensions/browser/extension_function_dispatcher.h"
10 #include "extensions/browser/guest_view/app_view/app_view_guest_delegate.h"
11 #include "extensions/browser/guest_view/guest_view.h"
13 namespace extensions {
14 class Extension;
15 class ExtensionHost;
17 // An AppViewGuest provides the browser-side implementation of <appview> API.
18 // AppViewGuest is created on attachment. That is, when a guest WebContents is
19 // associated with a particular embedder WebContents. This happens on calls to
20 // the connect API.
21 class AppViewGuest : public GuestView<AppViewGuest>,
22 public ExtensionFunctionDispatcher::Delegate {
23 public:
24 static const char Type[];
26 // Completes the creation of a WebContents associated with the provided
27 // |guest_extensions_id|.
28 static bool CompletePendingRequest(
29 content::BrowserContext* browser_context,
30 const GURL& url,
31 int guest_instance_id,
32 const std::string& guest_extension_id);
34 static GuestViewBase* Create(content::BrowserContext* browser_context,
35 content::WebContents* owner_web_contents,
36 int guest_instance_id);
38 // ExtensionFunctionDispatcher::Delegate implementation.
39 WindowController* GetExtensionWindowController() const override;
40 content::WebContents* GetAssociatedWebContents() const override;
42 // content::WebContentsObserver implementation.
43 bool OnMessageReceived(const IPC::Message& message) override;
45 // content::WebContentsDelegate implementation.
46 bool HandleContextMenu(const content::ContextMenuParams& params) override;
47 void RequestMediaAccessPermission(
48 content::WebContents* web_contents,
49 const content::MediaStreamRequest& request,
50 const content::MediaResponseCallback& callback) override;
51 bool CheckMediaAccessPermission(content::WebContents* web_contents,
52 const GURL& security_origin,
53 content::MediaStreamType type) override;
55 // GuestViewBase implementation.
56 const char* GetAPINamespace() const override;
57 int GetTaskPrefix() const override;
58 void CreateWebContents(const base::DictionaryValue& create_params,
59 const WebContentsCreatedCallback& callback) override;
60 void DidAttachToEmbedder() override;
61 void DidInitialize() override;
63 // Sets the AppDelegate for this guest.
64 void SetAppDelegateForTest(AppDelegate* delegate);
66 private:
67 AppViewGuest(content::BrowserContext* browser_context,
68 content::WebContents* owner_web_contents,
69 int guest_instance_id);
71 ~AppViewGuest() override;
73 void OnRequest(const ExtensionHostMsg_Request_Params& params);
75 void CompleteCreateWebContents(const GURL& url,
76 const Extension* guest_extension,
77 const WebContentsCreatedCallback& callback);
79 void LaunchAppAndFireEvent(scoped_ptr<base::DictionaryValue> data,
80 const WebContentsCreatedCallback& callback,
81 ExtensionHost* extension_host);
83 GURL url_;
84 std::string guest_extension_id_;
85 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_;
86 scoped_ptr<AppViewGuestDelegate> app_view_guest_delegate_;
87 scoped_ptr<AppDelegate> app_delegate_;
89 // This is used to ensure pending tasks will not fire after this object is
90 // destroyed.
91 base::WeakPtrFactory<AppViewGuest> weak_ptr_factory_;
93 DISALLOW_COPY_AND_ASSIGN(AppViewGuest);
96 } // namespace extensions
98 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_