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 APPS_SHELL_BROWSER_SHELL_APP_WINDOW_H_
6 #define APPS_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_observer.h"
11 #include "extensions/browser/extension_function_dispatcher.h"
13 struct ExtensionHostMsg_Request_Params
;
25 namespace extensions
{
26 class ExtensionFunctionDispatcher
;
35 // A simplified app window created by chrome.app.window.create(). Manages the
36 // primary web contents for the app.
38 : public content::WebContentsObserver
,
39 public extensions::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
, gfx::Size initial_size
);
48 // Starts loading |url| which must be an extension URL.
49 void LoadURL(const GURL
& url
);
51 // Returns the window hosting the web contents.
52 aura::Window
* GetNativeWindow();
54 // Returns the routing ID of the render view host of |web_contents_|.
55 int GetRenderViewRoutingID();
57 // content::WebContentsObserver implementation
58 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
60 // extensions::ExtensionFunctionDispatcher::Delegate implementation
61 virtual content::WebContents
* GetAssociatedWebContents() const OVERRIDE
;
65 void OnRequest(const ExtensionHostMsg_Request_Params
& params
);
67 scoped_ptr
<content::WebContents
> web_contents_
;
68 scoped_ptr
<extensions::ExtensionFunctionDispatcher
>
69 extension_function_dispatcher_
;
71 DISALLOW_COPY_AND_ASSIGN(ShellAppWindow
);
76 #endif // APPS_SHELL_BROWSER_SHELL_APP_WINDOW_H_