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.
5 #ifndef EXTENSIONS_SHELL_BROWSER_SHELL_APP_WINDOW_H_
6 #define EXTENSIONS_SHELL_BROWSER_SHELL_APP_WINDOW_H_
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"
14 struct ExtensionHostMsg_Request_Params
;
30 namespace extensions
{
32 class ExtensionFunctionDispatcher
;
33 class ShellWebContentsDelegate
;
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
{
42 virtual ~ShellAppWindow();
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
);
50 // Starts loading |url| which must be an extension URL.
51 void LoadURL(const GURL
& url
);
53 // Returns the window hosting the web contents.
54 aura::Window
* GetNativeWindow();
56 // Returns the routing ID of the render view host of |web_contents_|.
57 int GetRenderViewRoutingID();
59 // content::WebContentsDelegate overrides:
60 virtual void RequestMediaAccessPermission(
61 content::WebContents
* web_contents
,
62 const content::MediaStreamRequest
& request
,
63 const content::MediaResponseCallback
& callback
) OVERRIDE
;
65 // content::WebContentsObserver overrides:
66 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
68 // ExtensionFunctionDispatcher::Delegate overrides:
69 virtual content::WebContents
* GetAssociatedWebContents() const OVERRIDE
;
73 void OnRequest(const ExtensionHostMsg_Request_Params
& params
);
75 // The extension that spawned this window. Not owned.
76 const Extension
* extension_
;
78 scoped_ptr
<content::WebContents
> web_contents_
;
79 scoped_ptr
<ExtensionFunctionDispatcher
> extension_function_dispatcher_
;
81 DISALLOW_COPY_AND_ASSIGN(ShellAppWindow
);
84 } // namespace extensions
86 #endif // EXTENSIONS_SHELL_BROWSER_SHELL_APP_WINDOW_H_