Chromium Code Reviews| 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 "base/id_map.h" |
| 9 #include "extensions/browser/extension_function_dispatcher.h" | 9 #include "extensions/browser/extension_function_dispatcher.h" |
| 10 #include "extensions/browser/guest_view/guest_view.h" | 10 #include "extensions/browser/guest_view/guest_view.h" |
| 11 | 11 |
| 12 namespace extensions { | 12 namespace extensions { |
| 13 class Extension; | 13 class Extension; |
| 14 class ExtensionHost; | 14 class ExtensionHost; |
| 15 | 15 |
| 16 // An AppViewGuest provides the browser-side implementation of <appview> API. | 16 // An AppViewGuest provides the browser-side implementation of <appview> API. |
| 17 // AppViewGuest is created on attachment. That is, when a guest WebContents is | 17 // AppViewGuest is created on attachment. That is, when a guest WebContents is |
| 18 // associated with a particular embedder WebContents. This happens on calls to | 18 // associated with a particular embedder WebContents. This happens on calls to |
| 19 // the connect API. | 19 // the connect API. |
| 20 class AppViewGuest : public GuestView<AppViewGuest>, | 20 class AppViewGuest : public GuestView<AppViewGuest>, |
| 21 public extensions::ExtensionFunctionDispatcher::Delegate { | 21 public ExtensionFunctionDispatcher::Delegate { |
| 22 public: | 22 public: |
| 23 static const char Type[]; | 23 static const char Type[]; |
| 24 | 24 |
| 25 // Completes the creation of a WebContents associated with the provided | 25 // Completes the creation of a WebContents associated with the provided |
| 26 // |guest_extensions_id|. | 26 // |guest_extensions_id|. |
| 27 static bool CompletePendingRequest( | 27 static bool CompletePendingRequest( |
| 28 content::BrowserContext* browser_context, | 28 content::BrowserContext* browser_context, |
| 29 const GURL& url, | 29 const GURL& url, |
| 30 int guest_instance_id, | 30 int guest_instance_id, |
| 31 const std::string& guest_extension_id); | 31 const std::string& guest_extension_id); |
| 32 | 32 |
| 33 static GuestViewBase* Create(content::BrowserContext* browser_context, | 33 static GuestViewBase* Create(content::BrowserContext* browser_context, |
| 34 int guest_instance_id); | 34 int guest_instance_id); |
| 35 | 35 |
| 36 // ExtensionFunctionDispatcher::Delegate implementation. | 36 // ExtensionFunctionDispatcher::Delegate implementation. |
| 37 virtual extensions::WindowController* GetExtensionWindowController() const | 37 virtual WindowController* GetExtensionWindowController() const |
| 38 OVERRIDE; | 38 OVERRIDE; |
| 39 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; | 39 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; |
| 40 | 40 |
| 41 // content::WebContentsObserver implementation. | 41 // content::WebContentsObserver implementation. |
| 42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 43 | 43 |
| 44 // content::WebContentsDelegate implementation. | 44 // content::WebContentsDelegate implementation. |
| 45 virtual bool HandleContextMenu( | 45 virtual bool HandleContextMenu( |
| 46 const content::ContextMenuParams& params) OVERRIDE; | 46 const content::ContextMenuParams& params) OVERRIDE; |
| 47 | 47 |
| 48 // GuestViewBase implementation. | 48 // GuestViewBase implementation. |
| 49 virtual const char* GetAPINamespace() OVERRIDE; | 49 virtual const char* GetAPINamespace() OVERRIDE; |
| 50 virtual void CreateWebContents( | 50 virtual void CreateWebContents( |
| 51 const std::string& embedder_extension_id, | 51 const std::string& embedder_extension_id, |
| 52 int embedder_render_process_id, | 52 int embedder_render_process_id, |
| 53 const base::DictionaryValue& create_params, | 53 const base::DictionaryValue& create_params, |
| 54 const WebContentsCreatedCallback& callback) OVERRIDE; | 54 const WebContentsCreatedCallback& callback) OVERRIDE; |
| 55 virtual void DidAttachToEmbedder() OVERRIDE; | 55 virtual void DidAttachToEmbedder() OVERRIDE; |
| 56 virtual void DidInitialize() OVERRIDE; | 56 virtual void DidInitialize() OVERRIDE; |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 AppViewGuest(content::BrowserContext* browser_context, | 59 AppViewGuest(content::BrowserContext* browser_context, |
| 60 int guest_instance_id); | 60 int guest_instance_id); |
| 61 | 61 |
| 62 virtual ~AppViewGuest(); | 62 virtual ~AppViewGuest(); |
| 63 | 63 |
| 64 void OnRequest(const ExtensionHostMsg_Request_Params& params); | 64 void OnRequest(const ExtensionHostMsg_Request_Params& params); |
| 65 | 65 |
| 66 void CompleteCreateWebContents(const GURL& url, | 66 void CompleteCreateWebContents(const GURL& url, |
| 67 const extensions::Extension* guest_extension, | 67 const Extension* guest_extension, |
| 68 const WebContentsCreatedCallback& callback); | 68 const WebContentsCreatedCallback& callback); |
| 69 | 69 |
| 70 void LaunchAppAndFireEvent(const WebContentsCreatedCallback& callback, | 70 void LaunchAppAndFireEvent(const WebContentsCreatedCallback& callback, |
| 71 extensions::ExtensionHost* extension_host); | 71 ExtensionHost* extension_host); |
| 72 | 72 |
| 73 GURL url_; | 73 GURL url_; |
| 74 std::string guest_extension_id_; | 74 std::string guest_extension_id_; |
| 75 scoped_ptr<extensions::ExtensionFunctionDispatcher> | 75 scoped_ptr<ExtensionFunctionDispatcher> |
| 76 extension_function_dispatcher_; | 76 extension_function_dispatcher_; |
|
Fady Samuel
2014/08/12 21:25:30
This can probably now go on the same line?
Xi Han
2014/08/12 21:53:48
Done.
| |
| 77 | 77 |
| 78 // This is used to ensure pending tasks will not fire after this object is | 78 // This is used to ensure pending tasks will not fire after this object is |
| 79 // destroyed. | 79 // destroyed. |
| 80 base::WeakPtrFactory<AppViewGuest> weak_ptr_factory_; | 80 base::WeakPtrFactory<AppViewGuest> weak_ptr_factory_; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(AppViewGuest); | 82 DISALLOW_COPY_AND_ASSIGN(AppViewGuest); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 } // namespace extensions | 85 } // namespace extensions |
| 86 | 86 |
| 87 #endif // CHROME_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ | 87 #endif // CHROME_BROWSER_GUEST_VIEW_APP_VIEW_APP_VIEW_GUEST_H_ |
| OLD | NEW |