| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef APPS_SHELL_BROWSER_SHELL_APP_WINDOW_H_ | |
| 6 #define APPS_SHELL_BROWSER_SHELL_APP_WINDOW_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "content/public/browser/web_contents_observer.h" | |
| 11 #include "extensions/browser/extension_function_dispatcher.h" | |
| 12 | |
| 13 struct ExtensionHostMsg_Request_Params; | |
| 14 class GURL; | |
| 15 | |
| 16 namespace aura { | |
| 17 class Window; | |
| 18 } | |
| 19 | |
| 20 namespace content { | |
| 21 class BrowserContext; | |
| 22 class WebContents; | |
| 23 } | |
| 24 | |
| 25 namespace extensions { | |
| 26 class ExtensionFunctionDispatcher; | |
| 27 } | |
| 28 | |
| 29 namespace gfx { | |
| 30 class Size; | |
| 31 } | |
| 32 | |
| 33 namespace apps { | |
| 34 | |
| 35 // A simplified app window created by chrome.app.window.create(). Manages the | |
| 36 // primary web contents for the app. | |
| 37 class ShellAppWindow | |
| 38 : public content::WebContentsObserver, | |
| 39 public extensions::ExtensionFunctionDispatcher::Delegate { | |
| 40 public: | |
| 41 ShellAppWindow(); | |
| 42 virtual ~ShellAppWindow(); | |
| 43 | |
| 44 // Creates the web contents and attaches extension-specific helpers. | |
| 45 // Passing a valid |initial_size| to avoid a web contents resize. | |
| 46 void Init(content::BrowserContext* context, gfx::Size initial_size); | |
| 47 | |
| 48 // Starts loading |url| which must be an extension URL. | |
| 49 void LoadURL(const GURL& url); | |
| 50 | |
| 51 // Returns the window hosting the web contents. | |
| 52 aura::Window* GetNativeWindow(); | |
| 53 | |
| 54 // Returns the routing ID of the render view host of |web_contents_|. | |
| 55 int GetRenderViewRoutingID(); | |
| 56 | |
| 57 // content::WebContentsObserver implementation | |
| 58 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 59 | |
| 60 // extensions::ExtensionFunctionDispatcher::Delegate implementation | |
| 61 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; | |
| 62 | |
| 63 private: | |
| 64 // IPC handler. | |
| 65 void OnRequest(const ExtensionHostMsg_Request_Params& params); | |
| 66 | |
| 67 scoped_ptr<content::WebContents> web_contents_; | |
| 68 scoped_ptr<extensions::ExtensionFunctionDispatcher> | |
| 69 extension_function_dispatcher_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(ShellAppWindow); | |
| 72 }; | |
| 73 | |
| 74 } // namespace apps | |
| 75 | |
| 76 #endif // APPS_SHELL_BROWSER_SHELL_APP_WINDOW_H_ | |
| OLD | NEW |