1 // Copyright (c) 2012 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 CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_
6 #define CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/extensions/extension_function_dispatcher.h"
14 #include "content/public/browser/notification_registrar.h"
15 #include "content/public/browser/web_contents_delegate.h"
16 #include "content/public/browser/web_contents_observer.h"
25 class BalloonHost
: public content::WebContentsDelegate
,
26 public content::WebContentsObserver
,
27 public ExtensionFunctionDispatcher::Delegate
{
29 explicit BalloonHost(Balloon
* balloon
);
31 // Initialize the view.
34 // Stops showing the balloon.
37 // ExtensionFunctionDispatcher::Delegate overrides.
38 virtual extensions::WindowController
* GetExtensionWindowController()
40 virtual content::WebContents
* GetAssociatedWebContents() const OVERRIDE
;
42 const base::string16
& GetSource() const;
44 content::WebContents
* web_contents() const { return web_contents_
.get(); }
46 // Enable Web UI. This has to be called before renderer is created.
49 // Returns whether the associated render view is ready. Used only for testing.
50 bool IsRenderViewReady() const;
52 // content::WebContentsDelegate implementation:
53 virtual bool CanLoadDataURLsInWebUI() const OVERRIDE
;
56 virtual ~BalloonHost();
58 scoped_ptr
<content::WebContents
> web_contents_
;
61 // content::WebContentsDelegate implementation:
62 virtual void CloseContents(content::WebContents
* source
) OVERRIDE
;
63 virtual void HandleMouseDown() OVERRIDE
;
64 virtual void ResizeDueToAutoResize(content::WebContents
* source
,
65 const gfx::Size
& pref_size
) OVERRIDE
;
66 virtual void AddNewContents(content::WebContents
* source
,
67 content::WebContents
* new_contents
,
68 WindowOpenDisposition disposition
,
69 const gfx::Rect
& initial_pos
,
71 bool* was_blocked
) OVERRIDE
;
73 // content::WebContentsObserver implementation:
74 virtual void RenderViewCreated(
75 content::RenderViewHost
* render_view_host
) OVERRIDE
;
76 virtual void RenderViewReady() OVERRIDE
;
77 virtual void RenderProcessGone(base::TerminationStatus status
) OVERRIDE
;
78 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
81 void OnRequest(const ExtensionHostMsg_Request_Params
& params
);
83 // Called to send an event that the balloon has been disconnected from
84 // a renderer (if should_notify_on_disconnect_ is true).
85 void NotifyDisconnect();
87 // Non-owned pointer to the associated balloon.
90 // True after Init() has completed.
93 // Indicates whether we should notify about disconnection of this balloon.
94 // This is used to ensure disconnection notifications only happen if
95 // a connection notification has happened and that they happen only once.
96 bool should_notify_on_disconnect_
;
98 // Site instance for the balloon/profile, to be used for opening new links.
99 scoped_refptr
<content::SiteInstance
> site_instance_
;
101 // A flag to enable Web UI.
104 ExtensionFunctionDispatcher extension_function_dispatcher_
;
107 #endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_