diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-18 17:38:26 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-18 17:38:26 +0000 |
commit | c22198534b75e5576b1ab7a5d3b00db48e057caf (patch) | |
tree | f1bd3aa45d92d4b490780bb063fbe35b417392c6 | |
parent | 5d1c2aa14ddacea07ca8dbf27c7d14055fdfb8e4 (diff) | |
download | chromium_src-c22198534b75e5576b1ab7a5d3b00db48e057caf.zip chromium_src-c22198534b75e5576b1ab7a5d3b00db48e057caf.tar.gz chromium_src-c22198534b75e5576b1ab7a5d3b00db48e057caf.tar.bz2 |
Remove BrowserWindow::Init().
This belongs as a private method of BrowserView. Neither mac nor linux uses it.
Review URL: http://codereview.chromium.org/42298
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11982 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser_window.h | 5 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.h | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_cocoa.mm | 5 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.cc | 92 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_window_gtk.h | 1 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 102 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 4 |
7 files changed, 99 insertions, 111 deletions
diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h index b779ba1..e91f945 100644 --- a/chrome/browser/browser_window.h +++ b/chrome/browser/browser_window.h @@ -29,11 +29,6 @@ class Rect; // NOTE: All getters except GetTabStrip() may return NULL. class BrowserWindow { public: - // Initialize the frame. This is called on Windows via the views system. It - // doesn't get called on other platforms so don't do stuff here on other - // platforms. - virtual void Init() = 0; - // Show the window, or activates it if it's already visible. virtual void Show() = 0; diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h index 9f314ab..fa4661c 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.h +++ b/chrome/browser/cocoa/browser_window_cocoa.h @@ -29,7 +29,6 @@ class BrowserWindowCocoa : public BrowserWindow { virtual ~BrowserWindowCocoa(); // Overridden from BrowserWindow - virtual void Init(); virtual void Show(); virtual void SetBounds(const gfx::Rect& bounds); virtual void Close(); diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index 0427a6b..84729fb 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -20,11 +20,6 @@ BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser, BrowserWindowCocoa::~BrowserWindowCocoa() { } -void BrowserWindowCocoa::Init() { - // Remember, no code here. This doesn't get called on the Mac. Put code into - // the constructor, above, instead. -} - void BrowserWindowCocoa::Show() { [window_ makeKeyAndOrderFront:controller_]; } diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index e7aa460..24a03bf 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -107,57 +107,12 @@ gboolean OnKeyPress(GtkWindow* window, GdkEventKey* event, gpointer userdata) { } // namespace +// TODO(estade): Break up this constructor into helper functions to improve +// readability. BrowserWindowGtk::BrowserWindowGtk(Browser* browser) : browser_(browser), // TODO(port): make this a pref. custom_frame_(false) { - Init(); - browser_->tabstrip_model()->AddObserver(this); -} - -BrowserWindowGtk::~BrowserWindowGtk() { - browser_->tabstrip_model()->RemoveObserver(this); - - Close(); -} - -gboolean BrowserWindowGtk::OnContentAreaExpose(GtkWidget* widget, - GdkEventExpose* e, - BrowserWindowGtk* window) { - if (window->custom_frame_) { - NOTIMPLEMENTED() << " needs custom drawing for the custom frame."; - return FALSE; - } - - // The theme graphics include the 2px frame, but we don't draw the frame - // in the non-custom-frame mode. So we subtract it off. - const int kFramePixels = 2; - - GdkPixbuf* pixbuf = - gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, // alpha - 8, // bit depth - widget->allocation.width, - BrowserToolbarGtk::kToolbarHeight + kFramePixels); - -#ifndef NDEBUG - // Fill with a bright color so we can see any pixels we're missing. - gdk_pixbuf_fill(pixbuf, 0x00FFFFFF); -#endif - - window->content_area_ninebox_->RenderTopCenterStrip(pixbuf, 0, - widget->allocation.width); - gdk_draw_pixbuf(widget->window, NULL, pixbuf, - 0, 0, - widget->allocation.x, - widget->allocation.y - kFramePixels, - -1, -1, - GDK_RGB_DITHER_NORMAL, 0, 0); - gdk_pixbuf_unref(pixbuf); - - return FALSE; // Allow subwidgets to paint. -} - -void BrowserWindowGtk::Init() { window_ = GTK_WINDOW(gtk_window_new(GTK_WINDOW_TOPLEVEL)); gtk_window_set_default_size(window_, 640, 480); g_signal_connect(window_, "destroy", @@ -214,6 +169,49 @@ void BrowserWindowGtk::Init() { gtk_container_add(GTK_CONTAINER(window_), vbox_); gtk_widget_show(vbox_); + browser_->tabstrip_model()->AddObserver(this); +} + +BrowserWindowGtk::~BrowserWindowGtk() { + browser_->tabstrip_model()->RemoveObserver(this); + + Close(); +} + +gboolean BrowserWindowGtk::OnContentAreaExpose(GtkWidget* widget, + GdkEventExpose* e, + BrowserWindowGtk* window) { + if (window->custom_frame_) { + NOTIMPLEMENTED() << " needs custom drawing for the custom frame."; + return FALSE; + } + + // The theme graphics include the 2px frame, but we don't draw the frame + // in the non-custom-frame mode. So we subtract it off. + const int kFramePixels = 2; + + GdkPixbuf* pixbuf = + gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, // alpha + 8, // bit depth + widget->allocation.width, + BrowserToolbarGtk::kToolbarHeight + kFramePixels); + +#ifndef NDEBUG + // Fill with a bright color so we can see any pixels we're missing. + gdk_pixbuf_fill(pixbuf, 0x00FFFFFF); +#endif + + window->content_area_ninebox_->RenderTopCenterStrip(pixbuf, 0, + widget->allocation.width); + gdk_draw_pixbuf(widget->window, NULL, pixbuf, + 0, 0, + widget->allocation.x, + widget->allocation.y - kFramePixels, + -1, -1, + GDK_RGB_DITHER_NORMAL, 0, 0); + gdk_pixbuf_unref(pixbuf); + + return FALSE; // Allow subwidgets to paint. } void BrowserWindowGtk::Show() { diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h index 89eaa6e..24f7449 100644 --- a/chrome/browser/gtk/browser_window_gtk.h +++ b/chrome/browser/gtk/browser_window_gtk.h @@ -30,7 +30,6 @@ class BrowserWindowGtk : public BrowserWindow, virtual ~BrowserWindowGtk(); // Overridden from BrowserWindow - virtual void Init(); virtual void Show(); virtual void SetBounds(const gfx::Rect& bounds); virtual void Close(); diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index b405280..e896fe4 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -432,57 +432,6 @@ void BrowserView::RegisterBrowserViewPrefs(PrefService* prefs) { /////////////////////////////////////////////////////////////////////////////// // BrowserView, BrowserWindow implementation: -void BrowserView::Init() { - // Stow a pointer to this object onto the window handle so that we can get - // at it later when all we have is a HWND. - SetProp(GetWidget()->GetNativeView(), kBrowserViewKey, this); - - // Start a hung plugin window detector for this browser object (as long as - // hang detection is not disabled). - if (!CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDisableHangMonitor)) { - InitHangMonitor(); - } - - LoadAccelerators(); - SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); - - tabstrip_ = new TabStrip(browser_->tabstrip_model()); - tabstrip_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP)); - AddChildView(tabstrip_); - - toolbar_ = new BrowserToolbarView(browser_.get()); - AddChildView(toolbar_); - toolbar_->SetID(VIEW_ID_TOOLBAR); - toolbar_->Init(browser_->profile()); - toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); - - infobar_container_ = new InfoBarContainer(this); - AddChildView(infobar_container_); - - FindBarWin* find_bar_win = new FindBarWin(this); - - find_bar_controller_.reset(new FindBarController(find_bar_win)); - find_bar_win->set_find_bar_controller(find_bar_controller_.get()); - - contents_container_ = new TabContentsContainerView; - set_contents_view(contents_container_); - AddChildView(contents_container_); - - status_bubble_.reset(new StatusBubbleViews(GetWidget())); - -#ifdef CHROME_PERSONALIZATION - const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - EnablePersonalization(!command_line.HasSwitch(switches::kDisableP13n)); - if (IsPersonalizationEnabled()) { - personalization_ = Personalization::CreateFramePersonalization( - browser_->profile(), this); - } -#endif - - InitSystemMenu(); -} - void BrowserView::Show() { // If the window is already visible, just activate it. if (frame_->IsVisible()) { @@ -1276,6 +1225,57 @@ void BrowserView::ViewHierarchyChanged(bool is_add, /////////////////////////////////////////////////////////////////////////////// // BrowserView, private: +void BrowserView::Init() { + // Stow a pointer to this object onto the window handle so that we can get + // at it later when all we have is a HWND. + SetProp(GetWidget()->GetNativeView(), kBrowserViewKey, this); + + // Start a hung plugin window detector for this browser object (as long as + // hang detection is not disabled). + if (!CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableHangMonitor)) { + InitHangMonitor(); + } + + LoadAccelerators(); + SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); + + tabstrip_ = new TabStrip(browser_->tabstrip_model()); + tabstrip_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TABSTRIP)); + AddChildView(tabstrip_); + + toolbar_ = new BrowserToolbarView(browser_.get()); + AddChildView(toolbar_); + toolbar_->SetID(VIEW_ID_TOOLBAR); + toolbar_->Init(browser_->profile()); + toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); + + infobar_container_ = new InfoBarContainer(this); + AddChildView(infobar_container_); + + FindBarWin* find_bar_win = new FindBarWin(this); + + find_bar_controller_.reset(new FindBarController(find_bar_win)); + find_bar_win->set_find_bar_controller(find_bar_controller_.get()); + + contents_container_ = new TabContentsContainerView; + set_contents_view(contents_container_); + AddChildView(contents_container_); + + status_bubble_.reset(new StatusBubbleViews(GetWidget())); + +#ifdef CHROME_PERSONALIZATION + const CommandLine& command_line = *CommandLine::ForCurrentProcess(); + EnablePersonalization(!command_line.HasSwitch(switches::kDisableP13n)); + if (IsPersonalizationEnabled()) { + personalization_ = Personalization::CreateFramePersonalization( + browser_->profile(), this); + } +#endif + + InitSystemMenu(); +} + void BrowserView::InitSystemMenu() { HMENU system_menu = GetSystemMenu(frame_->GetNativeView(), FALSE); system_menu_.reset(new Menu(system_menu)); diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index d1a57a5..6386999 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -162,7 +162,6 @@ class BrowserView : public BrowserWindow, static void RegisterBrowserViewPrefs(PrefService* prefs); // Overridden from BrowserWindow: - virtual void Init(); virtual void Show(); virtual void SetBounds(const gfx::Rect& bounds); virtual void Close(); @@ -275,6 +274,9 @@ class BrowserView : public BrowserWindow, RECT window_rect; }; + // Browser window related initializations. + void Init(); + // Creates the system menu. void InitSystemMenu(); |