Commit 17168e2b authored by pinkerton@google.com's avatar pinkerton@google.com

Save and restore the options window position instead of always centering the window.

BUG=34644
TEST=Open options window, move and close the window, re-open and ensure position is saved. 
Contributed by Steven Pennington <spenn@engr.uvic.ca>

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57086 0039d316-1c4b-4281-b951-d872f2087c98
parent 4a6861a3
...@@ -83,3 +83,4 @@ Giuseppe Iuculano <giuseppe@iuculano.it> ...@@ -83,3 +83,4 @@ Giuseppe Iuculano <giuseppe@iuculano.it>
litl LLC litl LLC
James Willcox <jwillcox@litl.com> James Willcox <jwillcox@litl.com>
Shreyas VA <v.a.shreyas@gmail.com> Shreyas VA <v.a.shreyas@gmail.com>
Steven Pennington <spenn@engr.uvic.ca>
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "chrome/browser/options_window.h" #include "chrome/browser/options_window.h"
#include "app/l10n_util.h" #include "app/l10n_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_list.h" #include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_window.h" #include "chrome/browser/browser_window.h"
...@@ -44,6 +45,7 @@ class OptionsWindowView : public views::View, ...@@ -44,6 +45,7 @@ class OptionsWindowView : public views::View,
return MessageBoxFlags::DIALOGBUTTON_CANCEL; return MessageBoxFlags::DIALOGBUTTON_CANCEL;
} }
virtual std::wstring GetWindowTitle() const; virtual std::wstring GetWindowTitle() const;
virtual std::wstring GetWindowName() const;
virtual void WindowClosing(); virtual void WindowClosing();
virtual bool Cancel(); virtual bool Cancel();
virtual views::View* GetContentsView(); virtual views::View* GetContentsView();
...@@ -102,23 +104,7 @@ OptionsWindowView::~OptionsWindowView() { ...@@ -102,23 +104,7 @@ OptionsWindowView::~OptionsWindowView() {
void OptionsWindowView::ShowOptionsPage(OptionsPage page, void OptionsWindowView::ShowOptionsPage(OptionsPage page,
OptionsGroup highlight_group) { OptionsGroup highlight_group) {
if (Browser* b = BrowserList::GetLastActive()) { // Positioning is handled by window_delegate. we just need to show the window.
// Move dialog to user expected position.
gfx::Rect frame_bounds = b->window()->GetRestoredBounds();
if (b->window()->IsMaximized()) {
// For maximized window get monitor size as a bounding box.
WindowSizer::MonitorInfoProvider* provider =
WindowSizer::CreateDefaultMonitorInfoProvider();
frame_bounds = provider->GetMonitorWorkAreaMatching(frame_bounds);
delete provider;
}
gfx::Point origin = frame_bounds.origin();
origin.Offset(
(frame_bounds.width() - window()->GetBounds().width()) / 2,
(frame_bounds.height() - window()->GetBounds().height()) / 2);
window()->SetBounds(gfx::Rect(origin, window()->GetBounds().size()), NULL);
}
// This will show invisible windows and bring visible windows to the front. // This will show invisible windows and bring visible windows to the front.
window()->Show(); window()->Show();
...@@ -145,6 +131,10 @@ std::wstring OptionsWindowView::GetWindowTitle() const { ...@@ -145,6 +131,10 @@ std::wstring OptionsWindowView::GetWindowTitle() const {
l10n_util::GetString(IDS_PRODUCT_NAME)); l10n_util::GetString(IDS_PRODUCT_NAME));
} }
std::wstring OptionsWindowView::GetWindowName() const {
return UTF8ToWide(prefs::kPreferencesWindowPlacement);
}
void OptionsWindowView::WindowClosing() { void OptionsWindowView::WindowClosing() {
// Clear the static instance so that the next time ShowOptionsWindow() is // Clear the static instance so that the next time ShowOptionsWindow() is
// called a new window is opened. // called a new window is opened.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment