| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_ | |
| 6 #define CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/compiler_specific.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "content/public/browser/notification_registrar.h" | |
| 14 #include "content/public/browser/web_contents_delegate.h" | |
| 15 #include "content/public/browser/web_contents_observer.h" | |
| 16 #include "extensions/browser/extension_function_dispatcher.h" | |
| 17 | |
| 18 class Balloon; | |
| 19 class Browser; | |
| 20 | |
| 21 namespace content { | |
| 22 class SiteInstance; | |
| 23 }; | |
| 24 | |
| 25 class BalloonHost : public content::WebContentsDelegate, | |
| 26 public content::WebContentsObserver, | |
| 27 public extensions::ExtensionFunctionDispatcher::Delegate { | |
| 28 public: | |
| 29 explicit BalloonHost(Balloon* balloon); | |
| 30 | |
| 31 // Initialize the view. | |
| 32 void Init(); | |
| 33 | |
| 34 // Stops showing the balloon. | |
| 35 void Shutdown(); | |
| 36 | |
| 37 // extensions::ExtensionFunctionDispatcher::Delegate overrides. | |
| 38 virtual extensions::WindowController* GetExtensionWindowController() | |
| 39 const OVERRIDE; | |
| 40 virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; | |
| 41 | |
| 42 const base::string16& GetSource() const; | |
| 43 | |
| 44 content::WebContents* web_contents() const { return web_contents_.get(); } | |
| 45 | |
| 46 // Enable Web UI. This has to be called before renderer is created. | |
| 47 void EnableWebUI(); | |
| 48 | |
| 49 // Returns whether the associated render view is ready. Used only for testing. | |
| 50 bool IsRenderViewReady() const; | |
| 51 | |
| 52 protected: | |
| 53 virtual ~BalloonHost(); | |
| 54 | |
| 55 scoped_ptr<content::WebContents> web_contents_; | |
| 56 | |
| 57 private: | |
| 58 // content::WebContentsDelegate implementation: | |
| 59 virtual void CloseContents(content::WebContents* source) OVERRIDE; | |
| 60 virtual void HandleMouseDown() OVERRIDE; | |
| 61 virtual void ResizeDueToAutoResize(content::WebContents* source, | |
| 62 const gfx::Size& pref_size) OVERRIDE; | |
| 63 virtual void AddNewContents(content::WebContents* source, | |
| 64 content::WebContents* new_contents, | |
| 65 WindowOpenDisposition disposition, | |
| 66 const gfx::Rect& initial_pos, | |
| 67 bool user_gesture, | |
| 68 bool* was_blocked) OVERRIDE; | |
| 69 | |
| 70 // content::WebContentsObserver implementation: | |
| 71 virtual void RenderViewCreated( | |
| 72 content::RenderViewHost* render_view_host) OVERRIDE; | |
| 73 virtual void RenderViewReady() OVERRIDE; | |
| 74 virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE; | |
| 75 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 76 | |
| 77 // Message handlers | |
| 78 void OnRequest(const ExtensionHostMsg_Request_Params& params); | |
| 79 | |
| 80 // Called to send an event that the balloon has been disconnected from | |
| 81 // a renderer (if should_notify_on_disconnect_ is true). | |
| 82 void NotifyDisconnect(); | |
| 83 | |
| 84 // Non-owned pointer to the associated balloon. | |
| 85 Balloon* balloon_; | |
| 86 | |
| 87 // True after Init() has completed. | |
| 88 bool initialized_; | |
| 89 | |
| 90 // Indicates whether we should notify about disconnection of this balloon. | |
| 91 // This is used to ensure disconnection notifications only happen if | |
| 92 // a connection notification has happened and that they happen only once. | |
| 93 bool should_notify_on_disconnect_; | |
| 94 | |
| 95 // Site instance for the balloon/profile, to be used for opening new links. | |
| 96 scoped_refptr<content::SiteInstance> site_instance_; | |
| 97 | |
| 98 // A flag to enable Web UI. | |
| 99 bool enable_web_ui_; | |
| 100 | |
| 101 extensions::ExtensionFunctionDispatcher extension_function_dispatcher_; | |
| 102 }; | |
| 103 | |
| 104 #endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_ | |
| OLD | NEW |