diff options
-rw-r--r-- | chrome/browser/notifications/balloon_collection_linux.cc | 5 | ||||
-rw-r--r-- | chrome/browser/notifications/desktop_notifications_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/notifications/balloon_view.cc | 29 | ||||
-rw-r--r-- | chrome/browser/views/notifications/balloon_view_host.cc | 19 | ||||
-rw-r--r-- | chrome/browser/views/notifications/balloon_view_host_gtk.cc | 12 | ||||
-rwxr-xr-x | chrome/chrome_browser.gypi | 6 | ||||
-rw-r--r-- | chrome/renderer/render_thread.cc | 2 |
7 files changed, 43 insertions, 34 deletions
diff --git a/chrome/browser/notifications/balloon_collection_linux.cc b/chrome/browser/notifications/balloon_collection_linux.cc index d787876..1ad122b 100644 --- a/chrome/browser/notifications/balloon_collection_linux.cc +++ b/chrome/browser/notifications/balloon_collection_linux.cc @@ -13,13 +13,8 @@ Balloon* BalloonCollectionImpl::MakeBalloon(const Notification& notification, Profile* profile) { Balloon* balloon = new Balloon(notification, profile, this); - // TODO(johnnyg): hookup to views code for Chrome OS. -#if defined(TOOLKIT_GTK) balloon->set_view(new BalloonViewImpl()); gfx::Size size(layout_.min_balloon_width(), layout_.min_balloon_height()); balloon->set_content_size(size); -#endif - return balloon; - } diff --git a/chrome/browser/notifications/desktop_notifications_unittest.cc b/chrome/browser/notifications/desktop_notifications_unittest.cc index 32bda04..186dd5f 100644 --- a/chrome/browser/notifications/desktop_notifications_unittest.cc +++ b/chrome/browser/notifications/desktop_notifications_unittest.cc @@ -163,7 +163,7 @@ TEST_F(DesktopNotificationsTest, TestCancel) { log_output_); } -#if defined(OS_WIN) +#if defined(OS_WIN) || defined(TOOLKIT_VIEWS) TEST_F(DesktopNotificationsTest, TestPositioning) { std::string expected_log; // Create some toasts. After each but the first, make sure there @@ -188,7 +188,6 @@ TEST_F(DesktopNotificationsTest, TestVariableSize) { std::string expected_log; // Create some toasts. After each but the first, make sure there // is a minimum separation between the toasts. - int last_top = 0; EXPECT_TRUE(service_->ShowDesktopNotificationText( GURL("http://long.google.com"), GURL("/icon.png"), ASCIIToUTF16("Really Really Really Really Really Really " @@ -303,4 +302,3 @@ TEST_F(DesktopNotificationsTest, TestUserInputEscaping) { EXPECT_EQ(std::string::npos, data_url.spec().find("<script>")); EXPECT_EQ(std::string::npos, data_url.spec().find("<i>")); } - diff --git a/chrome/browser/views/notifications/balloon_view.cc b/chrome/browser/views/notifications/balloon_view.cc index 083178d..53bb73c 100644 --- a/chrome/browser/views/notifications/balloon_view.cc +++ b/chrome/browser/views/notifications/balloon_view.cc @@ -7,7 +7,6 @@ #include <vector> #include "app/gfx/canvas.h" -#include "app/gfx/gdi_util.h" #include "app/gfx/insets.h" #include "app/gfx/native_widget_types.h" #include "app/l10n_util.h" @@ -31,7 +30,13 @@ #include "views/controls/menu/menu_2.h" #include "views/controls/native/native_view_host.h" #include "views/painter.h" +#include "views/widget/root_view.h" +#if defined(OS_WIN) #include "views/widget/widget_win.h" +#endif +#if defined(OS_LINUX) +#include "views/widget/widget_gtk.h" +#endif using views::Widget; @@ -95,6 +100,7 @@ BalloonViewImpl::BalloonViewImpl() frame_container_(NULL), html_container_(NULL), html_contents_(NULL), + method_factory_(this), shelf_background_(NULL), balloon_background_(NULL), close_button_(NULL), @@ -102,8 +108,7 @@ BalloonViewImpl::BalloonViewImpl() animation_(NULL), options_menu_contents_(NULL), options_menu_menu_(NULL), - options_menu_button_(NULL), - method_factory_(this) { + options_menu_button_(NULL) { // This object is not to be deleted by the views hierarchy, // as it is owned by the balloon. set_parent_owned(false); @@ -146,6 +151,10 @@ void BalloonViewImpl::RunMenu(views::View* source, const gfx::Point& pt) { void BalloonViewImpl::DelayedClose(bool by_user) { html_contents_->Shutdown(); html_container_->CloseNow(); + // The BalloonViewImpl has to be detached from frame_container_ now + // because CloseNow on linux/views destroys the view hierachy + // asynchronously. + frame_container_->GetRootView()->RemoveAllChildViews(true); frame_container_->CloseNow(); balloon_->OnClose(by_user); } @@ -247,8 +256,10 @@ gfx::Rect BalloonViewImpl::GetOptionsMenuBounds() const { gfx::Rect BalloonViewImpl::GetLabelBounds() const { return gfx::Rect( kLeftLabelMargin, - height() - kDismissButtonHeight - kShelfBorderTopOverlap - kBottomMargin, - width() - kDismissButtonWidth - kOptionsMenuWidth - kRightMargin, + std::max(0, height() - kDismissButtonHeight - kShelfBorderTopOverlap - + kBottomMargin), + std::max(0, width() - kDismissButtonWidth - kOptionsMenuWidth - + kRightMargin), kDismissButtonHeight); } @@ -296,16 +307,16 @@ void BalloonViewImpl::Show(Balloon* balloon) { html_container_ = Widget::CreatePopupWidget(Widget::NotTransparent, Widget::AcceptEvents, Widget::DeleteOnDestroy); - html_container_->SetAlwaysOnTop(true); html_container_->Init(NULL, contents_rect); + html_container_->SetAlwaysOnTop(true); html_container_->SetContentsView(html_contents_); gfx::Rect balloon_rect(x(), y(), width(), height()); frame_container_ = Widget::CreatePopupWidget(Widget::Transparent, Widget::AcceptEvents, Widget::DeleteOnDestroy); - frame_container_->SetAlwaysOnTop(true); frame_container_->Init(NULL, balloon_rect); + frame_container_->SetAlwaysOnTop(true); frame_container_->SetContentsView(this); close_button_->SetIcon(*rb.GetBitmapNamed(IDR_BALLOON_CLOSE)); @@ -349,9 +360,9 @@ void BalloonViewImpl::CreateOptionsMenu() { if (options_menu_contents_.get()) return; - const std::wstring label_text = l10n_util::GetStringF( + const string16 label_text = WideToUTF16Hack(l10n_util::GetStringF( IDS_NOTIFICATION_BALLOON_REVOKE_MESSAGE, - this->balloon_->notification().display_source()); + this->balloon_->notification().display_source())); options_menu_contents_.reset(new menus::SimpleMenuModel(this)); options_menu_contents_->AddItem(kRevokePermissionCommand, label_text); diff --git a/chrome/browser/views/notifications/balloon_view_host.cc b/chrome/browser/views/notifications/balloon_view_host.cc index df074b0..6e05160 100644 --- a/chrome/browser/views/notifications/balloon_view_host.cc +++ b/chrome/browser/views/notifications/balloon_view_host.cc @@ -16,20 +16,28 @@ #if defined(OS_WIN) #include "chrome/browser/renderer_host/render_widget_host_view_win.h" #endif +#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/notification_service.h" #include "chrome/common/notification_type.h" #include "chrome/common/render_messages.h" #include "chrome/common/renderer_preferences.h" #include "views/widget/widget.h" +#if defined(OS_WIN) #include "views/widget/widget_win.h" +#endif +#if defined(OS_LINUX) +#include "views/widget/widget_gtk.h" +#endif BalloonViewHost::BalloonViewHost(Balloon* balloon) - : balloon_(balloon), + : initialized_(false), + balloon_(balloon), site_instance_(SiteInstance::CreateSiteInstance(balloon->profile())), render_view_host_(NULL), - should_notify_on_disconnect_(false), - initialized_(false) { + should_notify_on_disconnect_(false) { DCHECK(balloon_); } @@ -121,6 +129,11 @@ void BalloonViewHost::Init(gfx::NativeView parent_hwnd) { HWND hwnd = view_win->Create(parent_hwnd); view_win->ShowWindow(SW_SHOW); Attach(hwnd); +#elif defined(OS_LINUX) + RenderWidgetHostViewGtk* view_gtk = + static_cast<RenderWidgetHostViewGtk*>(view); + view_gtk->InitAsChild(); + Attach(view_gtk->native_view()); #else NOTIMPLEMENTED(); #endif diff --git a/chrome/browser/views/notifications/balloon_view_host_gtk.cc b/chrome/browser/views/notifications/balloon_view_host_gtk.cc deleted file mode 100644 index f3477f4..0000000 --- a/chrome/browser/views/notifications/balloon_view_host_gtk.cc +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2009 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/views/notifications/balloon_view_host.h" - -#include "base/logging.h" - -BalloonViewHost::BalloonViewHost(Balloon* balloon) { - // TODO(johnnyg): http://crbug.com/23954 - NOTIMPLEMENTED(); -} diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 2f2819b..1bc51be 100755 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -253,7 +253,7 @@ 'browser/chrome_plugin_host.h', 'browser/chrome_thread.cc', 'browser/chrome_thread.h', - 'browser/chromeos/browser_notification_observers.cc', + 'browser/chromeos/browser_notification_observers.cc', 'browser/chromeos/browser_extenders.cc', 'browser/chromeos/chromeos_browser_view.cc', 'browser/chromeos/chromeos_browser_view.h', @@ -2317,6 +2317,10 @@ ['include', '^browser/views/location_bar_view.cc'], ['include', '^browser/views/location_bar_view.h'], ['include', '^browser/views/page_info_window_view.cc'], + ['include', '^browser/views/notifications/balloon_view_host.cc'], + ['include', '^browser/views/notifications/balloon_view_host.h'], + ['include', '^browser/views/notifications/balloon_view.cc'], + ['include', '^browser/views/notifications/balloon_view.h'], # Not necessary unless you're trying to build ChromeOS+views. #['include', '^browser/views/panels/panel_scroller.cc'], #['include', '^browser/views/panels/panel_scroller.h'], diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index a19cbdd..1b4cd96 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -617,7 +617,7 @@ void RenderThread::EnsureWebKitInitialized() { WebRuntimeFeatures::enableApplicationCache( !command_line.HasSwitch(switches::kDisableApplicationCache)); -#if defined(OS_WIN) || (defined(OS_LINUX) && defined(TOOLKIT_GTK)) +#if defined(OS_WIN) || defined(OS_LINUX) // Notifications are supported on Windows and Linux only. WebRuntimeFeatures::enableNotifications( !command_line.HasSwitch(switches::kDisableDesktopNotifications)); |