diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-29 01:22:39 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-29 01:22:39 +0000 |
commit | 17635d02534099d1934d83db0b2fe77fe1a9ed0a (patch) | |
tree | 060e506d2cd328d7ed16a6cae787bb3f66c9d9bb /chrome/browser/chromeos | |
parent | b86f7011ca51378db1d9a8f8541a01db9324980a (diff) | |
download | chromium_src-17635d02534099d1934d83db0b2fe77fe1a9ed0a.zip chromium_src-17635d02534099d1934d83db0b2fe77fe1a9ed0a.tar.gz chromium_src-17635d02534099d1934d83db0b2fe77fe1a9ed0a.tar.bz2 |
Refactor panel controller so that notification window can use panel_controller.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/548194
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37476 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r-- | chrome/browser/chromeos/panel_browser_view.cc | 21 | ||||
-rw-r--r-- | chrome/browser/chromeos/panel_browser_view.h | 11 | ||||
-rw-r--r-- | chrome/browser/chromeos/panel_controller.cc | 22 | ||||
-rw-r--r-- | chrome/browser/chromeos/panel_controller.h | 22 |
4 files changed, 59 insertions, 17 deletions
diff --git a/chrome/browser/chromeos/panel_browser_view.cc b/chrome/browser/chromeos/panel_browser_view.cc index 19501c8..3981af5 100644 --- a/chrome/browser/chromeos/panel_browser_view.cc +++ b/chrome/browser/chromeos/panel_browser_view.cc @@ -13,6 +13,9 @@ PanelBrowserView::PanelBrowserView(Browser* browser) : BrowserView(browser) { } +//////////////////////////////////////////////////////////////////////////////// +// BrowserView overrides. + void PanelBrowserView::Init() { BrowserView::Init(); // The visibility of toolbar is controlled in @@ -31,7 +34,8 @@ void PanelBrowserView::Init() { } void PanelBrowserView::Show() { - panel_controller_.reset(new chromeos::PanelController(this)); + panel_controller_.reset( + new chromeos::PanelController(this, GetNativeHandle(), bounds())); BrowserView::Show(); } @@ -57,4 +61,19 @@ void PanelBrowserView::ActivationChanged(bool activated) { } } +//////////////////////////////////////////////////////////////////////////////// +// PanelController::Delegate overrides. + +string16 PanelBrowserView::GetPanelTitle() { + return browser()->GetWindowTitleForCurrentTab(); +} + +SkBitmap PanelBrowserView::GetPanelIcon() { + return browser()->GetCurrentPageIcon(); +} + +void PanelBrowserView::ClosePanel() { + Close(); +} + } // namespace chromeos diff --git a/chrome/browser/chromeos/panel_browser_view.h b/chrome/browser/chromeos/panel_browser_view.h index 027fd68..b269b3b 100644 --- a/chrome/browser/chromeos/panel_browser_view.h +++ b/chrome/browser/chromeos/panel_browser_view.h @@ -6,6 +6,7 @@ #define CHROME_BROWSER_CHROMEOS_PANEL_BROWSER_VIEW_H_ #include "base/scoped_ptr.h" +#include "chrome/browser/chromeos/panel_controller.h" #include "chrome/browser/views/frame/browser_view.h" class Browser; @@ -15,17 +16,23 @@ namespace chromeos { class PanelController; // A browser view that implements Panel specific behavior. -class PanelBrowserView : public BrowserView { +class PanelBrowserView : public BrowserView, + public PanelController::Delegate { public: explicit PanelBrowserView(Browser* browser); - // BrowserViews overrides. + // BrowserView overrides. virtual void Init(); virtual void Show(); virtual void Close(); virtual void UpdateTitleBar(); virtual void ActivationChanged(bool activated); + // PanelController::Delegate overrides + virtual string16 GetPanelTitle(); + virtual SkBitmap GetPanelIcon(); + virtual void ClosePanel(); + private: // Controls interactions with the window manager for popup panels. scoped_ptr<chromeos::PanelController> panel_controller_; diff --git a/chrome/browser/chromeos/panel_controller.cc b/chrome/browser/chromeos/panel_controller.cc index 3e308d9..8f8b491 100644 --- a/chrome/browser/chromeos/panel_controller.cc +++ b/chrome/browser/chromeos/panel_controller.cc @@ -12,7 +12,6 @@ #include "base/scoped_ptr.h" #include "base/string_util.h" #include "chrome/browser/browser.h" -#include "chrome/browser/views/frame/browser_view.h" #include "chrome/browser/views/tabs/tab_overview_types.h" #include "chrome/common/x11_util.h" #include "grit/app_resources.h" @@ -74,15 +73,17 @@ static void InitializeResources() { } // namespace -PanelController::PanelController(BrowserView* browser_window) - : browser_window_(browser_window), - panel_(browser_window->GetNativeHandle()), +PanelController::PanelController(Delegate* delegate, + GtkWindow* window, + const gfx::Rect& init_bounds) + : delegate_(delegate), + panel_(window), panel_xid_(x11_util::GetX11WindowFromGtkWidget(GTK_WIDGET(panel_))), title_window_(NULL), expanded_(true), mouse_down_(false), dragging_(false) { - Init(browser_window->bounds()); + Init(init_bounds); } void PanelController::Init(const gfx::Rect window_bounds) { @@ -110,7 +111,7 @@ void PanelController::Init(const gfx::Rect window_bounds) { &type_params); g_signal_connect( - panel_, "client-event", G_CALLBACK(OnPanelClientEvent), this); + G_OBJECT(panel_), "client-event", G_CALLBACK(OnPanelClientEvent), this); title_content_ = new TitleContentView(this); title_window_->SetContentsView(title_content_); @@ -118,12 +119,11 @@ void PanelController::Init(const gfx::Rect window_bounds) { } void PanelController::UpdateTitleBar() { - if (!browser_window_ || !title_window_) + if (!delegate_ || !title_window_) return; - Browser* browser = browser_window_->browser(); title_content_->title_label()->SetText( - UTF16ToWideHack(browser->GetWindowTitleForCurrentTab())); - title_content_->title_icon()->SetImage(browser->GetCurrentPageIcon()); + UTF16ToWideHack(delegate_->GetPanelTitle())); + title_content_->title_icon()->SetImage(delegate_->GetPanelIcon()); } bool PanelController::TitleMousePressed(const views::MouseEvent& event) { @@ -249,7 +249,7 @@ void PanelController::Close() { void PanelController::ButtonPressed( views::Button* sender, const views::Event& event) { if (title_window_ && sender == title_content_->close_button()) { - browser_window_->Close(); + delegate_->ClosePanel(); Close(); } } diff --git a/chrome/browser/chromeos/panel_controller.h b/chrome/browser/chromeos/panel_controller.h index 4276100..ff2055f 100644 --- a/chrome/browser/chromeos/panel_controller.h +++ b/chrome/browser/chromeos/panel_controller.h @@ -10,6 +10,7 @@ #include "views/controls/button/button.h" class BrowserView; +class SkBitmap; typedef unsigned long XID; namespace views { @@ -25,7 +26,22 @@ namespace chromeos { // Controls interactions with the WM for popups / panels. class PanelController : public views::ButtonListener { public: - explicit PanelController(BrowserView* browser_window); + // Delegate to control panel's appearance and behavior. + class Delegate { + public: + // Retrieves the title string of the panel. + virtual string16 GetPanelTitle() = 0; + + // Retrieves the icon to use in the panel's titlebar. + virtual SkBitmap GetPanelIcon() = 0; + + // Close the panel. Called when a close button is pressed. + virtual void ClosePanel() = 0; + }; + + PanelController(Delegate* delegate_window, + GtkWindow* window, + const gfx::Rect& init_bounds); virtual ~PanelController() {} bool TitleMousePressed(const views::MouseEvent& event); @@ -73,8 +89,8 @@ class PanelController : public views::ButtonListener { // Initializes the panel controller with the window bounds. void Init(const gfx::Rect window_bounds); - // Browser window containing content. - BrowserView* browser_window_; + // Panel's delegate. + Delegate* delegate_; // Gtk object for content. GtkWindow* panel_; |