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.
5 #ifndef APPS_APP_WINDOW_CONTENTS_H_
6 #define APPS_APP_WINDOW_CONTENTS_H_
10 #include "apps/app_window.h"
11 #include "base/basictypes.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/web_contents_observer.h"
15 #include "extensions/browser/extension_function_dispatcher.h"
23 namespace extensions
{
24 struct DraggableRegion
;
29 // AppWindowContents class specific to app windows. It maintains a
30 // WebContents instance and observes it for the purpose of passing
31 // messages to the extensions system.
32 class AppWindowContentsImpl
33 : public AppWindowContents
,
34 public content::NotificationObserver
,
35 public content::WebContentsObserver
,
36 public extensions::ExtensionFunctionDispatcher::Delegate
{
38 explicit AppWindowContentsImpl(AppWindow
* host
);
39 virtual ~AppWindowContentsImpl();
42 virtual void Initialize(content::BrowserContext
* context
,
43 const GURL
& url
) OVERRIDE
;
44 virtual void LoadContents(int32 creator_process_id
) OVERRIDE
;
45 virtual void NativeWindowChanged(NativeAppWindow
* native_app_window
) OVERRIDE
;
46 virtual void NativeWindowClosed() OVERRIDE
;
47 virtual content::WebContents
* GetWebContents() const OVERRIDE
;
50 // content::NotificationObserver
51 virtual void Observe(int type
,
52 const content::NotificationSource
& source
,
53 const content::NotificationDetails
& details
) OVERRIDE
;
55 // content::WebContentsObserver
56 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
58 // extensions::ExtensionFunctionDispatcher::Delegate
59 virtual extensions::WindowController
* GetExtensionWindowController() const
61 virtual content::WebContents
* GetAssociatedWebContents() const OVERRIDE
;
63 void OnRequest(const ExtensionHostMsg_Request_Params
& params
);
64 void UpdateDraggableRegions(
65 const std::vector
<extensions::DraggableRegion
>& regions
);
66 void SuspendRenderViewHost(content::RenderViewHost
* rvh
);
68 AppWindow
* host_
; // This class is owned by |host_|
70 content::NotificationRegistrar registrar_
;
71 scoped_ptr
<content::WebContents
> web_contents_
;
72 scoped_ptr
<extensions::ExtensionFunctionDispatcher
>
73 extension_function_dispatcher_
;
75 DISALLOW_COPY_AND_ASSIGN(AppWindowContentsImpl
);
80 #endif // APPS_APP_WINDOW_CONTENTS_H_