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>
litl LLC
James Willcox <jwillcox@litl.com>
Shreyas VA <v.a.shreyas@gmail.com>
Steven Pennington <spenn@engr.uvic.ca>
......@@ -5,6 +5,7 @@
#include "chrome/browser/options_window.h"
#include "app/l10n_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_window.h"
......@@ -44,6 +45,7 @@ class OptionsWindowView : public views::View,
return MessageBoxFlags::DIALOGBUTTON_CANCEL;
}
virtual std::wstring GetWindowTitle() const;
virtual std::wstring GetWindowName() const;
virtual void WindowClosing();
virtual bool Cancel();
virtual views::View* GetContentsView();
......@@ -102,23 +104,7 @@ OptionsWindowView::~OptionsWindowView() {
void OptionsWindowView::ShowOptionsPage(OptionsPage page,
OptionsGroup highlight_group) {
if (Browser* b = BrowserList::GetLastActive()) {
// 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);
}
// Positioning is handled by window_delegate. we just need to show the window.
// This will show invisible windows and bring visible windows to the front.
window()->Show();
......@@ -145,6 +131,10 @@ std::wstring OptionsWindowView::GetWindowTitle() const {
l10n_util::GetString(IDS_PRODUCT_NAME));
}
std::wstring OptionsWindowView::GetWindowName() const {
return UTF8ToWide(prefs::kPreferencesWindowPlacement);
}
void OptionsWindowView::WindowClosing() {
// Clear the static instance so that the next time ShowOptionsWindow() is
// 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