OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ | 5 #ifndef CHROME_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ |
6 #define CHROME_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ | 6 #define CHROME_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ |
7 | 7 |
| 8 #include "base/id_map.h" |
8 #include "chrome/browser/guest_view/guest_view.h" | 9 #include "chrome/browser/guest_view/guest_view.h" |
| 10 #include "extensions/browser/extension_function_dispatcher.h" |
9 | 11 |
10 class AppViewGuest : public GuestView<AppViewGuest> { | 12 namespace extensions { |
| 13 class Extension; |
| 14 class ExtensionHost; |
| 15 }; |
| 16 |
| 17 // An AppViewGuest provides the browser-side implementation of <appview> API. |
| 18 // AppViewGuest is created on attachment. That is, when a guest WEbContnets 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 extensions::ExtensionFunctionDispatcher::Delegate { |
11 public: | 23 public: |
12 static const char Type[]; | 24 static const char Type[]; |
13 | 25 |
| 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); |
| 33 |
14 AppViewGuest(content::BrowserContext* browser_context, | 34 AppViewGuest(content::BrowserContext* browser_context, |
15 int guest_instance_id); | 35 int guest_instance_id); |
16 | 36 |
| 37 // ExtensionFunctionDispatcher::Delegate implementation. |
| 38 virtual extensions::WindowController* GetExtensionWindowController() const |
| 39 OVERRIDE; |
| 40 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; |
| 41 |
| 42 // content::WebContentsObserver implementation. |
| 43 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 44 |
| 45 // content::WebContentsDelegate implementation. |
| 46 virtual bool HandleContextMenu( |
| 47 const content::ContextMenuParams& params) OVERRIDE; |
| 48 |
17 // GuestViewBase implementation. | 49 // GuestViewBase implementation. |
18 virtual void CreateWebContents( | 50 virtual void CreateWebContents( |
19 const std::string& embedder_extension_id, | 51 const std::string& embedder_extension_id, |
20 int embedder_render_process_id, | 52 int embedder_render_process_id, |
21 const base::DictionaryValue& create_params, | 53 const base::DictionaryValue& create_params, |
22 const WebContentsCreatedCallback& callback) OVERRIDE; | 54 const WebContentsCreatedCallback& callback) OVERRIDE; |
23 virtual void DidAttachToEmbedder() OVERRIDE; | 55 virtual void DidAttachToEmbedder() OVERRIDE; |
| 56 virtual void DidInitialize() OVERRIDE; |
24 | 57 |
25 private: | 58 private: |
26 virtual ~AppViewGuest(); | 59 virtual ~AppViewGuest(); |
| 60 |
| 61 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
| 62 |
| 63 void CompleteCreateWebContents(const GURL& url, |
| 64 const extensions::Extension* guest_extension, |
| 65 const WebContentsCreatedCallback& callback); |
| 66 |
| 67 void LaunchAppAndFireEvent(const WebContentsCreatedCallback& callback, |
| 68 extensions::ExtensionHost* extension_host); |
| 69 |
| 70 GURL url_; |
| 71 std::string guest_extension_id_; |
| 72 scoped_ptr<extensions::ExtensionFunctionDispatcher> |
| 73 extension_function_dispatcher_; |
| 74 |
| 75 // This is used to ensure pending tasks will not fire after this object is |
| 76 // destroyed. |
| 77 base::WeakPtrFactory<AppViewGuest> weak_ptr_factory_; |
| 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(AppViewGuest); |
27 }; | 80 }; |
28 | 81 |
29 #endif // CHROME_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ | 82 #endif // CHROME_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ |
OLD | NEW |