diff options
author | johnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 23:39:09 +0000 |
---|---|---|
committer | johnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 23:39:09 +0000 |
commit | 9e9e55c35954a06b68d5e62a27fa1ea60675d6f2 (patch) | |
tree | aa031fb90182ccd30df76f9d7947c36799ec611d | |
parent | 475b996b15bd1010869876e6d70e4c79bc1fea05 (diff) | |
download | chromium_src-9e9e55c35954a06b68d5e62a27fa1ea60675d6f2.zip chromium_src-9e9e55c35954a06b68d5e62a27fa1ea60675d6f2.tar.gz chromium_src-9e9e55c35954a06b68d5e62a27fa1ea60675d6f2.tar.bz2 |
Refactor BalloonViewHost, removing a lot of duplicate code that crept into notifications during the port to mac & linux and making behavior more consistent.
BUG=34826
TEST=notifications on each platform.
Review URL: http://codereview.chromium.org/1055005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42404 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/notifications/balloon_view.cc | 9 | ||||
-rw-r--r-- | chrome/browser/cocoa/notifications/balloon_view_host_mac.h | 110 | ||||
-rw-r--r-- | chrome/browser/cocoa/notifications/balloon_view_host_mac.mm | 109 | ||||
-rw-r--r-- | chrome/browser/gtk/notifications/balloon_view_host_gtk.cc | 126 | ||||
-rw-r--r-- | chrome/browser/gtk/notifications/balloon_view_host_gtk.h | 113 | ||||
-rw-r--r-- | chrome/browser/notifications/balloon_host.cc | 131 | ||||
-rw-r--r-- | chrome/browser/notifications/balloon_host.h | 116 | ||||
-rw-r--r-- | chrome/browser/views/notifications/balloon_view.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/notifications/balloon_view_host.cc | 156 | ||||
-rw-r--r-- | chrome/browser/views/notifications/balloon_view_host.h | 124 | ||||
-rwxr-xr-x | chrome/chrome_browser.gypi | 4 |
11 files changed, 342 insertions, 658 deletions
diff --git a/chrome/browser/chromeos/notifications/balloon_view.cc b/chrome/browser/chromeos/notifications/balloon_view.cc index 6b9c4f0..af66adf 100644 --- a/chrome/browser/chromeos/notifications/balloon_view.cc +++ b/chrome/browser/chromeos/notifications/balloon_view.cc @@ -72,7 +72,7 @@ void BalloonViewImpl::Show(Balloon* balloon) { balloon_ = balloon; html_contents_ = new BalloonViewHost(balloon); - AddChildView(html_contents_); + AddChildView(html_contents_->view()); if (controls_) { close_button_ = new views::TextButton(this, dismiss_text); close_button_->SetIcon(*rb.GetBitmapNamed(IDR_BALLOON_CLOSE)); @@ -109,8 +109,9 @@ void BalloonViewImpl::Show(Balloon* balloon) { void BalloonViewImpl::Update() { stale_ = false; - html_contents_->render_view_host()->NavigateToURL( - balloon_->notification().content_url()); + if (html_contents_->render_view_host()) + html_contents_->render_view_host()->NavigateToURL( + balloon_->notification().content_url()); } void BalloonViewImpl::Close(bool by_user) { @@ -145,7 +146,7 @@ void BalloonViewImpl::Layout() { int x = width() - button_size.width(); int y = height() - button_size.height(); - html_contents_->SetBounds(0, 0, width(), y); + html_contents_->view()->SetBounds(0, 0, width(), y); if (html_contents_->render_view_host()) { RenderWidgetHostView* view = html_contents_->render_view_host()->view(); if (view) diff --git a/chrome/browser/cocoa/notifications/balloon_view_host_mac.h b/chrome/browser/cocoa/notifications/balloon_view_host_mac.h index a6268d2..72220bd 100644 --- a/chrome/browser/cocoa/notifications/balloon_view_host_mac.h +++ b/chrome/browser/cocoa/notifications/balloon_view_host_mac.h @@ -5,28 +5,14 @@ #ifndef CHROME_BROWSER_COCOA_NOTIFICATIONS_BALLOON_VIEW_HOST_MAC_H_ #define CHROME_BROWSER_COCOA_NOTIFICATIONS_BALLOON_VIEW_HOST_MAC_H_ -#include "chrome/browser/notifications/balloon.h" -#include "chrome/browser/notifications/notification.h" -#include "chrome/browser/renderer_host/render_view_host_delegate.h" +#include "chrome/browser/notifications/balloon_host.h" #import "chrome/browser/renderer_host/render_widget_host_view_mac.h" -#include "chrome/browser/renderer_host/site_instance.h" -#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" -#include "gfx/native_widget_types.h" -#include "webkit/glue/webpreferences.h" - -class Profile; -class RenderViewHost; -class SkBitmap; -namespace gfx { -class Point; -} // BalloonViewHost class is a delegate to the renderer host for the HTML // notification. When initialized it creates a new RenderViewHost and loads // the contents of the toast into it. It also handles links within the toast, // loading them into a new tab. -class BalloonViewHost : public RenderViewHostDelegate, - public RenderViewHostDelegate::View { +class BalloonViewHost : public BalloonHost { public: explicit BalloonViewHost(Balloon* balloon); @@ -34,103 +20,25 @@ class BalloonViewHost : public RenderViewHostDelegate, Shutdown(); } - // Initialize the view. - void Init(); - - // Stops showing the balloon. - void Shutdown(); - - // RenderViewHostDelegate overrides. - virtual WebPreferences GetWebkitPrefs(); - virtual RendererPreferences GetRendererPrefs(Profile* profile) const; - virtual SiteInstance* GetSiteInstance() const { - return site_instance_.get(); - } - virtual Profile* GetProfile() const { return balloon_->profile(); } - virtual const GURL& GetURL() const { - return balloon_->notification().content_url(); - } - virtual void Close(RenderViewHost* render_view_host); - virtual void RenderViewCreated(RenderViewHost* render_view_host); - virtual void DidStopLoading() {} - virtual void RendererReady(RenderViewHost* render_view_host); - virtual void RendererGone(RenderViewHost* render_view_host); - virtual void UpdateTitle(RenderViewHost* /* render_view_host */, - int32 /* page_id */, const std::wstring& title) { - title_ = title; - } - virtual int GetBrowserWindowID() const { return -1; } - virtual ViewType::Type GetRenderViewType() const { - return ViewType::TAB_CONTENTS; - } - virtual RenderViewHostDelegate::View* GetViewDelegate() { - return this; - } - + // Changes the size of the balloon. void UpdateActualSize(const gfx::Size& new_size); - // RenderViewHostDelegate::View methods. Only the ones for opening new - // windows are currently implemented. - virtual void CreateNewWindow(int route_id); - virtual void CreateNewWidget(int route_id, bool activatable) {} - virtual void ShowCreatedWindow(int route_id, - WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, - bool user_gesture); - virtual void ShowCreatedWidget(int route_id, - const gfx::Rect& initial_pos) {} - virtual void ShowContextMenu(const ContextMenuParams& params) {} - virtual void StartDragging(const WebDropData& drop_data, - WebKit::WebDragOperationsMask allowed_ops, - const SkBitmap& image, - const gfx::Point& image_offset) {} - virtual void UpdateDragCursor(WebKit::WebDragOperation operation) {} - virtual void GotFocus() {} - virtual void TakeFocus(bool reverse) {} - virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, - bool* is_keyboard_shortcut) { - return false; - } - virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {} - virtual void HandleMouseEvent() {} - virtual void HandleMouseLeave() {} - virtual void UpdatePreferredSize(const gfx::Size& pref_size); - // Accessors. - RenderViewHost* render_view_host() const { return render_view_host_; } gfx::NativeView native_view() const { return render_widget_host_view_->native_view(); } - const std::wstring& title() const { return title_; } - - private: - // True after Init() has completed. - bool initialized_; - - // Non-owned pointer to the associated balloon. - Balloon* balloon_; - - // Site instance for the balloon/profile, to be used for opening new links. - scoped_refptr<SiteInstance> site_instance_; - // Owned pointer to to host for the renderer process. - RenderViewHost* render_view_host_; - - // Indicates whether we should notify about disconnection of this balloon. - // This is used to ensure disconnection notifications only happen if - // a connection notification has happened and that they happen only once. - bool should_notify_on_disconnect_; - - // The title of the balloon page. - std::wstring title_; + protected: + virtual void InitRenderWidgetHostView(); + virtual RenderWidgetHostView* render_widget_host_view() const { + return render_widget_host_view_; + } + private: // The Mac-specific widget host view. This is owned by its native view, // which this class frees in its destructor. RenderWidgetHostViewMac* render_widget_host_view_; - // Common implementations of some RenderViewHostDelegate::View methods. - RenderViewHostDelegateViewHelper delegate_view_helper_; - DISALLOW_COPY_AND_ASSIGN(BalloonViewHost); }; diff --git a/chrome/browser/cocoa/notifications/balloon_view_host_mac.mm b/chrome/browser/cocoa/notifications/balloon_view_host_mac.mm index 464de04..3b3aa35 100644 --- a/chrome/browser/cocoa/notifications/balloon_view_host_mac.mm +++ b/chrome/browser/cocoa/notifications/balloon_view_host_mac.mm @@ -4,103 +4,13 @@ #include "chrome/browser/cocoa/notifications/balloon_view_host_mac.h" -#include "base/string_util.h" -#include "chrome/browser/browser_list.h" -#include "chrome/browser/in_process_webkit/dom_storage_context.h" -#include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/notifications/balloon.h" -#include "chrome/browser/notifications/notification.h" -#include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" -#include "chrome/browser/renderer_host/site_instance.h" -#include "chrome/browser/renderer_preferences_util.h" -#include "chrome/common/notification_service.h" -#include "chrome/common/notification_type.h" -#include "chrome/common/render_messages.h" -#include "chrome/common/renderer_preferences.h" BalloonViewHost::BalloonViewHost(Balloon* balloon) - : initialized_(false), - balloon_(balloon), - site_instance_(SiteInstance::CreateSiteInstance(balloon->profile())), - render_view_host_(NULL), - should_notify_on_disconnect_(false), - render_widget_host_view_(NULL) { - DCHECK(balloon_); -} - -void BalloonViewHost::Shutdown() { - if (render_view_host_) { - render_view_host_->Shutdown(); - render_view_host_ = NULL; - } -} - -WebPreferences BalloonViewHost::GetWebkitPrefs() { - WebPreferences prefs; - prefs.allow_scripts_to_close_windows = true; - return prefs; -} - -RendererPreferences BalloonViewHost::GetRendererPrefs(Profile* profile) const { - RendererPreferences prefs; - renderer_preferences_util::UpdateFromSystemSettings(&prefs, profile); - return prefs; -} - -void BalloonViewHost::Close(RenderViewHost* render_view_host) { - balloon_->CloseByScript(); -} - -void BalloonViewHost::RenderViewCreated(RenderViewHost* render_view_host) { - render_view_host->Send(new ViewMsg_EnablePreferredSizeChangedMode( - render_view_host->routing_id())); -} - -void BalloonViewHost::RendererReady(RenderViewHost* render_view_host) { - should_notify_on_disconnect_ = true; - NotificationService::current()->Notify( - NotificationType::NOTIFY_BALLOON_CONNECTED, - Source<Balloon>(balloon_), NotificationService::NoDetails()); -} - -void BalloonViewHost::RendererGone(RenderViewHost* render_view_host) { - if (!should_notify_on_disconnect_) - return; - - should_notify_on_disconnect_ = false; - NotificationService::current()->Notify( - NotificationType::NOTIFY_BALLOON_DISCONNECTED, - Source<Balloon>(balloon_), NotificationService::NoDetails()); -} - -// RenderViewHostDelegate::View methods implemented to allow links to -// open pages in new tabs. -void BalloonViewHost::CreateNewWindow(int route_id) { - delegate_view_helper_.CreateNewWindow( - route_id, balloon_->profile(), site_instance_.get(), - DOMUIFactory::GetDOMUIType(balloon_->notification().content_url()), NULL); -} - -void BalloonViewHost::ShowCreatedWindow(int route_id, - WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, - bool user_gesture) { - // Don't allow pop-ups from notifications. - if (disposition == NEW_POPUP) - return; - - TabContents* contents = delegate_view_helper_.GetCreatedWindow(route_id); - if (contents) { - Browser* browser = BrowserList::GetLastActive(); - browser->AddTabContents(contents, disposition, initial_pos, user_gesture); - } -} - -void BalloonViewHost::UpdatePreferredSize(const gfx::Size& new_size) { - balloon_->SetContentPreferredSize(new_size); + : BalloonHost(balloon) { } void BalloonViewHost::UpdateActualSize(const gfx::Size& new_size) { @@ -113,19 +23,8 @@ void BalloonViewHost::UpdateActualSize(const gfx::Size& new_size) { [view setNeedsDisplay:YES]; } -void BalloonViewHost::Init() { - DCHECK(!render_view_host_) << "BalloonViewHost already initialized."; - - int64 session_storage_namespace_id = balloon_->profile()->GetWebKitContext()-> - dom_storage_context()->AllocateSessionStorageNamespaceId(); - - render_view_host_ = new RenderViewHost(site_instance_.get(), - this, MSG_ROUTING_NONE, - session_storage_namespace_id); - +void BalloonViewHost::InitRenderWidgetHostView() { + DCHECK(render_view_host_); render_widget_host_view_ = new RenderWidgetHostViewMac(render_view_host_); - render_view_host_->set_view(render_widget_host_view_); - render_view_host_->CreateRenderView(GetProfile()->GetRequestContext()); - render_view_host_->NavigateToURL(balloon_->notification().content_url()); - initialized_ = true; } + diff --git a/chrome/browser/gtk/notifications/balloon_view_host_gtk.cc b/chrome/browser/gtk/notifications/balloon_view_host_gtk.cc index b8f3e96..3a3afee 100644 --- a/chrome/browser/gtk/notifications/balloon_view_host_gtk.cc +++ b/chrome/browser/gtk/notifications/balloon_view_host_gtk.cc @@ -4,139 +4,31 @@ #include "chrome/browser/gtk/notifications/balloon_view_host_gtk.h" -#include "base/string_util.h" -#include "chrome/browser/browser_list.h" -#include "chrome/browser/in_process_webkit/dom_storage_context.h" -#include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/notifications/balloon.h" -#include "chrome/browser/notifications/notification.h" -#include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" -#include "chrome/browser/renderer_host/site_instance.h" -#include "chrome/browser/renderer_preferences_util.h" -#include "chrome/common/notification_service.h" -#include "chrome/common/notification_type.h" -#include "chrome/common/render_messages.h" -#include "chrome/common/renderer_preferences.h" BalloonViewHost::BalloonViewHost(Balloon* balloon) - : initialized_(false), - balloon_(balloon), - site_instance_(SiteInstance::CreateSiteInstance(balloon->profile())), - render_view_host_(NULL), - should_notify_on_disconnect_(false) { - DCHECK(balloon_); -} - -void BalloonViewHost::Shutdown() { - if (render_view_host_) { - render_view_host_->Shutdown(); - render_view_host_ = NULL; - } -} - -WebPreferences BalloonViewHost::GetWebkitPrefs() { - WebPreferences prefs; - prefs.allow_scripts_to_close_windows = true; - return prefs; -} - -RendererPreferences BalloonViewHost::GetRendererPrefs(Profile* profile) const { - RendererPreferences prefs; - renderer_preferences_util::UpdateFromSystemSettings(&prefs, profile); - // We want links (a.k.a. top_level_requests) to be forwarded to the browser so - // that we can open them in a new tab rather than in the balloon. - prefs.browser_handles_top_level_requests = true; - return prefs; -} - -void BalloonViewHost::RequestOpenURL(const GURL& url, - const GURL& referrer, - WindowOpenDisposition disposition) { - // Always open a link triggered within the notification balloon in a new tab. - // TODO(johnnyg): this new tab should always be in the same workspace as the - // notification. - BrowserList::GetLastActive()->AddTabWithURL(url, referrer, - PageTransition::LINK, true, 0, 0, GetSiteInstance()); -} - -void BalloonViewHost::Close(RenderViewHost* render_view_host) { - balloon_->CloseByScript(); -} - -void BalloonViewHost::RenderViewCreated(RenderViewHost* render_view_host) { - render_view_host->Send(new ViewMsg_EnablePreferredSizeChangedMode( - render_view_host->routing_id())); -} - -void BalloonViewHost::RendererReady(RenderViewHost* render_view_host) { - should_notify_on_disconnect_ = true; - NotificationService::current()->Notify( - NotificationType::NOTIFY_BALLOON_CONNECTED, - Source<Balloon>(balloon_), NotificationService::NoDetails()); -} - -void BalloonViewHost::RendererGone(RenderViewHost* render_view_host) { - if (!should_notify_on_disconnect_) - return; - - should_notify_on_disconnect_ = false; - NotificationService::current()->Notify( - NotificationType::NOTIFY_BALLOON_DISCONNECTED, - Source<Balloon>(balloon_), NotificationService::NoDetails()); -} - -// RenderViewHostDelegate::View methods implemented to allow links to -// open pages in new tabs. -void BalloonViewHost::CreateNewWindow(int route_id) { - delegate_view_helper_.CreateNewWindow( - route_id, balloon_->profile(), site_instance_.get(), - DOMUIFactory::GetDOMUIType(balloon_->notification().content_url()), NULL); -} - -void BalloonViewHost::ShowCreatedWindow(int route_id, - WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, - bool user_gesture) { - // Don't allow pop-ups from notifications. - if (disposition == NEW_POPUP) - return; - - TabContents* contents = delegate_view_helper_.GetCreatedWindow(route_id); - if (contents) { - Browser* browser = BrowserList::GetLastActive(); - browser->AddTabContents(contents, disposition, initial_pos, user_gesture); - } -} - -void BalloonViewHost::UpdatePreferredSize(const gfx::Size& new_size) { - balloon_->SetContentPreferredSize(new_size); + : BalloonHost(balloon) { } void BalloonViewHost::UpdateActualSize(const gfx::Size& new_size) { render_widget_host_view_->SetSize(new_size); - // gfx::Size(new_size.width(), new_size.height())); gtk_widget_set_size_request( native_view(), new_size.width(), new_size.height()); } -void BalloonViewHost::Init() { - DCHECK(!render_view_host_) << "BalloonViewHost already initialized."; - - int64 session_storage_namespace_id = balloon_->profile()->GetWebKitContext()-> - dom_storage_context()->AllocateSessionStorageNamespaceId(); - - render_view_host_ = new RenderViewHost(site_instance_.get(), - this, MSG_ROUTING_NONE, - session_storage_namespace_id); +gfx::NativeView BalloonViewHost::native_view() const { + return render_widget_host_view_->native_view(); +} +void BalloonViewHost::InitRenderWidgetHostView() { + DCHECK(render_view_host_); render_widget_host_view_ = new RenderWidgetHostViewGtk(render_view_host_); render_widget_host_view_->InitAsChild(); +} - render_view_host_->set_view(render_widget_host_view_); - render_view_host_->CreateRenderView(GetProfile()->GetRequestContext()); - render_view_host_->NavigateToURL(balloon_->notification().content_url()); - initialized_ = true; +RenderWidgetHostView* BalloonViewHost::render_widget_host_view() const { + return render_widget_host_view_; } diff --git a/chrome/browser/gtk/notifications/balloon_view_host_gtk.h b/chrome/browser/gtk/notifications/balloon_view_host_gtk.h index de71a41..833a78c 100644 --- a/chrome/browser/gtk/notifications/balloon_view_host_gtk.h +++ b/chrome/browser/gtk/notifications/balloon_view_host_gtk.h @@ -5,25 +5,16 @@ #ifndef CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_HOST_GTK_H_ #define CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_HOST_GTK_H_ -#include "chrome/browser/gtk/extension_view_gtk.h" -#include "chrome/browser/notifications/balloon.h" -#include "chrome/browser/notifications/notification.h" -#include "chrome/browser/renderer_host/render_view_host_delegate.h" -#include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" -#include "chrome/browser/renderer_host/site_instance.h" -#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" +#include "chrome/browser/notifications/balloon_host.h" #include "gfx/native_widget_types.h" -#include "webkit/glue/webpreferences.h" -class Profile; -class RenderViewHost; +class RenderWidgetHostViewGtk; // BalloonViewHost class is a delegate to the renderer host for the HTML // notification. When initialized it creates a new RenderViewHost and loads // the contents of the toast into it. It also handles links within the toast, // loading them into a new tab. -class BalloonViewHost : public RenderViewHostDelegate, - public RenderViewHostDelegate::View { +class BalloonViewHost : public BalloonHost { public: explicit BalloonViewHost(Balloon* balloon); @@ -31,104 +22,20 @@ class BalloonViewHost : public RenderViewHostDelegate, Shutdown(); } - // Initialize the view. - void Init(); - - // Stops showing the balloon. - void Shutdown(); - - // RenderViewHostDelegate overrides. - virtual WebPreferences GetWebkitPrefs(); - virtual RendererPreferences GetRendererPrefs(Profile* profile) const; - virtual SiteInstance* GetSiteInstance() const { - return site_instance_.get(); - } - virtual Profile* GetProfile() const { return balloon_->profile(); } - virtual const GURL& GetURL() const { - return balloon_->notification().content_url(); - } - virtual void RequestOpenURL(const GURL& url, const GURL& referrer, - WindowOpenDisposition disposition); - virtual void Close(RenderViewHost* render_view_host); - virtual void RenderViewCreated(RenderViewHost* render_view_host); - virtual void DidStopLoading() {} - virtual void RendererReady(RenderViewHost* render_view_host); - virtual void RendererGone(RenderViewHost* render_view_host); - virtual void UpdateTitle(RenderViewHost* /* render_view_host */, - int32 /* page_id */, const std::wstring& title) { - title_ = title; - } - virtual int GetBrowserWindowID() const { return -1; } - virtual ViewType::Type GetRenderViewType() const { - return ViewType::TAB_CONTENTS; - } - virtual RenderViewHostDelegate::View* GetViewDelegate() { - return this; - } - + // Changes the size of the balloon. void UpdateActualSize(const gfx::Size& new_size); - // RenderViewHostDelegate::View methods. Only the ones for opening new - // windows are currently implemented. - virtual void CreateNewWindow(int route_id); - virtual void CreateNewWidget(int route_id, bool activatable) {} - virtual void ShowCreatedWindow(int route_id, - WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, - bool user_gesture); - virtual void ShowCreatedWidget(int route_id, - const gfx::Rect& initial_pos) {} - virtual void ShowContextMenu(const ContextMenuParams& params) {} - virtual void StartDragging(const WebDropData& drop_data, - WebKit::WebDragOperationsMask allowed_ops, - const SkBitmap& image, - const gfx::Point& image_offset) {} - virtual void UpdateDragCursor(WebKit::WebDragOperation operation) {} - virtual void GotFocus() {} - virtual void TakeFocus(bool reverse) {} - virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, - bool* is_keyboard_shortcut) { - return false; - } - virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {} - virtual void HandleMouseEvent() {} - virtual void HandleMouseLeave() {} - virtual void UpdatePreferredSize(const gfx::Size& pref_size); - // Accessors. - RenderViewHost* render_view_host() const { return render_view_host_; } - gfx::NativeView native_view() const { - return render_widget_host_view_->native_view(); - } - const std::wstring& title() const { return title_; } - - private: - // True after Init() has completed. - bool initialized_; - - // Non-owned pointer to the associated balloon. - Balloon* balloon_; - - // Site instance for the balloon/profile, to be used for opening new links. - scoped_refptr<SiteInstance> site_instance_; + gfx::NativeView native_view() const; - // Owned pointer to to host for the renderer process. - RenderViewHost* render_view_host_; + protected: + virtual void InitRenderWidgetHostView(); + virtual RenderWidgetHostView* render_widget_host_view() const; - // Indicates whether we should notify about disconnection of this balloon. - // This is used to ensure disconnection notifications only happen if - // a connection notification has happened and that they happen only once. - bool should_notify_on_disconnect_; - - // The title of the balloon page. - std::wstring title_; - - // The GTK-specific widget host view. + private: + // The GTK-specific widget host view. Owned by its native view. RenderWidgetHostViewGtk* render_widget_host_view_; - // Common implementations of some RenderViewHostDelegate::View methods. - RenderViewHostDelegateViewHelper delegate_view_helper_; - DISALLOW_COPY_AND_ASSIGN(BalloonViewHost); }; diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc new file mode 100644 index 0000000..3b4a832 --- /dev/null +++ b/chrome/browser/notifications/balloon_host.cc @@ -0,0 +1,131 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/notifications/balloon_host.h" + +#include "chrome/browser/browser_list.h" +#include "chrome/browser/in_process_webkit/webkit_context.h" +#include "chrome/browser/extensions/extension_process_manager.h" +#include "chrome/browser/notifications/balloon.h" +#include "chrome/browser/profile.h" +#include "chrome/browser/renderer_host/render_view_host.h" +#include "chrome/browser/renderer_host/site_instance.h" +#include "chrome/browser/renderer_preferences_util.h" +#include "chrome/common/bindings_policy.h" +#include "chrome/common/notification_service.h" +#include "chrome/common/notification_type.h" +#include "chrome/common/render_messages.h" +#include "chrome/common/renderer_preferences.h" +#include "chrome/common/url_constants.h" + +BalloonHost::BalloonHost(Balloon* balloon) + : render_view_host_(NULL), + balloon_(balloon), + initialized_(false), + should_notify_on_disconnect_(false), + is_extension_page_(false) { + DCHECK(balloon_); + + // If the notification is for an extension URL, make sure to use the extension + // process to render it, so that it can communicate with other views in the + // extension. + const GURL& balloon_url = balloon_->notification().content_url(); + if (balloon_url.SchemeIs(chrome::kExtensionScheme)) { + is_extension_page_ = true; + site_instance_ = + balloon_->profile()->GetExtensionProcessManager()->GetSiteInstanceForURL( + balloon_url); + } else { + site_instance_ = SiteInstance::CreateSiteInstance(balloon_->profile()); + } +} + +void BalloonHost::Shutdown() { + if (render_view_host_) { + render_view_host_->Shutdown(); + render_view_host_ = NULL; + } +} + +WebPreferences BalloonHost::GetWebkitPrefs() { + WebPreferences prefs; + prefs.allow_scripts_to_close_windows = true; + return prefs; +} + +void BalloonHost::Close(RenderViewHost* render_view_host) { + balloon_->CloseByScript(); +} + + +void BalloonHost::RenderViewCreated(RenderViewHost* render_view_host) { + render_view_host->Send(new ViewMsg_EnablePreferredSizeChangedMode( + render_view_host->routing_id())); +} + +void BalloonHost::RendererReady(RenderViewHost* render_view_host) { + should_notify_on_disconnect_ = true; + NotificationService::current()->Notify( + NotificationType::NOTIFY_BALLOON_CONNECTED, + Source<Balloon>(balloon_), NotificationService::NoDetails()); +} + +void BalloonHost::RendererGone(RenderViewHost* render_view_host) { + if (!should_notify_on_disconnect_) + return; + + should_notify_on_disconnect_ = false; + NotificationService::current()->Notify( + NotificationType::NOTIFY_BALLOON_DISCONNECTED, + Source<Balloon>(balloon_), NotificationService::NoDetails()); +} + +// RenderViewHostDelegate::View methods implemented to allow links to +// open pages in new tabs. +void BalloonHost::CreateNewWindow(int route_id) { + delegate_view_helper_.CreateNewWindow( + route_id, balloon_->profile(), site_instance_.get(), + DOMUIFactory::GetDOMUIType(balloon_->notification().content_url()), NULL); +} + +void BalloonHost::ShowCreatedWindow(int route_id, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture) { + // Don't allow pop-ups from notifications. + if (disposition == NEW_POPUP) + return; + + TabContents* contents = delegate_view_helper_.GetCreatedWindow(route_id); + if (contents) { + Browser* browser = BrowserList::GetLastActive(); + browser->AddTabContents(contents, disposition, initial_pos, user_gesture); + } +} + +void BalloonHost::UpdatePreferredSize(const gfx::Size& new_size) { + balloon_->SetContentPreferredSize(new_size); +} + +void BalloonHost::Init() { + DCHECK(!render_view_host_) << "BalloonViewHost already initialized."; + int64 session_storage_namespace_id = balloon_->profile()->GetWebKitContext()-> + dom_storage_context()->AllocateSessionStorageNamespaceId(); + RenderViewHost* rvh = new RenderViewHost(site_instance_.get(), + this, MSG_ROUTING_NONE, + session_storage_namespace_id); + if (is_extension_page_) + rvh->AllowBindings(BindingsPolicy::EXTENSION); + + // Do platform-specific initialization. + render_view_host_ = rvh; + InitRenderWidgetHostView(); + DCHECK(render_widget_host_view()); + + rvh->set_view(render_widget_host_view()); + rvh->CreateRenderView(GetProfile()->GetRequestContext()); + rvh->NavigateToURL(balloon_->notification().content_url()); + + initialized_ = true; +} diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h new file mode 100644 index 0000000..b42ea46 --- /dev/null +++ b/chrome/browser/notifications/balloon_host.h @@ -0,0 +1,116 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_ +#define CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_ + +#include "chrome/browser/notifications/balloon.h" +#include "chrome/browser/notifications/notification.h" +#include "chrome/browser/renderer_host/render_view_host_delegate.h" +#include "chrome/browser/renderer_host/site_instance.h" +#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" +#include "chrome/common/renderer_preferences.h" +#include "webkit/glue/webpreferences.h" + +class Profile; + +class BalloonHost : public RenderViewHostDelegate, + public RenderViewHostDelegate::View { + public: + explicit BalloonHost(Balloon* balloon); + + // Initialize the view. + void Init(); + + // Stops showing the balloon. + void Shutdown(); + + RenderViewHost* render_view_host() const { return render_view_host_; } + + // RenderViewHostDelegate overrides. + virtual WebPreferences GetWebkitPrefs(); + virtual SiteInstance* GetSiteInstance() const { + return site_instance_.get(); + } + virtual Profile* GetProfile() const { return balloon_->profile(); } + virtual const GURL& GetURL() const { + return balloon_->notification().content_url(); + } + virtual void Close(RenderViewHost* render_view_host); + virtual void RenderViewCreated(RenderViewHost* render_view_host); + virtual void RendererReady(RenderViewHost* render_view_host); + virtual void RendererGone(RenderViewHost* render_view_host); + virtual void UpdateTitle(RenderViewHost* render_view_host, + int32 page_id, const std::wstring& title) {} + virtual int GetBrowserWindowID() const { return -1; } + virtual ViewType::Type GetRenderViewType() const { + return ViewType::TAB_CONTENTS; + } + virtual RenderViewHostDelegate::View* GetViewDelegate() { + return this; + } + + // RenderViewHostDelegate::View methods. Only the ones for opening new + // windows are currently implemented. + virtual void CreateNewWindow(int route_id); + virtual void CreateNewWidget(int route_id, bool activatable) {} + virtual void ShowCreatedWindow(int route_id, + WindowOpenDisposition disposition, + const gfx::Rect& initial_pos, + bool user_gesture); + virtual void ShowCreatedWidget(int route_id, + const gfx::Rect& initial_pos) {} + virtual void ShowContextMenu(const ContextMenuParams& params) {} + virtual void StartDragging(const WebDropData& drop_data, + WebKit::WebDragOperationsMask allowed_ops) {} + virtual void StartDragging(const WebDropData&, + WebKit::WebDragOperationsMask, + const SkBitmap&, + const gfx::Point&) {} + virtual void UpdateDragCursor(WebKit::WebDragOperation operation) {} + virtual void GotFocus() {} + virtual void TakeFocus(bool reverse) {} + virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, + bool* is_keyboard_shortcut) { + return false; + } + virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {} + virtual void HandleMouseEvent() {} + virtual void HandleMouseLeave() {} + virtual void UpdatePreferredSize(const gfx::Size& pref_size); + virtual RendererPreferences GetRendererPrefs(Profile* profile) const { + return RendererPreferences(); + } + + protected: + // Must override in platform specific implementations. + virtual void InitRenderWidgetHostView() = 0; + virtual RenderWidgetHostView* render_widget_host_view() const = 0; + + // Owned pointer to the host for the renderer process. + RenderViewHost* render_view_host_; + + private: + // Non-owned pointer to the associated balloon. + Balloon* balloon_; + + // True after Init() has completed. + bool initialized_; + + // Indicates whether we should notify about disconnection of this balloon. + // This is used to ensure disconnection notifications only happen if + // a connection notification has happened and that they happen only once. + bool should_notify_on_disconnect_; + + // Whether the page we are rendering is from an extension. + bool is_extension_page_; + + // Site instance for the balloon/profile, to be used for opening new links. + scoped_refptr<SiteInstance> site_instance_; + + // Common implementations of some RenderViewHostDelegate::View methods. + RenderViewHostDelegateViewHelper delegate_view_helper_; +}; + +#endif // CHROME_BROWSER_NOTIFICATIONS_BALLOON_HOST_H_ diff --git a/chrome/browser/views/notifications/balloon_view.cc b/chrome/browser/views/notifications/balloon_view.cc index d0e27fa..cc0c222 100644 --- a/chrome/browser/views/notifications/balloon_view.cc +++ b/chrome/browser/views/notifications/balloon_view.cc @@ -315,7 +315,7 @@ void BalloonViewImpl::Show(Balloon* balloon) { Widget::DeleteOnDestroy); html_container_->SetAlwaysOnTop(true); html_container_->Init(NULL, contents_rect); - html_container_->SetContentsView(html_contents_); + html_container_->SetContentsView(html_contents_->view()); gfx::Rect balloon_rect(x(), y(), width(), height()); frame_container_ = Widget::CreatePopupWidget(Widget::Transparent, diff --git a/chrome/browser/views/notifications/balloon_view_host.cc b/chrome/browser/views/notifications/balloon_view_host.cc index ea8d55d..22fe5de 100644 --- a/chrome/browser/views/notifications/balloon_view_host.cc +++ b/chrome/browser/views/notifications/balloon_view_host.cc @@ -4,14 +4,7 @@ #include "chrome/browser/views/notifications/balloon_view_host.h" -#include "base/string_util.h" -#include "chrome/browser/browser_list.h" -#include "chrome/browser/extensions/extension_process_manager.h" -#include "chrome/browser/in_process_webkit/dom_storage_context.h" -#include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/notifications/balloon.h" -#include "chrome/browser/notifications/notification.h" -#include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/renderer_host/render_widget_host_view.h" #if defined(OS_WIN) @@ -20,13 +13,6 @@ #if defined(OS_LINUX) #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" #endif -#include "chrome/browser/renderer_host/site_instance.h" -#include "chrome/common/bindings_policy.h" -#include "chrome/common/notification_service.h" -#include "chrome/common/notification_type.h" -#include "chrome/common/render_messages.h" -#include "chrome/common/renderer_preferences.h" -#include "chrome/common/url_constants.h" #include "views/widget/widget.h" #if defined(OS_WIN) #include "views/widget/widget_win.h" @@ -35,138 +21,60 @@ #include "views/widget/widget_gtk.h" #endif -BalloonViewHost::BalloonViewHost(Balloon* balloon) - : initialized_(false), - balloon_(balloon), - render_view_host_(NULL), - should_notify_on_disconnect_(false), - is_extension_page_(false) { - DCHECK(balloon_); - - // If the notification is for an extension URL, make sure to use the extension - // process to render it, so that it can communicate with other views in the - // extension. - const GURL& balloon_url = balloon_->notification().content_url(); - if (balloon_url.SchemeIs(chrome::kExtensionScheme)) { - is_extension_page_ = true; - site_instance_ = - balloon_->profile()->GetExtensionProcessManager()->GetSiteInstanceForURL( - balloon_url); - } else { - site_instance_ = SiteInstance::CreateSiteInstance(balloon_->profile()); +class BalloonViewHostView : public views::NativeViewHost { + public: + explicit BalloonViewHostView(BalloonViewHost* host) + : host_(host), + initialized_(false) { } -} -void BalloonViewHost::Shutdown() { - if (render_view_host_) { - render_view_host_->Shutdown(); - render_view_host_ = NULL; + virtual void ViewHierarchyChanged(bool is_add, + views::View* parent, + views::View* child) { + NativeViewHost::ViewHierarchyChanged(is_add, parent, child); + if (is_add && GetWidget() && !initialized_) + host_->Init(GetWidget()->GetNativeView()); + initialized_ = true; } -} - -WebPreferences BalloonViewHost::GetWebkitPrefs() { - WebPreferences prefs; - prefs.allow_scripts_to_close_windows = true; - return prefs; -} -void BalloonViewHost::Close(RenderViewHost* render_view_host) { - balloon_->CloseByScript(); -} - -void BalloonViewHost::RenderViewCreated(RenderViewHost* render_view_host) { - render_view_host->Send(new ViewMsg_EnablePreferredSizeChangedMode( - render_view_host->routing_id())); -} + private: + // The host owns this object. + BalloonViewHost* host_; -void BalloonViewHost::RendererReady(RenderViewHost* /* render_view_host */) { - should_notify_on_disconnect_ = true; - NotificationService::current()->Notify( - NotificationType::NOTIFY_BALLOON_CONNECTED, - Source<Balloon>(balloon_), NotificationService::NoDetails()); -} - -void BalloonViewHost::RendererGone(RenderViewHost* /* render_view_host */) { - if (!should_notify_on_disconnect_) - return; + bool initialized_; +}; - should_notify_on_disconnect_ = false; - NotificationService::current()->Notify( - NotificationType::NOTIFY_BALLOON_DISCONNECTED, - Source<Balloon>(balloon_), NotificationService::NoDetails()); -} - -// RenderViewHostDelegate::View methods implemented to allow links to -// open pages in new tabs. -void BalloonViewHost::CreateNewWindow(int route_id) { - delegate_view_helper_.CreateNewWindow( - route_id, balloon_->profile(), site_instance_.get(), - DOMUIFactory::GetDOMUIType(balloon_->notification().content_url()), NULL); +BalloonViewHost::BalloonViewHost(Balloon* balloon) + : BalloonHost(balloon) { + native_host_.reset(new BalloonViewHostView(this)); } -void BalloonViewHost::ShowCreatedWindow(int route_id, - WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, - bool user_gesture) { - // Don't allow pop-ups from notifications. - if (disposition == NEW_POPUP) - return; - - TabContents* contents = delegate_view_helper_.GetCreatedWindow(route_id); - if (contents) { - Browser* browser = BrowserList::GetLastActive(); - browser->AddTabContents(contents, disposition, initial_pos, user_gesture); - } +void BalloonViewHost::Init(gfx::NativeView parent_native_view) { + parent_native_view_ = parent_native_view; + BalloonHost::Init(); } -void BalloonViewHost::UpdatePreferredSize(const gfx::Size& new_size) { - balloon_->SetContentPreferredSize(new_size); -} +void BalloonViewHost::InitRenderWidgetHostView() { + DCHECK(render_view_host_); -void BalloonViewHost::Init(gfx::NativeView parent_hwnd) { - DCHECK(!render_view_host_) << "BalloonViewHost already initialized."; - int64 session_storage_namespace_id = balloon_->profile()->GetWebKitContext()-> - dom_storage_context()->AllocateSessionStorageNamespaceId(); - RenderViewHost* rvh = new RenderViewHost(site_instance_.get(), - this, MSG_ROUTING_NONE, - session_storage_namespace_id); - render_view_host_ = rvh; - - if (is_extension_page_) { - rvh->AllowBindings(BindingsPolicy::EXTENSION); - } - - // Pointer is owned by the RVH. - RenderWidgetHostView* view = RenderWidgetHostView::CreateViewForWidget(rvh); - rvh->set_view(view); + render_widget_host_view_ = + RenderWidgetHostView::CreateViewForWidget(render_view_host_); // TODO(johnnyg): http://crbug.com/23954. Need a cross-platform solution. #if defined(OS_WIN) RenderWidgetHostViewWin* view_win = - static_cast<RenderWidgetHostViewWin*>(view); + static_cast<RenderWidgetHostViewWin*>(render_widget_host_view_); // Create the HWND. - HWND hwnd = view_win->Create(parent_hwnd); + HWND hwnd = view_win->Create(parent_native_view_); view_win->ShowWindow(SW_SHOW); - Attach(hwnd); + native_host_->Attach(hwnd); #elif defined(OS_LINUX) RenderWidgetHostViewGtk* view_gtk = - static_cast<RenderWidgetHostViewGtk*>(view); + static_cast<RenderWidgetHostViewGtk*>(render_widget_host_view_); view_gtk->InitAsChild(); - Attach(view_gtk->native_view()); + native_host_->Attach(view_gtk->native_view()); #else NOTIMPLEMENTED(); #endif - - // Start up the renderer and point it at the balloon contents URL. - rvh->CreateRenderView(GetProfile()->GetRequestContext()); - rvh->NavigateToURL(balloon_->notification().content_url()); - initialized_ = true; -} - -void BalloonViewHost::ViewHierarchyChanged(bool is_add, views::View* parent, - views::View* child) { - NativeViewHost::ViewHierarchyChanged(is_add, parent, child); - if (is_add && GetWidget() && !initialized_) - Init(GetWidget()->GetNativeView()); } diff --git a/chrome/browser/views/notifications/balloon_view_host.h b/chrome/browser/views/notifications/balloon_view_host.h index 84610a0..0ed90f9 100644 --- a/chrome/browser/views/notifications/balloon_view_host.h +++ b/chrome/browser/views/notifications/balloon_view_host.h @@ -5,29 +5,14 @@ #ifndef CHROME_BROWSER_VIEWS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_ #define CHROME_BROWSER_VIEWS_NOTIFICATIONS_BALLOON_VIEW_HOST_H_ -#include "chrome/browser/notifications/balloon.h" -#include "chrome/browser/notifications/notification.h" -#include "chrome/browser/renderer_host/render_view_host_delegate.h" -#include "chrome/browser/renderer_host/site_instance.h" -#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" -#include "chrome/common/renderer_preferences.h" +#include "chrome/browser/notifications/balloon_host.h" #include "views/controls/native/native_view_host.h" -#include "webkit/glue/webpreferences.h" - -class Profile; -class RenderViewHost; -class SkBitmap; -namespace gfx { -class Point; -} // BalloonViewHost class is a delegate to the renderer host for the HTML // notification. When initialized it creates a new RenderViewHost and loads // the contents of the toast into it. It also handles links within the toast, // loading them into a new tab. -class BalloonViewHost : public views::NativeViewHost, - public RenderViewHostDelegate, - public RenderViewHostDelegate::View { +class BalloonViewHost : public BalloonHost { public: explicit BalloonViewHost(Balloon* balloon); @@ -35,102 +20,37 @@ class BalloonViewHost : public views::NativeViewHost, Shutdown(); } - // Stops showing the balloon. - void Shutdown(); - - // RenderViewHostDelegate overrides. - virtual WebPreferences GetWebkitPrefs(); - virtual SiteInstance* GetSiteInstance() const { - return site_instance_.get(); - } - virtual Profile* GetProfile() const { return balloon_->profile(); } - virtual const GURL& GetURL() const { - return balloon_->notification().content_url(); - } - virtual void Close(RenderViewHost* render_view_host); - virtual void RenderViewCreated(RenderViewHost* render_view_host); - virtual void RendererReady(RenderViewHost* render_view_host); - virtual void RendererGone(RenderViewHost* render_view_host); - virtual void UpdateTitle(RenderViewHost* /* render_view_host */, - int32 /* page_id */, const std::wstring& title) { - title_ = title; - } - virtual int GetBrowserWindowID() const { return -1; } - virtual ViewType::Type GetRenderViewType() const { - return ViewType::TAB_CONTENTS; - } - virtual RenderViewHostDelegate::View* GetViewDelegate() { - return this; - } - - // RenderViewHostDelegate::View methods. Only the ones for opening new - // windows are currently implemented. - virtual void CreateNewWindow(int route_id); - virtual void CreateNewWidget(int route_id, bool activatable) {} - virtual void ShowCreatedWindow(int route_id, - WindowOpenDisposition disposition, - const gfx::Rect& initial_pos, - bool user_gesture); - virtual void ShowCreatedWidget(int route_id, - const gfx::Rect& initial_pos) {} - virtual void ShowContextMenu(const ContextMenuParams& params) {} - virtual void StartDragging(const WebDropData& drop_data, - WebKit::WebDragOperationsMask allowed_ops, - const SkBitmap& image, - const gfx::Point& image_offset) {} - virtual void UpdateDragCursor(WebKit::WebDragOperation operation) {} - virtual void GotFocus() {} - virtual void TakeFocus(bool reverse) {} - virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, - bool* is_keyboard_shortcut) { - return false; - } - virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {} - virtual void HandleMouseEvent() {} - virtual void HandleMouseLeave() {} - virtual void UpdatePreferredSize(const gfx::Size& pref_size); - virtual RendererPreferences GetRendererPrefs(Profile* profile) const { - return RendererPreferences(); + void SetPreferredSize(const gfx::Size& size) { + native_host_->SetPreferredSize(size); } // Accessors. - RenderViewHost* render_view_host() const { return render_view_host_; } - const std::wstring& title() const { return title_; } + views::View* view() { + return native_host_.get(); + } - private: - // View overrides. - virtual void ViewHierarchyChanged(bool is_add, - views::View *parent, - views::View *child); + gfx::NativeView native_view() const { + return native_host_->native_view(); + } // Initialize the view, parented to |parent|, and show it. void Init(gfx::NativeView parent); - // True after Init() has completed. - bool initialized_; - - // Non-owned pointer to the associated balloon. - Balloon* balloon_; - - // Site instance for the balloon/profile, to be used for opening new links. - scoped_refptr<SiteInstance> site_instance_; - - // Owned pointer to to host for the renderer process. - RenderViewHost* render_view_host_; - - // Indicates whether we should notify about disconnection of this balloon. - // This is used to ensure disconnection notifications only happen if - // a connection notification has happened and that they happen only once. - bool should_notify_on_disconnect_; + protected: + virtual void InitRenderWidgetHostView(); + virtual RenderWidgetHostView* render_widget_host_view() const { + return render_widget_host_view_; + } - // The title of the balloon page. - std::wstring title_; + private: + // The platform-specific widget host view. Pointer is owned by the RVH. + RenderWidgetHostView* render_widget_host_view_; - // Whether the page we are rendering is from an extension. - bool is_extension_page_; + // The views-specific host view. + scoped_ptr<views::NativeViewHost> native_host_; - // Common implementations of some RenderViewHostDelegate::View methods. - RenderViewHostDelegateViewHelper delegate_view_helper_; + // The handle to the parent view. + gfx::NativeView parent_native_view_; DISALLOW_COPY_AND_ASSIGN(BalloonViewHost); }; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index cb2f030..ec32bc3 100755 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1568,6 +1568,8 @@ 'browser/net/websocket_experiment/websocket_experiment_task.h', 'browser/notifications/balloon.cc', 'browser/notifications/balloon.h', + 'browser/notifications/balloon_host.h', + 'browser/notifications/balloon_host.cc', 'browser/notifications/balloon_collection.cc', 'browser/notifications/balloon_collection.h', 'browser/notifications/balloon_collection_impl.h', @@ -2661,7 +2663,7 @@ ['exclude', '^browser/views/'], ], 'conditions': [ - ['OS=="linux" and (toolkit_views==1 or chromeos==1)',{ + ['OS=="linux" and (toolkit_views==1 or chromeos==1)',{ 'dependencies': [ '../views/views.gyp:views', ], |