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/browser/views | |
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/browser/views')
-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 |
6 files changed, 108 insertions, 18 deletions
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: |