diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-20 18:01:45 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-20 18:01:45 +0000 |
commit | 5d49b0f6fc6b71a4ad0d1e72cf7e3c86f2943f86 (patch) | |
tree | 60580cc0553df9e2d9f5fc7aaf2977eda7704d2d /chrome | |
parent | d6968dda8612fe906d8e25bcc384641b28e1af42 (diff) | |
download | chromium_src-5d49b0f6fc6b71a4ad0d1e72cf7e3c86f2943f86.zip chromium_src-5d49b0f6fc6b71a4ad0d1e72cf7e3c86f2943f86.tar.gz chromium_src-5d49b0f6fc6b71a4ad0d1e72cf7e3c86f2943f86.tar.bz2 |
PanelControler support
* Refactored BrowserExtender and added NormalExtender and PopopExtender.
BrowserExtender::Create factory method returns appropriate extender for given BrowserView.
* Added #if/#else to PanelController to accept BrowserView in Constructor.
* added guard code in Close so that it will ignore 2nd invocation of Close. (views seems
to call Close() (when it requests, and when it's really closed)
Added missing code in TabOverviewMessageListener
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/276075
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29533 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/chromeos/browser_extender.cc | 276 | ||||
-rw-r--r-- | chrome/browser/chromeos/browser_extender.h | 94 | ||||
-rwxr-xr-x | chrome/browser/views/frame/browser_view.cc | 30 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 7 | ||||
-rw-r--r-- | chrome/browser/views/panel_controller.cc | 46 | ||||
-rw-r--r-- | chrome/browser/views/panel_controller.h | 17 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_overview_controller.cc | 19 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_overview_message_listener.cc | 7 | ||||
-rwxr-xr-x | chrome/chrome.gyp | 6 |
9 files changed, 367 insertions, 135 deletions
diff --git a/chrome/browser/chromeos/browser_extender.cc b/chrome/browser/chromeos/browser_extender.cc index 250713b..2d12293 100644 --- a/chrome/browser/chromeos/browser_extender.cc +++ b/chrome/browser/chromeos/browser_extender.cc @@ -10,101 +10,223 @@ #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/chromeos/main_menu.h" #include "chrome/browser/chromeos/status_area_view.h" -#include "chrome/browser/views/frame/browser_frame_gtk.h" #include "chrome/browser/views/frame/browser_view.h" +#include "chrome/browser/views/panel_controller.h" +#include "chrome/browser/views/tabs/tab_overview_types.h" +#include "chrome/browser/views/toolbar_view.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" +#include "views/controls/button/button.h" #include "views/controls/button/image_button.h" +#include "views/controls/menu/simple_menu_model.h" #include "views/window/window.h" -BrowserExtender::BrowserExtender(BrowserView* browser_view) - : browser_view_(browser_view), - main_menu_(new views::ImageButton(this)) { -} +namespace { + +// NormalExtender adds ChromeOS specific controls and menus to BrowserView +// created with Browser::TYPE_NORMAL. For Browser::TYPE_POPUP type of +// BrowserView, see PopupExtender class below. +class NormalExtender : public BrowserExtender, + public views::ButtonListener, + public views::ContextMenuController { + public: + explicit NormalExtender(BrowserView* browser_view) + : BrowserExtender(browser_view), + main_menu_(NULL) { + } + virtual ~NormalExtender() {} + + protected: + // BrowserExtender overrides. + virtual void Init() { + main_menu_ = new views::ImageButton(this); + ThemeProvider* theme_provider = + browser_view()->frame()->GetThemeProviderForFrame(); + SkBitmap* image = theme_provider->GetBitmapNamed(IDR_MAIN_MENU_BUTTON); + main_menu_->SetImage(views::CustomButton::BS_NORMAL, image); + main_menu_->SetImage(views::CustomButton::BS_HOT, image); + main_menu_->SetImage(views::CustomButton::BS_PUSHED, image); + browser_view()->AddChildView(main_menu_); + + status_area_ = new StatusAreaView( + browser_view()->browser(), + browser_view()->GetWindow()->GetNativeWindow()); + browser_view()->AddChildView(status_area_); + status_area_->Init(); + + // TODO(oshima): set the context menu controller to NonClientFrameView. + InitSystemMenu(); + MainMenu::ScheduleCreation(); + } -//////////////////////////////////////////////////////////////////////////////// -// BrowserExtender, public: + virtual gfx::Rect Layout(const gfx::Rect& bounds) { + // skip if there is no space to layout. + if (bounds.IsEmpty()) + return bounds; + + // Layout main menu before tab strip. + gfx::Size main_menu_size = main_menu_->GetPreferredSize(); + main_menu_->SetBounds(bounds.x(), bounds.y(), + main_menu_size.width(), bounds.height()); + + // Layout status area after tab strip. + gfx::Size status_size = status_area_->GetPreferredSize(); + status_area_->SetBounds(bounds.x() + bounds.width() - status_size.width(), + bounds.y(), status_size.width(), + status_size.height()); + int width = bounds.width() - main_menu_size.width() - status_size.width(); + return gfx::Rect(bounds.x() + main_menu_size.width(), + bounds.y(), + std::max(0, width), // in case there is no space left. + bounds.height()); + } -void BrowserExtender::Init() { - ThemeProvider* theme_provider = - browser_view_->frame()->GetThemeProviderForFrame(); - SkBitmap* image = theme_provider->GetBitmapNamed(IDR_MAIN_MENU_BUTTON); - main_menu_->SetImage(views::CustomButton::BS_NORMAL, image); - main_menu_->SetImage(views::CustomButton::BS_HOT, image); - main_menu_->SetImage(views::CustomButton::BS_PUSHED, image); - browser_view_->AddChildView(main_menu_); - - status_area_ = new StatusAreaView( - browser_view_->browser(), - browser_view_->GetWindow()->GetNativeWindow()); - browser_view_->AddChildView(status_area_); - status_area_->Init(); - - // TODO(oshima): set the context menu controller to NonClientFrameView. - InitSystemMenu(); -} + virtual bool NonClientHitTest(const gfx::Point& point) { + gfx::Point point_in_main_menu_coords(point); + views::View::ConvertPointToView(browser_view()->GetParent(), main_menu_, + &point_in_main_menu_coords); -gfx::Rect BrowserExtender::Layout(const gfx::Rect& bounds) { - if (bounds.IsEmpty()) { - // skip if there is no space to layout. - return bounds; + gfx::Point point_in_status_area_coords(point); + views::View::ConvertPointToView(browser_view()->GetParent(), status_area_, + &point_in_status_area_coords); + + return main_menu_->HitTest(point_in_main_menu_coords) || + status_area_->HitTest(point_in_status_area_coords); } - // Layout main menu before tab strip. - gfx::Size main_menu_size = main_menu_->GetPreferredSize(); - main_menu_->SetBounds(bounds.x(), bounds.y(), - main_menu_size.width(), bounds.height()); - - // Layout status area after tab strip. - gfx::Size status_size = status_area_->GetPreferredSize(); - status_area_->SetBounds(bounds.x() + bounds.width() - status_size.width(), - bounds.y(), status_size.width(), - status_size.height()); - int width = bounds.width() - main_menu_size.width() - status_size.width(); - return gfx::Rect(bounds.x() + main_menu_size.width(), - bounds.y(), - std::max(0, width), // in case there is no space left. - bounds.height()); -} -bool BrowserExtender::NonClientHitTest(const gfx::Point& point) { - gfx::Point point_in_main_menu_coords(point); - views::View::ConvertPointToView(browser_view_->GetParent(), main_menu_, - &point_in_main_menu_coords); + virtual void Show() { + // TODO(oshima): PanelController seems to be doing something similar. + // Investigate if we need both. + TabOverviewTypes::instance()->SetWindowType( + GTK_WIDGET(GetBrowserWindow()->GetNativeWindow()), + TabOverviewTypes::WINDOW_TYPE_CHROME_TOPLEVEL, + NULL); + } - gfx::Point point_in_status_area_coords(point); - views::View::ConvertPointToView(browser_view_->GetParent(), status_area_, - &point_in_status_area_coords); + private: + // Creates system menu. + void InitSystemMenu() { + system_menu_contents_.reset(new views::SimpleMenuModel(browser_view())); + system_menu_contents_->AddItemWithStringId(IDC_RESTORE_TAB, + IDS_RESTORE_TAB); + system_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); + system_menu_contents_->AddSeparator(); + system_menu_contents_->AddItemWithStringId(IDC_TASK_MANAGER, + IDS_TASK_MANAGER); + system_menu_menu_.reset(new views::Menu2(system_menu_contents_.get())); + } - return main_menu_->HitTest(point_in_main_menu_coords) || - status_area_->HitTest(point_in_status_area_coords); -} + // views::ButtonListener overrides. + virtual void ButtonPressed(views::Button* sender, const views::Event& event) { + MainMenu::Show(browser_view()->browser()); + } -//////////////////////////////////////////////////////////////////////////////// -// BrowserExtender, private: - -void BrowserExtender::InitSystemMenu() { - system_menu_contents_.reset(new views::SimpleMenuModel(browser_view_)); - system_menu_contents_->AddItemWithStringId(IDC_RESTORE_TAB, IDS_RESTORE_TAB); - system_menu_contents_->AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); - system_menu_contents_->AddSeparator(); - system_menu_contents_->AddItemWithStringId(IDC_TASK_MANAGER, - IDS_TASK_MANAGER); - system_menu_menu_.reset(new views::Menu2(system_menu_contents_.get())); -} + // views::ContextMenuController overrides. + virtual void ShowContextMenu(views::View* source, + int x, + int y, + bool is_mouse_gesture) { + system_menu_menu_->RunMenuAt(gfx::Point(x, y), views::Menu2::ALIGN_TOPLEFT); + } + + // Main menu button. + views::ImageButton* main_menu_; + + // Status Area view. + StatusAreaView* status_area_; + + // System menus + scoped_ptr<views::SimpleMenuModel> system_menu_contents_; + scoped_ptr<views::Menu2> system_menu_menu_; + + DISALLOW_COPY_AND_ASSIGN(NormalExtender); +}; + +// PopupExtender class creates dedicated title window for popup window. +// The size and location of the created title window is controlled by +// by window manager. +class PopupExtender : public BrowserExtender { + public: + explicit PopupExtender(BrowserView* browser_view) + : BrowserExtender(browser_view) { + } + virtual ~PopupExtender() {} + + private: + // BrowserExtender overrides. + virtual void Init() { + // The visibility of toolbar is controlled in + // the BrowserView::IsToolbarVisible method. + + views::Window* window = GetBrowserWindow(); + gfx::NativeWindow native_window = window->GetNativeWindow(); + // The window manager needs the min size for popups. + gfx::Rect bounds = window->GetBounds(); + gtk_widget_set_size_request( + GTK_WIDGET(native_window), bounds.width(), bounds.height()); + // If we don't explicitly resize here there is a race condition between + // the X Server and the window manager. Windows will appear with a default + // size of 200x200 if this happens. + gtk_window_resize(native_window, bounds.width(), bounds.height()); + } + + virtual bool NonClientHitTest(const gfx::Point& point) { + return false; + } + + virtual void Show() { + panel_controller_.reset(new PanelController(browser_view())); + } + + virtual void Close() { + if (panel_controller_.get()) + panel_controller_->Close(); + } + + virtual void UpdateTitleBar() { + if (panel_controller_.get()) + panel_controller_->UpdateTitleBar(); + } + + virtual void ActivationChanged() { + if (panel_controller_.get()) { + if (GetBrowserWindow()->IsActive()) + panel_controller_->OnFocusIn(); + else + panel_controller_->OnFocusOut(); + } + } + + // Controls interactions with the window manager for popup panels. + scoped_ptr<PanelController> panel_controller_; + + DISALLOW_COPY_AND_ASSIGN(PopupExtender); +}; + +} // namespace //////////////////////////////////////////////////////////////////////////////// -// BrowserExtender, views::ButtonListener implemenation: +// BrowserExtender, public: -void BrowserExtender::ButtonPressed(views::Button* sender, - const views::Event& event) { - MainMenu::Show(browser_view_->browser()); +BrowserExtender::BrowserExtender(BrowserView* browser_view) + : browser_view_(browser_view), + can_close_(true) { } -/////////////////////////////////////////////////////////////////////////////// -// BrowserExtender, views::ContextMenuController implementation: - -void BrowserExtender::ShowContextMenu(views::View* source, int x, int y, - bool is_mouse_gesture) { - system_menu_menu_->RunMenuAt(gfx::Point(x, y), views::Menu2::ALIGN_TOPLEFT); +// static +BrowserExtender* BrowserExtender::Create(BrowserView* browser_view) { + BrowserExtender* extender; + if (browser_view->browser()->type() & Browser::TYPE_POPUP) + extender = new PopupExtender(browser_view); + else + extender = new NormalExtender(browser_view); + extender->Init(); + return extender; } +//////////////////////////////////////////////////////////////////////////////// +// BrowserExtender, protected: + +views::Window* BrowserExtender::GetBrowserWindow() { + return browser_view_->frame()->GetWindow(); +} diff --git a/chrome/browser/chromeos/browser_extender.h b/chrome/browser/chromeos/browser_extender.h index 6150d5d..d1ae11a 100644 --- a/chrome/browser/chromeos/browser_extender.h +++ b/chrome/browser/chromeos/browser_extender.h @@ -5,74 +5,88 @@ #ifndef CHROME_BROWSER_CHROMEOS_BROWSER_EXTENDER_H_ #define CHROME_BROWSER_CHROMEOS_BROWSER_EXTENDER_H_ -#include "views/controls/button/button.h" -#include "views/controls/menu/simple_menu_model.h" -#include "views/controls/menu/view_menu_delegate.h" +#include "base/basictypes.h" +#include "base/gfx/rect.h" class BrowserView; -class StatusAreaView; namespace views { -class ImageButton; -class SimpleMenuModel; -} +class Window; +} // namespace views -namespace gfx { -class Point; -} -// BrowserExtender adds extra controls to BrowserView for ChromeOS. -// This layout controls as follows +// BrowserExtender adds chromeos specific features to BrowserView. +// The factory method |Create(BrowserView*)| returns two different types +// of extender depending on the type of BrowserView. If the browser_view +// is normal browser, it returns NormalExtender that adds controls to +// the title bar as follows: // ____ __ __ // [MainMenu] / \ \ \ [StatusArea] // // and adds the system context menu to the remaining arae of the titlebar. -class BrowserExtender : public views::ButtonListener, - public views::ContextMenuController { +// +// If it is popup window, it returns PopupExtender that creates +// a title window. +class BrowserExtender { public: - explicit BrowserExtender(BrowserView* browser_view); + // Factory method to create a BrowserExtender for given + // BrowserView object. Please see the class description for details. + static BrowserExtender* Create(BrowserView* browser_view); + virtual ~BrowserExtender() {} - // Initializes the extender. This creates controls, status area and - // menus. - void Init(); + // Initializes the extender. + virtual void Init() = 0; // Layouts controls within the given bounds and returns the remaining // bounds for tabstip to be layed out. - gfx::Rect Layout(const gfx::Rect& bounds); + virtual gfx::Rect Layout(const gfx::Rect& bounds) { return bounds; } // Tests if the given |point|, which is given in window coordinates, // hits any of controls. - bool NonClientHitTest(const gfx::Point& point); + virtual bool NonClientHitTest(const gfx::Point& point) = 0; - private: - // Creates system menu. - void InitSystemMenu(); + // Updates the title bar (if any). + virtual void UpdateTitleBar() {} - // Overridden from views::ButtonListener: - virtual void ButtonPressed(views::Button* sender, const views::Event& event); + // Called when the BrowserView is shown. + virtual void Show() = 0; - // views::ContextMenuController overrides: - virtual void ShowContextMenu(views::View* source, - int x, - int y, - bool is_mouse_gesture); + // Called when the BrowserView is closed. + virtual void Close() {} - // BrowserView to be extended. - BrowserView* browser_view_; // weak + // Called when the browser window is either activated or deactivated. + virtual void ActivationChanged() {} + + // Tells if the browser can be closed. + bool can_close() const { + return can_close_; + } - // Main menu button. - views::ImageButton* main_menu_; + // Specifies if the browser can be closed or not. This typically set + // to false when the browser is being dragged. + void set_can_close(bool b) { + can_close_ = b; + } - // Status Area view. - StatusAreaView* status_area_; + protected: + explicit BrowserExtender(BrowserView* browser_view); - // System menus - scoped_ptr<views::SimpleMenuModel> system_menu_contents_; - scoped_ptr<views::Menu2> system_menu_menu_; + // Returns the view Window object that contains the BrowserView. + views::Window* GetBrowserWindow(); + + BrowserView* browser_view() { + return browser_view_; + } + + private: + // BrowserView to be extended. + BrowserView* browser_view_; + + // True if the browser can be closed. See set_can_close method for setails. + bool can_close_; DISALLOW_COPY_AND_ASSIGN(BrowserExtender); }; #endif // CHROME_BROWSER_CHROMEOS_BROWSER_EXTENDER_H_ - diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 499741d..eae4ec7 100755 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -571,6 +571,12 @@ gfx::Rect BrowserView::GetTabStripBounds() const { } bool BrowserView::IsToolbarVisible() const { +#if defined(OS_CHROMEOS) + if (browser_->type() & Browser::TYPE_POPUP) { + // Don't show toolbar if the window is a popup. + return false; + } +#endif return browser_->SupportsWindowFeature(Browser::FEATURE_TOOLBAR) || browser_->SupportsWindowFeature(Browser::FEATURE_LOCATIONBAR); } @@ -644,6 +650,9 @@ bool BrowserView::ActivateAppModalDialog() const { void BrowserView::ActivationChanged(bool activated) { if (activated) BrowserList::SetLastActive(browser_.get()); +#if defined(OS_CHROMEOS) + browser_extender_->ActivationChanged(); +#endif } TabContents* BrowserView::GetSelectedTabContents() const { @@ -720,6 +729,10 @@ void BrowserView::Show() { contents_split_->set_divider_offset(split_offset); frame_->GetWindow()->Show(); + +#if defined (OS_CHROMEOS) + browser_extender_->Show(); +#endif } void BrowserView::SetBounds(const gfx::Rect& bounds) { @@ -736,6 +749,10 @@ void BrowserView::Close() { } frame_->GetWindow()->Close(); + +#if defined(OS_CHROMEOS) + browser_extender_->Close(); +#endif } void BrowserView::Activate() { @@ -791,6 +808,9 @@ void BrowserView::UpdateTitleBar() { frame_->GetWindow()->UpdateWindowTitle(); if (ShouldShowWindowIcon()) frame_->GetWindow()->UpdateWindowIcon(); +#if defined(OS_CHROMEOS) + browser_extender_->UpdateTitleBar(); +#endif } void BrowserView::ShelfVisibilityChanged() { @@ -1454,6 +1474,11 @@ views::ClientView* BrowserView::CreateClientView(views::Window* window) { // BrowserView, views::ClientView overrides: bool BrowserView::CanClose() const { +#if defined(OS_CHROMEOS) + if (!browser_extender_->can_close()) + return false; +#endif + // You cannot close a frame for which there is an active originating drag // session. if (tabstrip_->IsDragSessionActive()) @@ -1737,10 +1762,7 @@ void BrowserView::Init() { #endif #if defined(OS_CHROMEOS) - if (browser_->type() == Browser::TYPE_NORMAL) { - browser_extender_.reset(new BrowserExtender(this)); - browser_extender_->Init(); - } + browser_extender_.reset(BrowserExtender::Create(this)); #endif } diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index 6e7400e..5703306 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -328,6 +328,13 @@ class BrowserView : public BrowserWindow, virtual bool GetAccessibleName(std::wstring* name); virtual void SetAccessibleName(const std::wstring& name); +#if defined(OS_CHROMEOS) + // Returns BrowserExtender. + BrowserExtender* browser_extender() const { + return browser_extender_.get(); + } +#endif + protected: // Overridden from views::View: virtual void Layout(); diff --git a/chrome/browser/views/panel_controller.cc b/chrome/browser/views/panel_controller.cc index 0d722db..7515b55 100644 --- a/chrome/browser/views/panel_controller.cc +++ b/chrome/browser/views/panel_controller.cc @@ -10,7 +10,11 @@ #include "base/scoped_ptr.h" #include "base/string_util.h" #include "chrome/browser/browser.h" +#if defined(TOOLKIT_VIEWS) +#include "chrome/browser/views/frame/browser_view.h" +#else #include "chrome/browser/gtk/browser_window_gtk.h" +#endif #include "chrome/browser/views/tabs/tab_overview_types.h" #include "chrome/common/x11_util.h" #include "grit/app_resources.h" @@ -22,6 +26,7 @@ #include "views/event.h" #include "views/view.h" #include "views/widget/widget_gtk.h" +#include "views/window/window.h" static int close_button_width; static int close_button_height; @@ -69,16 +74,35 @@ static void InitializeResources() { } // namespace +#if defined(TOOLKIT_VIEWS) +PanelController::PanelController(BrowserView* browser_window) + : browser_window_(browser_window), + panel_(browser_window->GetNativeHandle()), + panel_xid_(x11_util::GetX11WindowFromGtkWidget(GTK_WIDGET(panel_))), + title_window_(NULL), + expanded_(true), + mouse_down_(false), + dragging_(false) { + Init(browser_window->bounds()); +} +#else PanelController::PanelController(BrowserWindowGtk* browser_window) : browser_window_(browser_window), panel_(browser_window->window()), panel_xid_(x11_util::GetX11WindowFromGtkWidget(GTK_WIDGET(panel_))), + title_window_(NULL), expanded_(true), mouse_down_(false), dragging_(false) { - title_window_ = new views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW); + Init(browser_window->bounds()); +} +#endif + +void PanelController::Init(const gfx::Rect window_bounds) { gfx::Rect title_bounds( - 0, 0, browser_window->bounds().width(), kTitleHeight); + 0, 0, window_bounds.width(), kTitleHeight); + + title_window_ = new views::WidgetGtk(views::WidgetGtk::TYPE_WINDOW); title_window_->Init(NULL, title_bounds); title_ = title_window_->GetNativeView(); title_xid_ = x11_util::GetX11WindowFromGtkWidget(title_); @@ -105,6 +129,8 @@ PanelController::PanelController(BrowserWindowGtk* browser_window) } void PanelController::UpdateTitleBar() { + if (!browser_window_ || !title_window_) + return; Browser* browser = browser_window_->browser(); title_content_->title_label()->SetText( UTF16ToWideHack(browser->GetWindowTitleForCurrentTab())); @@ -197,11 +223,13 @@ bool PanelController::OnPanelClientEvent( } void PanelController::OnFocusIn() { - title_content_->OnFocusIn(); + if (title_window_) + title_content_->OnFocusIn(); } void PanelController::OnFocusOut() { - title_content_->OnFocusOut(); + if (title_window_) + title_content_->OnFocusOut(); } bool PanelController::PanelClientEvent(GdkEventClient* event) { @@ -214,13 +242,18 @@ bool PanelController::PanelClientEvent(GdkEventClient* event) { } void PanelController::Close() { - title_window_->Close(); + // ignore if the title window is already closed. + if (title_window_) { + title_window_->Close(); + title_window_ = NULL; + } } void PanelController::ButtonPressed( views::Button* sender, const views::Event& event) { - if (sender == title_content_->close_button()) { + if (title_window_ && sender == title_content_->close_button()) { browser_window_->Close(); + Close(); } } @@ -298,4 +331,3 @@ void PanelController::TitleContentView::OnFocusOut() { Layout(); SchedulePaint(); } - diff --git a/chrome/browser/views/panel_controller.h b/chrome/browser/views/panel_controller.h index bb5804f..ac9909c 100644 --- a/chrome/browser/views/panel_controller.h +++ b/chrome/browser/views/panel_controller.h @@ -9,7 +9,11 @@ #include "views/controls/button/button.h" +#if defined(TOOLKIT_VIEWS) +class BrowserView; +#else class BrowserWindowGtk; +#endif typedef unsigned long XID; namespace views { @@ -23,7 +27,11 @@ class WidgetGtk; // Controls interactions with the WM for popups / panels. class PanelController : public views::ButtonListener { public: +#if defined(TOOLKIT_VIEWS) + explicit PanelController(BrowserView* browser_window); +#else explicit PanelController(BrowserWindowGtk* browser_window); +#endif virtual ~PanelController() {} bool TitleMousePressed(const views::MouseEvent& event); @@ -68,8 +76,16 @@ class PanelController : public views::ButtonListener { GdkEventClient* event, PanelController* panel_controller); + // Initializes the panel controller with the window bounds. + void Init(const gfx::Rect window_bounds); + // Browser window containing content. +#if defined(TOOLKIT_VIEWS) + BrowserView* browser_window_; +#else BrowserWindowGtk* browser_window_; +#endif + // Gtk object for content. GtkWindow* panel_; // X id for content. @@ -108,4 +124,3 @@ class PanelController : public views::ButtonListener { }; #endif // CHROME_BROWSER_PANEL_CONTROLLER_H_ - diff --git a/chrome/browser/views/tabs/tab_overview_controller.cc b/chrome/browser/views/tabs/tab_overview_controller.cc index 853cdc5..ee26feebc 100644 --- a/chrome/browser/views/tabs/tab_overview_controller.cc +++ b/chrome/browser/views/tabs/tab_overview_controller.cc @@ -6,7 +6,13 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_process.h" +#if defined(TOOLKIT_VIEWS) +#include "chrome/common/x11_util.h" +#include "chrome/browser/chromeos/browser_extender.h" +#include "chrome/browser/views/frame/browser_view.h" +#else #include "chrome/browser/gtk/browser_window_gtk.h" +#endif #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/thumbnail_generator.h" #include "chrome/browser/views/tabs/tab_overview_cell.h" @@ -157,12 +163,22 @@ void TabOverviewController::ConfigureCell(TabOverviewCell* cell, void TabOverviewController::DragStarted() { DCHECK(!drag_browser_); drag_browser_ = browser_; +#if defined(TOOLKIT_VIEWS) + static_cast<BrowserView*>(browser_->window())-> + browser_extender()->set_can_close(false); +#else static_cast<BrowserWindowGtk*>(browser_->window())->set_drag_active(true); +#endif } void TabOverviewController::DragEnded() { +#if defined(TOOLKIT_VIEWS) + static_cast<BrowserView*>(browser_->window())-> + browser_extender()->set_can_close(true); +#else static_cast<BrowserWindowGtk*>(drag_browser_->window())-> set_drag_active(false); +#endif if (drag_browser_->tabstrip_model()->count() == 0) drag_browser_->tabstrip_model()->delegate()->CloseFrameAfterDragSession(); drag_browser_ = NULL; @@ -182,8 +198,7 @@ void TabOverviewController::SelectTab(int index) { void TabOverviewController::FocusBrowser() { TabOverviewTypes::Message message; message.set_type(TabOverviewTypes::Message::WM_FOCUS_WINDOW); - GtkWidget* browser_widget = GTK_WIDGET( - static_cast<BrowserWindowGtk*>(browser_->window())->GetNativeHandle()); + GtkWidget* browser_widget = GTK_WIDGET(browser_->window()->GetNativeHandle()); message.set_param(0, x11_util::GetX11WindowFromGtkWidget(browser_widget)); TabOverviewTypes::instance()->SendMessage(message); } diff --git a/chrome/browser/views/tabs/tab_overview_message_listener.cc b/chrome/browser/views/tabs/tab_overview_message_listener.cc index 86ba0c2..68e05a8 100644 --- a/chrome/browser/views/tabs/tab_overview_message_listener.cc +++ b/chrome/browser/views/tabs/tab_overview_message_listener.cc @@ -134,13 +134,13 @@ void TabOverviewMessageListener::ProcessMessage( // Over a mini-window, make sure the controller is showing the contents // of the browser the mouse is over. #if defined(TOOLKIT_VIEWS) - NOTIMPLEMENTED(); - // TODO(oshima): Figure out how to get BrowserView from XID - // in message.param(0). + BrowserView* browser_window = GetBrowserViewForGdkWindow( + gdk_window_lookup(message.param(0))); #else BrowserWindowGtk* browser_window = BrowserWindowGtk::GetBrowserWindowForNativeWindow( BrowserWindowGtk::GetBrowserWindowForXID(message.param(0))); +#endif if (!browser_window) return; @@ -154,7 +154,6 @@ void TabOverviewMessageListener::ProcessMessage( UserMetrics::RecordAction(L"TabOverview_DragOverMiniWindow", browser_window->browser()->profile()); -#endif } default: diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 5e4c04e..f6bafc2 100755 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -2408,6 +2408,12 @@ 'CHROME_V8', ], }], + ['chromeos==1 and toolkit_views==0', { + 'sources!': [ + 'browser/chromeos/browser_extender.cc', + 'browser/chromeos/browser_extender.h', + ], + }], ['chromeos==0 and toolkit_views==0', { 'sources/': [ ['exclude', '^browser/chromeos'], |