Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / notifications / balloon_host.h
blobc87f43e22ab9a99be107ef1e2795caab0abf9f66
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_
8 #include <string>
9 #include <vector>
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"
18 class Balloon;
19 class Browser;
21 namespace content {
22 class SiteInstance;
25 class BalloonHost : public content::WebContentsDelegate,
26 public content::WebContentsObserver,
27 public ExtensionFunctionDispatcher::Delegate {
28 public:
29 explicit BalloonHost(Balloon* balloon);
31 // Initialize the view.
32 void Init();
34 // Stops showing the balloon.
35 void Shutdown();
37 // ExtensionFunctionDispatcher::Delegate overrides.
38 virtual extensions::WindowController* GetExtensionWindowController()
39 const OVERRIDE;
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.
47 void EnableWebUI();
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;
55 protected:
56 virtual ~BalloonHost();
58 scoped_ptr<content::WebContents> web_contents_;
60 private:
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,
70 bool user_gesture,
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;
80 // Message handlers
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.
88 Balloon* balloon_;
90 // True after Init() has completed.
91 bool initialized_;
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.
102 bool enable_web_ui_;
104 ExtensionFunctionDispatcher extension_function_dispatcher_;
107 #endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_