summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 18:51:43 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 18:51:43 +0000
commit32ded2218dcf2047dee5964685060123cd7d61de (patch)
treefae56a775ba5bcb78da22f10aefd190e105bb98b /chrome
parent1504529f3f4b305890b0efb9a87891c05cd283d3 (diff)
downloadchromium_src-32ded2218dcf2047dee5964685060123cd7d61de.zip
chromium_src-32ded2218dcf2047dee5964685060123cd7d61de.tar.gz
chromium_src-32ded2218dcf2047dee5964685060123cd7d61de.tar.bz2
Make BalloonHost use TabContents instead of RenderViewHost.
BUG=99700,98716 Review URL: http://codereview.chromium.org/8439021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109468 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/automation/automation_provider_observers.cc6
-rw-r--r--chrome/browser/chromeos/notifications/balloon_view.cc17
-rw-r--r--chrome/browser/chromeos/notifications/balloon_view_host.cc2
-rw-r--r--chrome/browser/chromeos/notifications/balloon_view_host.h4
-rw-r--r--chrome/browser/notifications/balloon_host.cc133
-rw-r--r--chrome/browser/notifications/balloon_host.h75
-rw-r--r--chrome/browser/tab_contents/render_view_host_delegate_helper.cc4
-rw-r--r--chrome/browser/task_manager/task_manager_notification_resource_provider.cc9
-rw-r--r--chrome/browser/ui/cocoa/notifications/balloon_controller.mm14
-rw-r--r--chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.h8
-rw-r--r--chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.mm16
-rw-r--r--chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc9
-rw-r--r--chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.cc19
-rw-r--r--chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.h7
-rw-r--r--chrome/browser/ui/views/notifications/balloon_view.cc15
-rw-r--r--chrome/browser/ui/views/notifications/balloon_view_host.cc45
-rw-r--r--chrome/browser/ui/views/notifications/balloon_view_host.h7
17 files changed, 124 insertions, 266 deletions
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc
index 78f24b5..aa0fe0b 100644
--- a/chrome/browser/automation/automation_provider_observers.cc
+++ b/chrome/browser/automation/automation_provider_observers.cc
@@ -2459,8 +2459,10 @@ void GetAllNotificationsObserver::SendMessage() {
base::DictionaryValue* note = NotificationToJson(
&(*balloon_iter)->notification());
BalloonView* view = (*balloon_iter)->view();
- note->SetInteger("pid", base::GetProcId(
- view->GetHost()->render_view_host()->process()->GetHandle()));
+ note->SetInteger(
+ "pid",
+ base::GetProcId(view->GetHost()->tab_contents()->render_view_host()->
+ process()-> GetHandle()));
list->Append(note);
}
std::vector<const Notification*> queued_notes;
diff --git a/chrome/browser/chromeos/notifications/balloon_view.cc b/chrome/browser/chromeos/notifications/balloon_view.cc
index a14e2cb..24c8ddd 100644
--- a/chrome/browser/chromeos/notifications/balloon_view.cc
+++ b/chrome/browser/chromeos/notifications/balloon_view.cc
@@ -21,6 +21,7 @@
#include "chrome/common/chrome_notification_types.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
+#include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "grit/generated_resources.h"
@@ -234,9 +235,11 @@ void BalloonViewImpl::Show(Balloon* balloon) {
void BalloonViewImpl::Update() {
stale_ = false;
- if (html_contents_->render_view_host())
- html_contents_->render_view_host()->NavigateToURL(
- balloon_->notification().content_url());
+ if (!html_contents_->tab_contents())
+ return;
+ html_contents_->tab_contents()->controller().LoadURL(
+ balloon_->notification().content_url(), GURL(),
+ content::PAGE_TRANSITION_LINK, std::string());
}
void BalloonViewImpl::Close(bool by_user) {
@@ -268,8 +271,9 @@ void BalloonViewImpl::Layout() {
SetBounds(x(), y(), size.width(), size.height());
html_contents_->view()->SetBounds(0, 0, size.width(), size.height());
- if (html_contents_->render_view_host()) {
- RenderWidgetHostView* view = html_contents_->render_view_host()->view();
+ if (html_contents_->tab_contents()) {
+ RenderWidgetHostView* view =
+ html_contents_->tab_contents()->render_view_host()->view();
if (view)
view->SetSize(size);
}
@@ -359,7 +363,8 @@ void BalloonViewImpl::DenyPermission() {
}
gfx::NativeView BalloonViewImpl::GetParentNativeView() {
- RenderWidgetHostView* view = html_contents_->render_view_host()->view();
+ RenderWidgetHostView* view =
+ html_contents_->tab_contents()->render_view_host()->view();
DCHECK(view);
return view->GetNativeView();
}
diff --git a/chrome/browser/chromeos/notifications/balloon_view_host.cc b/chrome/browser/chromeos/notifications/balloon_view_host.cc
index 177df72..bc05c34 100644
--- a/chrome/browser/chromeos/notifications/balloon_view_host.cc
+++ b/chrome/browser/chromeos/notifications/balloon_view_host.cc
@@ -30,7 +30,7 @@ bool BalloonViewHost::AddWebUIMessageCallback(
return ret.second;
}
-void BalloonViewHost::WebUISend(RenderViewHost* render_view_host,
+void BalloonViewHost::WebUISend(TabContents* tab,
const GURL& source_url,
const std::string& name,
const ListValue& args) {
diff --git a/chrome/browser/chromeos/notifications/balloon_view_host.h b/chrome/browser/chromeos/notifications/balloon_view_host.h
index 738b989..eca3f1d 100644
--- a/chrome/browser/chromeos/notifications/balloon_view_host.h
+++ b/chrome/browser/chromeos/notifications/balloon_view_host.h
@@ -38,8 +38,8 @@ class BalloonViewHost : public ::BalloonViewHost {
const MessageCallback& callback);
private:
- // RenderViewHostDelegate
- virtual void WebUISend(RenderViewHost* render_view_host,
+ // TabContentsDelegate
+ virtual void WebUISend(TabContents* tab,
const GURL& source_url,
const std::string& name,
const base::ListValue& args) OVERRIDE;
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc
index 9109d15..ee586cc 100644
--- a/chrome/browser/notifications/balloon_host.cc
+++ b/chrome/browser/notifications/balloon_host.cc
@@ -17,8 +17,9 @@
#include "content/browser/renderer_host/browser_render_process_host.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/site_instance.h"
-#include "content/public/browser/notification_service.h"
+#include "content/browser/tab_contents/tab_contents.h"
#include "content/common/view_messages.h"
+#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/common/bindings_policy.h"
#include "content/public/common/renderer_preferences.h"
@@ -26,24 +27,19 @@
#include "webkit/glue/webpreferences.h"
BalloonHost::BalloonHost(Balloon* balloon)
- : render_view_host_(NULL),
- balloon_(balloon),
+ : balloon_(balloon),
initialized_(false),
should_notify_on_disconnect_(false),
enable_web_ui_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(
extension_function_dispatcher_(balloon_->profile(), this)) {
- CHECK(balloon_);
- site_instance_ = SiteInstance::CreateSiteInstanceForURL(balloon_->profile(),
- GetURL());
+ site_instance_ = SiteInstance::CreateSiteInstanceForURL(
+ balloon_->profile(), balloon_->notification().content_url());
}
void BalloonHost::Shutdown() {
NotifyDisconnect();
- if (render_view_host_) {
- render_view_host_->Shutdown();
- render_view_host_ = NULL;
- }
+ tab_contents_.reset();
}
Browser* BalloonHost::GetBrowser() {
@@ -64,20 +60,18 @@ const string16& BalloonHost::GetSource() const {
return balloon_->notification().display_source();
}
-WebPreferences BalloonHost::GetWebkitPrefs() {
- WebPreferences web_prefs =
- RenderViewHostDelegateHelper::GetWebkitPrefs(render_view_host_);
- web_prefs.allow_scripts_to_close_windows = true;
- return web_prefs;
+void BalloonHost::CloseContents(TabContents* source) {
+ balloon_->CloseByScript();
+ NotifyDisconnect();
}
-const GURL& BalloonHost::GetURL() const {
- return balloon_->notification().content_url();
+void BalloonHost::HandleMouseDown() {
+ balloon_->OnClick();
}
-void BalloonHost::Close(RenderViewHost* render_view_host) {
- balloon_->CloseByScript();
- NotifyDisconnect();
+void BalloonHost::UpdatePreferredSize(TabContents* source,
+ const gfx::Size& pref_size) {
+ balloon_->SetContentPreferredSize(pref_size);
}
void BalloonHost::RenderViewCreated(RenderViewHost* render_view_host) {
@@ -86,9 +80,12 @@ void BalloonHost::RenderViewCreated(RenderViewHost* render_view_host) {
render_view_host->WasResized();
render_view_host->EnablePreferredSizeMode(
kPreferredSizeWidth | kPreferredSizeHeightThisIsSlow);
+
+ if (enable_web_ui_)
+ render_view_host->AllowBindings(content::BINDINGS_POLICY_WEB_UI);
}
-void BalloonHost::RenderViewReady(RenderViewHost* render_view_host) {
+void BalloonHost::RenderViewReady() {
should_notify_on_disconnect_ = true;
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_NOTIFY_BALLOON_CONNECTED,
@@ -96,18 +93,8 @@ void BalloonHost::RenderViewReady(RenderViewHost* render_view_host) {
content::NotificationService::NoDetails());
}
-void BalloonHost::RenderViewGone(RenderViewHost* render_view_host,
- base::TerminationStatus status,
- int error_code) {
- Close(render_view_host);
-}
-
-content::ViewType BalloonHost::GetRenderViewType() const {
- return chrome::VIEW_TYPE_NOTIFICATION;
-}
-
-RenderViewHostDelegate::View* BalloonHost::GetViewDelegate() {
- return this;
+void BalloonHost::RenderViewGone() {
+ CloseContents(tab_contents_.get());
}
bool BalloonHost::OnMessageReceived(const IPC::Message& message) {
@@ -120,86 +107,36 @@ bool BalloonHost::OnMessageReceived(const IPC::Message& message) {
}
void BalloonHost::OnRequest(const ExtensionHostMsg_Request_Params& params) {
- extension_function_dispatcher_.Dispatch(params, render_view_host_);
+ extension_function_dispatcher_.Dispatch(params,
+ tab_contents_->render_view_host());
}
-// RenderViewHostDelegate::View methods implemented to allow links to
-// open pages in new tabs.
-void BalloonHost::CreateNewWindow(
- int route_id,
- const ViewHostMsg_CreateWindow_Params& params) {
- delegate_view_helper_.CreateNewWindow(
- route_id,
+void BalloonHost::Init() {
+ DCHECK(!tab_contents_.get()) << "BalloonViewHost already initialized.";
+ tab_contents_.reset(new TabContents(
balloon_->profile(),
site_instance_.get(),
- ChromeWebUIFactory::GetInstance()->GetWebUIType(balloon_->profile(),
- balloon_->notification().content_url()),
- this,
- params.window_container_type,
- params.frame_name);
-}
-
-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)
- return;
- Browser* browser = BrowserList::GetLastActiveWithProfile(balloon_->profile());
- if (!browser)
- return;
-
- browser->AddTabContents(contents, disposition, initial_pos, user_gesture);
-}
-
-void BalloonHost::UpdatePreferredSize(const gfx::Size& new_size) {
- balloon_->SetContentPreferredSize(new_size);
-}
-
-void BalloonHost::HandleMouseDown() {
- balloon_->OnClick();
-}
-
-content::RendererPreferences BalloonHost::GetRendererPrefs(
- content::BrowserContext* browser_context) const {
- Profile* profile = Profile::FromBrowserContext(browser_context);
- content::RendererPreferences preferences;
- renderer_preferences_util::UpdateFromSystemSettings(&preferences, profile);
- return preferences;
-}
-
-void BalloonHost::Init() {
- DCHECK(!render_view_host_) << "BalloonViewHost already initialized.";
- RenderViewHost* rvh = new RenderViewHost(
- site_instance_.get(), this, MSG_ROUTING_NONE, NULL);
- if (enable_web_ui_)
- rvh->AllowBindings(content::BINDINGS_POLICY_WEB_UI);
-
- // Do platform-specific initialization.
- render_view_host_ = rvh;
- InitRenderWidgetHostView();
- DCHECK(render_widget_host_view());
+ MSG_ROUTING_NONE,
+ NULL,
+ NULL));
+ tab_contents_->set_view_type(chrome::VIEW_TYPE_NOTIFICATION);
+ tab_contents_->set_delegate(this);
+ Observe(tab_contents_.get());
- rvh->SetView(render_widget_host_view());
- rvh->CreateRenderView(string16());
- rvh->NavigateToURL(balloon_->notification().content_url());
+ tab_contents_->controller().LoadURL(
+ balloon_->notification().content_url(), GURL(),
+ content::PAGE_TRANSITION_LINK, std::string());
initialized_ = true;
}
void BalloonHost::EnableWebUI() {
- DCHECK(render_view_host_ == NULL) <<
+ DCHECK(!tab_contents_.get()) <<
"EnableWebUI has to be called before a renderer is created.";
enable_web_ui_ = true;
}
BalloonHost::~BalloonHost() {
- DCHECK(!render_view_host_);
}
void BalloonHost::NotifyDisconnect() {
diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h
index e55cefa..06b5cdb 100644
--- a/chrome/browser/notifications/balloon_host.h
+++ b/chrome/browser/notifications/balloon_host.h
@@ -12,8 +12,9 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/extension_function_dispatcher.h"
-#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
+#include "content/browser/tab_contents/tab_contents_delegate.h"
+#include "content/browser/tab_contents/tab_contents_observer.h"
#include "content/public/browser/notification_registrar.h"
class Balloon;
@@ -26,8 +27,8 @@ namespace IPC {
class Message;
}
-class BalloonHost : public RenderViewHostDelegate,
- public RenderViewHostDelegate::View,
+class BalloonHost : public TabContentsDelegate,
+ public TabContentsObserver,
public ExtensionFunctionDispatcher::Delegate {
public:
explicit BalloonHost(Balloon* balloon);
@@ -43,55 +44,9 @@ class BalloonHost : public RenderViewHostDelegate,
virtual gfx::NativeView GetNativeViewOfHost();
virtual TabContents* GetAssociatedTabContents() const;
- RenderViewHost* render_view_host() const { return render_view_host_; }
-
const string16& GetSource() const;
- // RenderViewHostDelegate overrides.
- virtual WebPreferences GetWebkitPrefs() OVERRIDE;
- virtual const GURL& GetURL() const OVERRIDE;
- virtual void Close(RenderViewHost* render_view_host) OVERRIDE;
- virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
- virtual void RenderViewReady(RenderViewHost* render_view_host) OVERRIDE;
- virtual void RenderViewGone(RenderViewHost* render_view_host,
- base::TerminationStatus status,
- int error_code) OVERRIDE;
- virtual content::ViewType GetRenderViewType() const OVERRIDE;
- virtual RenderViewHostDelegate::View* GetViewDelegate() OVERRIDE;
- virtual void HandleMouseDown() OVERRIDE;
- virtual content::RendererPreferences GetRendererPrefs(
- content::BrowserContext* browser_context) const OVERRIDE;
- virtual void UpdatePreferredSize(const gfx::Size& pref_size) OVERRIDE;
-
- // RenderViewHostDelegate::View methods. Only the ones for opening new
- // windows are currently implemented.
- virtual void CreateNewWindow(
- int route_id,
- const ViewHostMsg_CreateWindow_Params& params) OVERRIDE;
- virtual void CreateNewWidget(int route_id,
- WebKit::WebPopupType popup_type) OVERRIDE {}
- virtual void CreateNewFullscreenWidget(int route_id) OVERRIDE {}
- virtual void ShowCreatedWindow(int route_id,
- WindowOpenDisposition disposition,
- const gfx::Rect& initial_pos,
- bool user_gesture) OVERRIDE;
- virtual void ShowCreatedWidget(int route_id,
- const gfx::Rect& initial_pos) OVERRIDE {}
- virtual void ShowCreatedFullscreenWidget(int route_id) OVERRIDE {}
- virtual void ShowContextMenu(const ContextMenuParams& params) OVERRIDE {}
- virtual void ShowPopupMenu(const gfx::Rect& bounds,
- int item_height,
- double item_font_size,
- int selected_item,
- const std::vector<WebMenuItem>& items,
- bool right_aligned) OVERRIDE {}
- virtual void StartDragging(const WebDropData&,
- WebKit::WebDragOperationsMask,
- const SkBitmap&,
- const gfx::Point&) OVERRIDE {}
- virtual void UpdateDragCursor(WebKit::WebDragOperation operation) OVERRIDE {}
- virtual void GotFocus() OVERRIDE {}
- virtual void TakeFocus(bool reverse) OVERRIDE {}
+ TabContents* tab_contents() const { return tab_contents_.get(); }
// Enable Web UI. This has to be called before renderer is created.
void EnableWebUI();
@@ -101,15 +56,20 @@ class BalloonHost : public RenderViewHostDelegate,
protected:
virtual ~BalloonHost();
- // 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_;
+ scoped_ptr<TabContents> tab_contents_;
private:
- // RenderViewHostDelegate
+ // TabContentsDelegate implementation:
+ virtual void CloseContents(TabContents* source) OVERRIDE;
+ virtual void HandleMouseDown() OVERRIDE;
+ virtual void UpdatePreferredSize(TabContents* source,
+ const gfx::Size& pref_size) OVERRIDE;
+
+ // TabContentsObserver implementation:
+ virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
+ virtual void RenderViewReady() OVERRIDE;
+ virtual void RenderViewGone() OVERRIDE;
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
// Message handlers
@@ -133,9 +93,6 @@ class BalloonHost : public RenderViewHostDelegate,
// 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_;
-
// A flag to enable Web UI.
bool enable_web_ui_;
diff --git a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
index 28f4eda..ede1a3b9 100644
--- a/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
+++ b/chrome/browser/tab_contents/render_view_host_delegate_helper.cc
@@ -25,6 +25,7 @@
#include "chrome/browser/tab_contents/background_contents.h"
#include "chrome/browser/user_style_sheet_watcher.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/chrome_view_types.h"
#include "chrome/common/pref_names.h"
#include "content/browser/child_process_security_policy.h"
#include "content/browser/gpu/gpu_data_manager.h"
@@ -550,6 +551,9 @@ WebPreferences RenderViewHostDelegateHelper::GetWebkitPrefs(
extension_webkit_preferences::SetPreferences(&web_prefs, extension);
}
+ if (rvh->delegate()->GetRenderViewType() == chrome::VIEW_TYPE_NOTIFICATION)
+ web_prefs.allow_scripts_to_close_windows = true;
+
return web_prefs;
}
diff --git a/chrome/browser/task_manager/task_manager_notification_resource_provider.cc b/chrome/browser/task_manager/task_manager_notification_resource_provider.cc
index d6c2bc1..2db029f 100644
--- a/chrome/browser/task_manager/task_manager_notification_resource_provider.cc
+++ b/chrome/browser/task_manager/task_manager_notification_resource_provider.cc
@@ -12,8 +12,9 @@
#include "chrome/browser/notifications/balloon_host.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/common/chrome_notification_types.h"
-#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_process_host.h"
+#include "content/browser/renderer_host/render_view_host.h"
+#include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/notification_service.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -35,7 +36,8 @@ TaskManagerNotificationResource::TaskManagerNotificationResource(
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN);
}
- process_handle_ = balloon_host_->render_view_host()->process()->GetHandle();
+ process_handle_ =
+ balloon_host_->tab_contents()->render_view_host()->process()->GetHandle();
pid_ = base::GetProcId(process_handle_);
title_ = l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_NOTIFICATION_PREFIX,
balloon_host_->GetSource());
@@ -69,7 +71,8 @@ bool TaskManagerNotificationResource::CanInspect() const {
}
void TaskManagerNotificationResource::Inspect() const {
- DevToolsWindow::OpenDevToolsWindow(balloon_host_->render_view_host());
+ DevToolsWindow::OpenDevToolsWindow(
+ balloon_host_->tab_contents()->render_view_host());
}
bool TaskManagerNotificationResource::SupportNetworkUsage() const {
diff --git a/chrome/browser/ui/cocoa/notifications/balloon_controller.mm b/chrome/browser/ui/cocoa/notifications/balloon_controller.mm
index b45838d..b5ebab8 100644
--- a/chrome/browser/ui/cocoa/notifications/balloon_controller.mm
+++ b/chrome/browser/ui/cocoa/notifications/balloon_controller.mm
@@ -19,6 +19,7 @@
#import "chrome/browser/ui/cocoa/notifications/balloon_view.h"
#include "chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.h"
#include "content/browser/renderer_host/render_view_host.h"
+#include "content/browser/tab_contents/tab_contents.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -174,9 +175,11 @@ const int kRightMargin = 2;
- (void)updateContents {
DCHECK(htmlContents_.get()) << "BalloonView::Update called before Show";
- if (htmlContents_->render_view_host())
- htmlContents_->render_view_host()->NavigateToURL(
- balloon_->notification().content_url());
+ if (htmlContents_->tab_contents()) {
+ htmlContents_->tab_contents()->controller().LoadURL(
+ balloon_->notification().content_url(), GURL(),
+ content::PAGE_TRANSITION_LINK, std::string());
+ }
}
- (void)repositionToBalloon {
@@ -186,11 +189,10 @@ const int kRightMargin = 2;
int w = [self desiredTotalWidth];
int h = [self desiredTotalHeight];
+ [[self window] setFrame:NSMakeRect(x, y, w, h)
+ display:YES];
if (htmlContents_.get())
htmlContents_->UpdateActualSize(balloon_->content_size());
-
- [[[self window] animator] setFrame:NSMakeRect(x, y, w, h)
- display:YES];
}
// Returns the total width the view should be to accommodate the balloon.
diff --git a/chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.h b/chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.h
index 4d87466..43096ee 100644
--- a/chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.h
+++ b/chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.h
@@ -27,15 +27,7 @@ class BalloonViewHost : public BalloonHost {
// Accessors.
gfx::NativeView native_view() const;
- protected:
- virtual void InitRenderWidgetHostView();
- virtual RenderWidgetHostView* render_widget_host_view() const;
-
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_;
-
DISALLOW_COPY_AND_ASSIGN(BalloonViewHost);
};
diff --git a/chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.mm b/chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.mm
index 4fad1c0..4d71835 100644
--- a/chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.mm
+++ b/chrome/browser/ui/cocoa/notifications/balloon_view_host_mac.mm
@@ -6,6 +6,8 @@
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_widget_host_view_mac.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "content/browser/tab_contents/tab_contents_view.h"
BalloonViewHost::BalloonViewHost(Balloon* balloon)
: BalloonHost(balloon) {
@@ -16,7 +18,8 @@ BalloonViewHost::~BalloonViewHost() {
}
void BalloonViewHost::UpdateActualSize(const gfx::Size& new_size) {
- NSView* view = render_widget_host_view_->native_view();
+ tab_contents_->view()->SizeContents(new_size);
+ NSView* view = native_view();
NSRect frame = [view frame];
frame.size.width = new_size.width();
frame.size.height = new_size.height();
@@ -26,14 +29,5 @@ void BalloonViewHost::UpdateActualSize(const gfx::Size& new_size) {
}
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 RenderWidgetHostViewMac(render_view_host_);
-}
-
-RenderWidgetHostView* BalloonViewHost::render_widget_host_view() const {
- return render_widget_host_view_;
+ return tab_contents_->GetContentNativeView();
}
diff --git a/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc b/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc
index b49f72c..22734f8 100644
--- a/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc
+++ b/chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc
@@ -32,6 +32,7 @@
#include "chrome/common/extensions/extension.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
+#include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/notification_source.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
@@ -344,9 +345,11 @@ void BalloonViewImpl::Show(Balloon* balloon) {
void BalloonViewImpl::Update() {
DCHECK(html_contents_.get()) << "BalloonView::Update called before Show";
- if (html_contents_->render_view_host())
- html_contents_->render_view_host()->NavigateToURL(
- balloon_->notification().content_url());
+ if (!html_contents_->tab_contents())
+ return;
+ html_contents_->tab_contents()->controller().LoadURL(
+ balloon_->notification().content_url(), GURL(),
+ content::PAGE_TRANSITION_LINK, std::string());
}
gfx::Point BalloonViewImpl::GetContentsOffset() const {
diff --git a/chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.cc b/chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.cc
index 2f3da9d..ee44ae8 100644
--- a/chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.cc
+++ b/chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.cc
@@ -6,12 +6,11 @@
#include "chrome/browser/notifications/balloon.h"
#include "content/browser/renderer_host/render_view_host.h"
-#include "content/browser/renderer_host/render_widget_host_view.h"
#include "content/browser/renderer_host/render_widget_host_view_gtk.h"
+#include "content/browser/tab_contents/tab_contents.h"
BalloonViewHost::BalloonViewHost(Balloon* balloon)
- : BalloonHost(balloon),
- render_widget_host_view_(NULL) {
+ : BalloonHost(balloon) {
}
BalloonViewHost::~BalloonViewHost() {
@@ -19,21 +18,11 @@ BalloonViewHost::~BalloonViewHost() {
}
void BalloonViewHost::UpdateActualSize(const gfx::Size& new_size) {
- render_widget_host_view_->SetSize(new_size);
+ tab_contents_->render_view_host()->view()->SetSize(new_size);
gtk_widget_set_size_request(
native_view(), new_size.width(), new_size.height());
}
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();
-}
-
-RenderWidgetHostView* BalloonViewHost::render_widget_host_view() const {
- return render_widget_host_view_;
+ return tab_contents_->GetNativeView();
}
diff --git a/chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.h b/chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.h
index 656ebb3..ef63643 100644
--- a/chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.h
+++ b/chrome/browser/ui/gtk/notifications/balloon_view_host_gtk.h
@@ -27,14 +27,7 @@ class BalloonViewHost : public BalloonHost {
// Accessors.
gfx::NativeView native_view() const;
- protected:
- virtual void InitRenderWidgetHostView();
- virtual RenderWidgetHostView* render_widget_host_view() const;
-
private:
- // The GTK-specific widget host view. Owned by its native view.
- RenderWidgetHostViewGtk* render_widget_host_view_;
-
DISALLOW_COPY_AND_ASSIGN(BalloonViewHost);
};
diff --git a/chrome/browser/ui/views/notifications/balloon_view.cc b/chrome/browser/ui/views/notifications/balloon_view.cc
index 64ddc93..75b93fa 100644
--- a/chrome/browser/ui/views/notifications/balloon_view.cc
+++ b/chrome/browser/ui/views/notifications/balloon_view.cc
@@ -19,6 +19,7 @@
#include "chrome/common/chrome_notification_types.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
+#include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
@@ -211,7 +212,8 @@ void BalloonViewImpl::RepositionToBalloon() {
gfx::Rect contents_rect = GetContentsRectangle();
html_container_->SetBounds(contents_rect);
html_contents_->SetPreferredSize(contents_rect.size());
- RenderWidgetHostView* view = html_contents_->render_view_host()->view();
+ RenderWidgetHostView* view =
+ html_contents_->tab_contents()->GetRenderWidgetHostView();
if (view)
view->SetSize(contents_rect.size());
return;
@@ -227,9 +229,11 @@ void BalloonViewImpl::RepositionToBalloon() {
void BalloonViewImpl::Update() {
DCHECK(html_contents_.get()) << "BalloonView::Update called before Show";
- if (html_contents_->render_view_host())
- html_contents_->render_view_host()->NavigateToURL(
- balloon_->notification().content_url());
+ if (!html_contents_->tab_contents())
+ return;
+ html_contents_->tab_contents()->controller().LoadURL(
+ balloon_->notification().content_url(), GURL(),
+ content::PAGE_TRANSITION_LINK, std::string());
}
void BalloonViewImpl::AnimationProgressed(const ui::Animation* animation) {
@@ -257,7 +261,8 @@ void BalloonViewImpl::AnimationProgressed(const ui::Animation* animation) {
html_container_->SetShape(path.CreateNativeRegion());
html_contents_->SetPreferredSize(contents_rect.size());
- RenderWidgetHostView* view = html_contents_->render_view_host()->view();
+ RenderWidgetHostView* view =
+ html_contents_->tab_contents()->GetRenderWidgetHostView();
if (view)
view->SetSize(contents_rect.size());
}
diff --git a/chrome/browser/ui/views/notifications/balloon_view_host.cc b/chrome/browser/ui/views/notifications/balloon_view_host.cc
index d018b6c..a59b374 100644
--- a/chrome/browser/ui/views/notifications/balloon_view_host.cc
+++ b/chrome/browser/ui/views/notifications/balloon_view_host.cc
@@ -7,13 +7,12 @@
#include "chrome/browser/notifications/balloon.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/renderer_host/render_widget_host_view.h"
+#include "content/browser/tab_contents/tab_contents.h"
#include "content/public/browser/content_browser_client.h"
#include "views/widget/widget.h"
#if defined(USE_AURA)
#include "content/browser/renderer_host/render_widget_host_view_aura.h"
-#elif defined(OS_WIN)
-#include "content/browser/renderer_host/render_widget_host_view_win.h"
#elif defined(TOUCH_UI)
#include "chrome/browser/renderer_host/render_widget_host_view_views.h"
#elif defined(TOOLKIT_USES_GTK)
@@ -56,45 +55,25 @@ BalloonViewHost::~BalloonViewHost() {
void BalloonViewHost::Init(gfx::NativeView parent_native_view) {
parent_native_view_ = parent_native_view;
BalloonHost::Init();
-}
-
-void BalloonViewHost::InitRenderWidgetHostView() {
- DCHECK(render_view_host_);
-
- render_widget_host_view_ =
- content::GetContentClient()->browser()->CreateViewForWidget(
- render_view_host_);
- // TODO(johnnyg): http://crbug.com/23954. Need a cross-platform solution.
+ RenderWidgetHostView* render_widget_host_view =
+ tab_contents_->render_view_host()->view();
#if defined(USE_AURA)
- RenderWidgetHostViewAura* view_aura =
- static_cast<RenderWidgetHostViewAura*>(render_widget_host_view_);
- view_aura->InitAsChild();
- view_aura->Show();
- native_host_->Attach(view_aura->GetNativeView());
+ // TODO(beng): (same as touch_ui probably).
+ NOTIMPLEMENTED();
#elif defined(OS_WIN)
- RenderWidgetHostViewWin* view_win =
- static_cast<RenderWidgetHostViewWin*>(render_widget_host_view_);
-
- // Create the HWND.
- HWND hwnd = view_win->Create(parent_native_view_);
- view_win->ShowWindow(SW_SHOW);
- native_host_->Attach(hwnd);
-#elif defined(TOUCH_UI)
+ native_host_->Attach(render_widget_host_view->GetNativeView());
+#elif defined(TOOLKIT_USES_GTK)
+#if defined(TOUCH_UI)
RenderWidgetHostViewViews* view_views =
- static_cast<RenderWidgetHostViewViews*>(render_widget_host_view_);
- view_views->InitAsChild();
+ static_cast<RenderWidgetHostViewViews*>(render_widget_host_view);
native_host_->AttachToView(view_views);
-#elif defined(TOOLKIT_USES_GTK)
+#else
RenderWidgetHostViewGtk* view_gtk =
- static_cast<RenderWidgetHostViewGtk*>(render_widget_host_view_);
- view_gtk->InitAsChild();
+ static_cast<RenderWidgetHostViewGtk*>(render_widget_host_view);
native_host_->Attach(view_gtk->native_view());
+#endif
#else
NOTIMPLEMENTED();
#endif
}
-
-RenderWidgetHostView* BalloonViewHost::render_widget_host_view() const {
- return render_widget_host_view_;
-}
diff --git a/chrome/browser/ui/views/notifications/balloon_view_host.h b/chrome/browser/ui/views/notifications/balloon_view_host.h
index e3b0a23..3ad8b07 100644
--- a/chrome/browser/ui/views/notifications/balloon_view_host.h
+++ b/chrome/browser/ui/views/notifications/balloon_view_host.h
@@ -35,14 +35,7 @@ class BalloonViewHost : public BalloonHost {
// Initialize the view, parented to |parent|, and show it.
void Init(gfx::NativeView parent);
- protected:
- virtual void InitRenderWidgetHostView();
- virtual RenderWidgetHostView* render_widget_host_view() const;
-
private:
- // The platform-specific widget host view. Pointer is owned by the RVH.
- RenderWidgetHostView* render_widget_host_view_;
-
// The views-specific host view. Pointer owned by the views hierarchy.
views::NativeViewHost* native_host_;