diff options
author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-11 17:40:47 +0000 |
---|---|---|
committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-11 17:40:47 +0000 |
commit | 0d395bdee7ebb251bcabe06f4eb81a0b6570392e (patch) | |
tree | a59abf558af4025be3170af22d1dd23bcb0410ab /chrome/browser | |
parent | d0364b99e19f5bd2308003c27a2eabfa9248dd79 (diff) | |
download | chromium_src-0d395bdee7ebb251bcabe06f4eb81a0b6570392e.zip chromium_src-0d395bdee7ebb251bcabe06f4eb81a0b6570392e.tar.gz chromium_src-0d395bdee7ebb251bcabe06f4eb81a0b6570392e.tar.bz2 |
Cleanup and rearrange methods on BrowserWindow interface.
Review URL: http://codereview.chromium.org/10291
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5180 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/browser.h | 18 | ||||
-rw-r--r-- | chrome/browser/browser.vcproj | 4 | ||||
-rw-r--r-- | chrome/browser/browser_window.cc | 14 | ||||
-rw-r--r-- | chrome/browser/browser_window.h | 82 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip_model.h | 4 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip_model_unittest.cc | 1 | ||||
-rw-r--r-- | chrome/browser/views/first_run_bubble.cc | 9 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 52 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 12 | ||||
-rw-r--r-- | chrome/browser/views/info_bubble.cc | 15 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.h | 4 |
11 files changed, 50 insertions, 165 deletions
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index d1b93de..1912fd8 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -239,7 +239,6 @@ class Browser : public TabStripModelDelegate, PageTransition::Type transition, bool defer_load, SiteInstance* instance) const; - virtual void ShowApplicationMenu(const gfx::Point& p); virtual bool CanDuplicateContentsAt(int index); virtual void DuplicateContentsAt(int index); virtual void ValidateLoadingAnimations(); @@ -364,14 +363,9 @@ class Browser : public TabStripModelDelegate, typedef std::vector<TabContents*> UnloadListenerVector; - Browser(); - // Closes the frame. void CloseFrame(); - // Returns the root view for this browser. - views::RootView* GetRootView() const; - // Returns what the user's home page is, or the new tab page if the home page // has not been set. GURL GetHomePage(); @@ -394,11 +388,6 @@ class Browser : public TabStripModelDelegate, // TODO(beng): remove this. StatusBubble* GetStatusBubble(); - // Saves the location of the window to the history database. - void SaveWindowPlacementToDatabase(); - // Window placement memory across sessions. - void SaveWindowPlacement(); - // Notifies the history database of the index for all tabs whose index is // >= index. void SyncHistoryWithTabs(int index); @@ -443,11 +432,6 @@ class Browser : public TabStripModelDelegate, // Opens the Bug Report dialog. void OpenBugReportDialog(); - // Removes the InfoBar and download shelf for the specified TabContents, if - // they are presently attached. - // TODO(beng): REMOVE - void RemoveShelvesForTabContents(TabContents* contents); - // Copy the current page URL to the clipboard. void CopyCurrentURLToClipBoard(); @@ -517,6 +501,8 @@ class Browser : public TabStripModelDelegate, // BrowserView, or some more likely place. int initial_show_command_; + // TODO(beng): should be combined with ToolbarModel now that this is the only + // implementation. class BrowserToolbarModel : public ToolbarModel { public: explicit BrowserToolbarModel(Browser* browser) : browser_(browser) { } diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj index b2d2571..a3871db 100644 --- a/chrome/browser/browser.vcproj +++ b/chrome/browser/browser.vcproj @@ -994,10 +994,6 @@ > </File> <File - RelativePath=".\browser_window.cc" - > - </File> - <File RelativePath=".\browser_window.h" > </File> diff --git a/chrome/browser/browser_window.cc b/chrome/browser/browser_window.cc deleted file mode 100644 index 2f6021a..0000000 --- a/chrome/browser/browser_window.cc +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2006-2008 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/browser_window.h" - -#include <windows.h> - -void BrowserWindow::InfoBubbleClosing() { - // TODO(beng): (Cleanup) - move out of here! - HWND hwnd = static_cast<HWND>(GetPlatformID()); - // The frame is really inactive, send notification now. - DefWindowProc(hwnd, WM_NCACTIVATE, FALSE, 0); -} diff --git a/chrome/browser/browser_window.h b/chrome/browser/browser_window.h index 6f0e6ec..c76e553 100644 --- a/chrome/browser/browser_window.h +++ b/chrome/browser/browser_window.h @@ -47,11 +47,16 @@ class BrowserWindow { // events are still fired) until the drag ends, then close. virtual void Close() = 0; + // Activates (brings to front) the window. Restores the window from minimized + // state if necessary. + virtual void Activate() = 0; + + // Flashes the taskbar item associated with this frame. + virtual void FlashFrame() = 0; + // Return a platform dependent identifier for this frame. On Windows, this - // returns an HWND. - // TODO(beng): This should go away. The Browser object and friends should not - // be interacting with platform types. - virtual void* GetPlatformID() = 0; + // returns an HWND. DO NOT USE IN CROSS PLATFORM CODE. + virtual void* GetNativeHandle() = 0; // TODO(beng): REMOVE (obtain via BrowserFrame). // Return the TabStrip associated with the frame. @@ -60,50 +65,16 @@ class BrowserWindow { // Return the status bubble associated with the frame virtual StatusBubble* GetStatusBubble() = 0; - // Inform the receiving frame that the visibility of one of the shelfs/bars - // may have changed. - // TODO(beng): REMOVE - virtual void ShelfVisibilityChanged() {} - // Inform the receiving frame that an animation has progressed in the // selected tab. + // TODO(beng): Remove. Infobars/Boomarks bars should talk directly to + // BrowserView. virtual void SelectedTabToolbarSizeChanged(bool is_animating) = 0; // Inform the frame that the selected tab favicon or title has changed. Some // frames may need to refresh their title bar. // TODO(beng): make this pure virtual after XPFrame/VistaFrame retire. - virtual void UpdateTitleBar() { } - - // Sets the title displayed in various places within the OS, such as the task - // bar. - // TODO(beng): REMOVE - virtual void SetWindowTitle(const std::wstring& title) {} - - // Activates (brings to front) the window. Restores the window from minimized - // state if necessary. - virtual void Activate() = 0; - - // Flashes the taskbar item associated with this frame. - virtual void FlashFrame() = 0; - - // Makes the specified TabContents visible. If there is another TabContents - // visible presently, this method is responsible for hiding that TabContents - // cleanly as well. - // TODO(beng): REMOVE - virtual void ShowTabContents(TabContents* contents) {} - - // Sizes the frame to match the specified desired bounds for the contents. - // |contents_bounds| are in screen coordinates. - // TODO(beng): REMOVE - virtual void SizeToContents(const gfx::Rect& contents_bounds) = 0; - - // Set the accelerator table. This is called once after LoadAccelerators - // has been called on the frame. The callee becomes the owner of the passed - // map. The map associates accelerators with command ids. - // Note if you are not calling FrameUtil::LoadAccelerators() on this frame, - // this method is never invoked. - virtual void SetAcceleratorTable( - std::map<views::Accelerator, int>* accelerator_table) = 0; + virtual void UpdateTitleBar() = 0; // Updates internal state specifying whether the throbber is to be shown. // If the throbber was shown, and should still be shown, the frame of the @@ -120,21 +91,6 @@ class BrowserWindow { // Returns true if the frame is maximized (aka zoomed). virtual bool IsMaximized() = 0; - // TODO(beng): REMOVE - this work should be done entirely in the frames. - // Returns the bounds required to accomodate for some contents located at the - // provided rectangle. The result is in whatever coordinate system used for - // |content_rect|. - virtual gfx::Rect GetBoundsForContentBounds(const gfx::Rect content_rect) = 0; - - // Invoked by the InfoBubble when it is shown/hidden. XPFrame/VistaFrame use - // this notification to make sure they render as active even though they are - // not active while the bubble is shown. - virtual void InfoBubbleShowing() = 0; - // The implementation for this sends WM_NCACTIVATE with a value of FALSE for - // the window. Subclasses that need to customize should be sure and invoke - // this implementation too. - virtual void InfoBubbleClosing(); - // Returns the star button. virtual ToolbarStarToggle* GetStarButton() const = 0; @@ -147,29 +103,21 @@ class BrowserWindow { // Returns the Bookmark Bar view. virtual BookmarkBarView* GetBookmarkBarView() = 0; - // Returns the BrowserView. - // TODO(beng): remove this! temporary only! - virtual BrowserView* GetBrowserView() const = 0; - // Updates the toolbar with the state for the specified |contents|. virtual void UpdateToolbar(TabContents* contents, bool should_restore_state) = 0; - // Updates the UI with the specified Profile. - // TODO(beng): REMOVE - virtual void ProfileChanged(Profile* profile) {} - // Focuses the toolbar (for accessibility). virtual void FocusToolbar() = 0; + // Returns whether the bookmark bar is visible or not. + virtual bool IsBookmarkBarVisible() const = 0; + // Construct a BrowserWindow implementation for the specified |browser|. static BrowserWindow* CreateBrowserWindow(Browser* browser, const gfx::Rect& bounds, int show_command); - // Returns whether the bookmark bar is visible or not. - virtual bool IsBookmarkBarVisible() const = 0; - protected: friend class BrowserList; friend class BrowserView; diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h index 4329a6e..52e3761 100644 --- a/chrome/browser/tabs/tab_strip_model.h +++ b/chrome/browser/tabs/tab_strip_model.h @@ -124,10 +124,6 @@ class TabStripModelDelegate { bool defer_load, SiteInstance* instance) const = 0; - // Show the web application context menu at the provided point. |p| is in - // screen coordinate system. - virtual void ShowApplicationMenu(const gfx::Point& p) = 0; - // Return whether some contents can be duplicated. virtual bool CanDuplicateContentsAt(int index) = 0; diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc index d051bf9..f3015a9 100644 --- a/chrome/browser/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/tabs/tab_strip_model_unittest.cc @@ -1006,7 +1006,6 @@ class TabStripDummyDelegate : public TabStripModelDelegate { return dummy_contents_; return NULL; } - virtual void ShowApplicationMenu(const gfx::Point& p) {} virtual bool CanDuplicateContentsAt(int index) { return false; } virtual void DuplicateContentsAt(int index) {} virtual void ValidateLoadingAnimations() {} diff --git a/chrome/browser/views/first_run_bubble.cc b/chrome/browser/views/first_run_bubble.cc index 1b3e101..a11eb73 100644 --- a/chrome/browser/views/first_run_bubble.cc +++ b/chrome/browser/views/first_run_bubble.cc @@ -4,6 +4,7 @@ #include "chrome/browser/views/first_run_bubble.h" +#include "base/win_util.h" #include "chrome/app/locales/locale_settings.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" @@ -206,9 +207,11 @@ FirstRunBubble* FirstRunBubble::Show(HWND parent_hwnd, views::View* view = new FirstRunBubbleView(window); window->SetDelegate(window); window->Init(parent_hwnd, position_relative_to, view); - BrowserWindow* frame = window->GetHostingWindow(); - DCHECK(frame); - frame->InfoBubbleShowing(); + + views::Window* parent_window = + reinterpret_cast<views::Window*>(win_util::GetWindowUserData( + parent_hwnd)); + parent_window->DisableInactiveRendering(true); window->ShowWindow(SW_SHOW); return window; } diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 65afb62..8cc8ead 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -307,7 +307,21 @@ void BrowserView::Close() { frame_->GetWindow()->Close(); } -void* BrowserView::GetPlatformID() { +void BrowserView::Activate() { + frame_->GetWindow()->Activate(); +} + +void BrowserView::FlashFrame() { + FLASHWINFO fwi; + fwi.cbSize = sizeof(fwi); + fwi.hwnd = frame_->GetWindow()->GetHWND(); + fwi.dwFlags = FLASHW_ALL; + fwi.uCount = 4; + fwi.dwTimeout = 0; + FlashWindowEx(&fwi); +} + +void* BrowserView::GetNativeHandle() { return GetContainer()->GetHWND(); } @@ -336,29 +350,6 @@ void BrowserView::UpdateTitleBar() { frame_->GetWindow()->UpdateWindowIcon(); } -void BrowserView::Activate() { - frame_->GetWindow()->Activate(); -} - -void BrowserView::FlashFrame() { - FLASHWINFO fwi; - fwi.cbSize = sizeof(fwi); - fwi.hwnd = frame_->GetWindow()->GetHWND(); - fwi.dwFlags = FLASHW_ALL; - fwi.uCount = 4; - fwi.dwTimeout = 0; - FlashWindowEx(&fwi); -} - -void BrowserView::SizeToContents(const gfx::Rect& contents_bounds) { - frame_->SizeToContents(contents_bounds); -} - -void BrowserView::SetAcceleratorTable( - std::map<views::Accelerator, int>* accelerator_table) { - accelerator_table_.reset(accelerator_table); -} - void BrowserView::ValidateThrobber() { if (ShouldShowWindowIcon()) { TabContents* tab_contents = browser_->GetSelectedTabContents(); @@ -378,19 +369,6 @@ bool BrowserView::IsMaximized() { return frame_->GetWindow()->IsMaximized(); } -gfx::Rect BrowserView::GetBoundsForContentBounds( - const gfx::Rect content_rect) { - return frame_->GetWindowBoundsForClientBounds(content_rect); -} - -void BrowserView::InfoBubbleShowing() { - frame_->GetWindow()->DisableInactiveRendering(true); -} - -void BrowserView::InfoBubbleClosing() { - frame_->GetWindow()->DisableInactiveRendering(false); -} - ToolbarStarToggle* BrowserView::GetStarButton() const { return toolbar_->star_button(); } diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index 31469f4..8e04f6d 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -134,22 +134,16 @@ class BrowserView : public BrowserWindow, virtual void Init(); virtual void Show(int command, bool adjust_to_fit); virtual void Close(); - virtual void* GetPlatformID(); + virtual void Activate(); + virtual void FlashFrame(); + virtual void* GetNativeHandle(); virtual TabStrip* GetTabStrip() const; virtual StatusBubble* GetStatusBubble(); virtual void SelectedTabToolbarSizeChanged(bool is_animating); virtual void UpdateTitleBar(); - virtual void Activate(); - virtual void FlashFrame(); - virtual void SizeToContents(const gfx::Rect& contents_bounds); - virtual void SetAcceleratorTable( - std::map<views::Accelerator, int>* accelerator_table); virtual void ValidateThrobber(); virtual gfx::Rect GetNormalBounds(); virtual bool IsMaximized(); - virtual gfx::Rect GetBoundsForContentBounds(const gfx::Rect content_rect); - virtual void InfoBubbleShowing(); - virtual void InfoBubbleClosing(); virtual ToolbarStarToggle* GetStarButton() const; virtual LocationBarView* GetLocationBarView() const; virtual GoButton* GetGoButton() const; diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc index f2b9b27..00e5457 100644 --- a/chrome/browser/views/info_bubble.cc +++ b/chrome/browser/views/info_bubble.cc @@ -13,6 +13,7 @@ #include "chrome/common/resource_bundle.h" #include "chrome/common/win_util.h" #include "chrome/views/root_view.h" +#include "chrome/views/window.h" using views::View; @@ -71,9 +72,10 @@ InfoBubble* InfoBubble::Show(HWND parent_hwnd, InfoBubbleDelegate* delegate) { InfoBubble* window = new InfoBubble(); window->Init(parent_hwnd, position_relative_to, content); - BrowserWindow* frame = window->GetHostingWindow(); - if (frame) - frame->InfoBubbleShowing(); + views::Window* parent_window = + reinterpret_cast<views::Window*>(win_util::GetWindowUserData( + parent_hwnd)); + parent_window->DisableInactiveRendering(true); window->ShowWindow(SW_SHOW); window->delegate_ = delegate; return window; @@ -140,11 +142,12 @@ void InfoBubble::Init(HWND parent_hwnd, void InfoBubble::Close() { // We don't fade out because it looks terrible. - BrowserWindow* frame = GetHostingWindow(); if (delegate_) delegate_->InfoBubbleClosing(this); - if (frame) - frame->InfoBubbleClosing(); + views::Window* parent_window = + reinterpret_cast<views::Window*>( + win_util::GetWindowUserData(GetAncestor(GetHWND(), GA_ROOT))); + parent_window->DisableInactiveRendering(false); ContainerWin::Close(); } diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h index 3b96279e..ed752d0 100644 --- a/chrome/browser/views/tabs/tab_strip.h +++ b/chrome/browser/views/tabs/tab_strip.h @@ -53,10 +53,6 @@ class TabStrip : public views::View, // non drag-able Tab. bool HasAvailableDragActions() const; - // Ask the delegate to show the application menu at the provided point. - // The point is in screen coordinate system. - void ShowApplicationMenu(const gfx::Point& p); - // Returns true if the TabStrip can accept input events. This returns false // when the TabStrip is animating to a new state and as such the user should // not be allowed to interact with the TabStrip. |