OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 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_VIEWS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_ |
| 6 #define CHROME_BROWSER_VIEWS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_ |
| 7 |
| 8 #include "chrome/browser/notifications/balloon.h" |
| 9 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
| 10 #include "chrome/browser/renderer_host/site_instance.h" |
| 11 #include "views/controls/native/native_view_host.h" |
| 12 #include "webkit/glue/webpreferences.h" |
| 13 |
| 14 class Profile; |
| 15 class RenderViewHost; |
| 16 |
| 17 // BalloonViewHost class is a delegate to the renderer host for the HTML |
| 18 // notification. When initialized it creates a new RenderViewHost and loads |
| 19 // the contents of the toast into it. It also handles links within the toast, |
| 20 // loading them into a new tab. |
| 21 class BalloonViewHost : public views::NativeViewHost, |
| 22 public RenderViewHostDelegate { |
| 23 public: |
| 24 explicit BalloonViewHost(Balloon* balloon); |
| 25 |
| 26 ~BalloonViewHost() { |
| 27 Shutdown(); |
| 28 } |
| 29 |
| 30 // Stops showing the balloon. |
| 31 void Shutdown(); |
| 32 |
| 33 // RenderViewHostDelegate overrides. |
| 34 virtual WebPreferences GetWebkitPrefs() { return WebPreferences(); } |
| 35 virtual RendererPreferences GetRendererPrefs() const; |
| 36 virtual SiteInstance* GetSiteInstance() const { |
| 37 return site_instance_.get(); |
| 38 } |
| 39 virtual Profile* GetProfile() const { return balloon_->profile(); } |
| 40 virtual const GURL& GetURL() const { |
| 41 return balloon_->notification().content_url(); |
| 42 } |
| 43 virtual void RequestOpenURL(const GURL& url, const GURL& referrer, |
| 44 WindowOpenDisposition disposition); |
| 45 virtual void RendererReady(RenderViewHost* render_view_host); |
| 46 virtual void RendererGone(RenderViewHost* render_view_host); |
| 47 virtual void UpdateTitle(RenderViewHost* /* render_view_host */, |
| 48 int32 /* page_id */, const std::wstring& title) { |
| 49 title_ = title; |
| 50 } |
| 51 virtual int GetBrowserWindowID() const { return -1; } |
| 52 virtual ViewType::Type GetRenderViewType() const { |
| 53 return ViewType::TAB_CONTENTS; |
| 54 } |
| 55 |
| 56 // Accessors. |
| 57 RenderViewHost* render_view_host() const { return render_view_host_; } |
| 58 const std::wstring& title() const { return title_; } |
| 59 |
| 60 private: |
| 61 // View overrides. |
| 62 virtual void ViewHierarchyChanged(bool is_add, |
| 63 views::View *parent, |
| 64 views::View *child); |
| 65 |
| 66 // Initialize the view, parented to |parent|, and show it. |
| 67 void Init(gfx::NativeView parent); |
| 68 |
| 69 // True after Init() has completed. |
| 70 bool initialized_; |
| 71 |
| 72 // Non-owned pointer to the associated balloon. |
| 73 Balloon* balloon_; |
| 74 |
| 75 // Site instance for the balloon/profile, to be used for opening new links. |
| 76 scoped_refptr<SiteInstance> site_instance_; |
| 77 |
| 78 // Owned pointer to to host for the renderer process. |
| 79 RenderViewHost* render_view_host_; |
| 80 |
| 81 // Indicates whether we should notify about disconnection of this balloon. |
| 82 // This is used to ensure disconnection notifications only happen if |
| 83 // a connection notification has happened and that they happen only once. |
| 84 bool should_notify_on_disconnect_; |
| 85 |
| 86 // The title of the balloon page. |
| 87 std::wstring title_; |
| 88 |
| 89 DISALLOW_COPY_AND_ASSIGN(BalloonViewHost); |
| 90 }; |
| 91 |
| 92 #endif // CHROME_BROWSER_VIEWS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_ |
OLD | NEW |