[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 1 | // Copyright 2013 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. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_EXTENSIONS_APP_WINDOW_CONTENTS_H_ |
| 6 | #define CHROME_BROWSER_EXTENSIONS_APP_WINDOW_CONTENTS_H_ |
| 7 | |
| 8 | #include <vector> |
| 9 | |
[email protected] | d53417e | 2013-07-01 07:07:39 | [diff] [blame] | 10 | #include "apps/shell_window.h" |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 11 | #include "base/basictypes.h" |
| 12 | #include "base/memory/scoped_ptr.h" |
| 13 | #include "chrome/browser/extensions/extension_function_dispatcher.h" |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 14 | #include "content/public/browser/notification_observer.h" |
| 15 | #include "content/public/browser/web_contents_observer.h" |
| 16 | |
| 17 | class GURL; |
| 18 | |
| 19 | namespace content { |
| 20 | class RenderViewHost; |
| 21 | } |
| 22 | |
| 23 | namespace extensions { |
| 24 | struct DraggableRegion; |
| 25 | } |
| 26 | |
[email protected] | 8a7ffed9 | 2013-07-17 06:21:19 | [diff] [blame] | 27 | namespace apps { |
| 28 | |
| 29 | // ShellWindowContents class specific to app windows. It maintains a |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 30 | // WebContents instance and observes it for the purpose of passing |
| 31 | // messages to the extensions system. |
[email protected] | 8a7ffed9 | 2013-07-17 06:21:19 | [diff] [blame] | 32 | class AppWindowContents : public ShellWindowContents, |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 33 | public content::NotificationObserver, |
| 34 | public content::WebContentsObserver, |
| 35 | public ExtensionFunctionDispatcher::Delegate { |
| 36 | public: |
[email protected] | 8a7ffed9 | 2013-07-17 06:21:19 | [diff] [blame] | 37 | explicit AppWindowContents(ShellWindow* host); |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 38 | virtual ~AppWindowContents(); |
| 39 | |
[email protected] | 8a7ffed9 | 2013-07-17 06:21:19 | [diff] [blame] | 40 | // ShellWindowContents |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 41 | virtual void Initialize(Profile* profile, const GURL& url) OVERRIDE; |
| 42 | virtual void LoadContents(int32 creator_process_id) OVERRIDE; |
| 43 | virtual void NativeWindowChanged(NativeAppWindow* native_app_window) OVERRIDE; |
| 44 | virtual void NativeWindowClosed() OVERRIDE; |
| 45 | virtual content::WebContents* GetWebContents() const OVERRIDE; |
| 46 | |
| 47 | private: |
| 48 | // content::NotificationObserver |
| 49 | virtual void Observe(int type, |
| 50 | const content::NotificationSource& source, |
| 51 | const content::NotificationDetails& details) OVERRIDE; |
| 52 | |
| 53 | // content::WebContentsObserver |
| 54 | virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 55 | |
| 56 | // ExtensionFunctionDispatcher::Delegate |
| 57 | virtual extensions::WindowController* GetExtensionWindowController() const |
| 58 | OVERRIDE; |
| 59 | virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; |
| 60 | |
| 61 | void OnRequest(const ExtensionHostMsg_Request_Params& params); |
| 62 | void UpdateDraggableRegions( |
| 63 | const std::vector<extensions::DraggableRegion>& regions); |
| 64 | void SuspendRenderViewHost(content::RenderViewHost* rvh); |
| 65 | |
[email protected] | 8a7ffed9 | 2013-07-17 06:21:19 | [diff] [blame] | 66 | ShellWindow* host_; // This class is owned by |host_| |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 67 | GURL url_; |
| 68 | content::NotificationRegistrar registrar_; |
| 69 | scoped_ptr<content::WebContents> web_contents_; |
| 70 | scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_; |
| 71 | |
| 72 | DISALLOW_COPY_AND_ASSIGN(AppWindowContents); |
| 73 | }; |
| 74 | |
[email protected] | 8a7ffed9 | 2013-07-17 06:21:19 | [diff] [blame] | 75 | } // namespace apps |
| 76 | |
[email protected] | f1c102b | 2013-02-15 07:44:12 | [diff] [blame] | 77 | #endif // CHROME_BROWSER_EXTENSIONS_APP_WINDOW_CONTENTS_H_ |