| 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 EXTENSIONS_SHELL_BROWSER_SHELL_APP_WINDOW_H_ | |
| 6 #define EXTENSIONS_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_delegate.h" | |
| 11 #include "content/public/browser/web_contents_observer.h" | |
| 12 #include "extensions/browser/extension_function_dispatcher.h" | |
| 13 | |
| 14 struct ExtensionHostMsg_Request_Params; | |
| 15 class GURL; | |
| 16 | |
| 17 namespace aura { | |
| 18 class Window; | |
| 19 } | |
| 20 | |
| 21 namespace content { | |
| 22 class BrowserContext; | |
| 23 class WebContents; | |
| 24 } | |
| 25 | |
| 26 namespace gfx { | |
| 27 class Size; | |
| 28 } | |
| 29 | |
| 30 namespace extensions { | |
| 31 | |
| 32 class ExtensionFunctionDispatcher; | |
| 33 class ShellWebContentsDelegate; | |
| 34 | |
| 35 // A simplified app window created by chrome.app.window.create(). Manages the | |
| 36 // primary web contents for the app. | |
| 37 class ShellAppWindow : public content::WebContentsDelegate, | |
| 38 public content::WebContentsObserver, | |
| 39 public 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, | |
| 47 const Extension* extension, | |
| 48 gfx::Size initial_size); | |
| 49 | |
| 50 // Starts loading |url| which must be an extension URL. | |
| 51 void LoadURL(const GURL& url); | |
| 52 | |
| 53 // Returns the window hosting the web contents. | |
| 54 aura::Window* GetNativeWindow(); | |
| 55 | |
| 56 // Returns the routing ID of the render view host of |web_contents_|. | |
| 57 int GetRenderViewRoutingID(); | |
| 58 | |
| 59 // content::WebContentsDelegate overrides: | |
| 60 virtual void RequestMediaAccessPermission( | |
| 61 content::WebContents* web_contents, | |
| 62 const content::MediaStreamRequest& request, | |
| 63 const content::MediaResponseCallback& callback) OVERRIDE; | |
| 64 | |
| 65 // content::WebContentsObserver overrides: | |
| 66 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 67 | |
| 68 // ExtensionFunctionDispatcher::Delegate overrides: | |
| 69 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; | |
| 70 | |
| 71 private: | |
| 72 // IPC handler. | |
| 73 void OnRequest(const ExtensionHostMsg_Request_Params& params); | |
| 74 | |
| 75 // The extension that spawned this window. Not owned. | |
| 76 const Extension* extension_; | |
| 77 | |
| 78 scoped_ptr<content::WebContents> web_contents_; | |
| 79 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_; | |
| 80 | |
| 81 DISALLOW_COPY_AND_ASSIGN(ShellAppWindow); | |
| 82 }; | |
| 83 | |
| 84 } // namespace extensions | |
| 85 | |
| 86 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_APP_WINDOW_H_ | |
| OLD | NEW |