summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browser.cc32
-rw-r--r--chrome/browser/browser.h2
-rw-r--r--chrome/browser/views/frame/browser_view.cc9
-rw-r--r--chrome/browser/views/frame/browser_view.h1
4 files changed, 23 insertions, 21 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 19ecce9..69f23a9e 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -309,33 +309,25 @@ bool Browser::IsCommandEnabled(int id) const {
///////////////////////////////////////////////////////////////////////////////
// Browser, State Storage and Retrieval for UI:
-void Browser::SaveWindowPlacement(const gfx::Rect& bounds, bool maximized) {
- // We don't save window position for popups.
- if (type() == BrowserType::BROWSER)
- return;
-
- // First save to local state, this is for remembering on subsequent starts.
- PrefService* prefs = g_browser_process->local_state();
- DCHECK(prefs);
+std::wstring Browser::GetWindowPlacementKey() const {
std::wstring name(prefs::kBrowserWindowPlacement);
if (!app_name_.empty()) {
name.append(L"_");
name.append(app_name_);
}
+ return name;
+}
- DictionaryValue* win_pref = prefs->GetMutableDictionary(name.c_str());
- DCHECK(win_pref);
- win_pref->SetInteger(L"top", bounds.y());
- win_pref->SetInteger(L"left", bounds.x());
- win_pref->SetInteger(L"bottom", bounds.bottom());
- win_pref->SetInteger(L"right", bounds.right());
- win_pref->SetBoolean(L"maximized", maximized);
+bool Browser::ShouldSaveWindowPlacement() const {
+ // We don't save window position for popups.
+ return type() != BrowserType::BROWSER;
+}
- // Then save to the session storage service, used when reloading a past
- // session. Note that we don't want to be the ones who cause lazy
- // initialization of the session service. This function gets called during
- // initial window showing, and we don't want to bring in the session service
- // this early.
+void Browser::SaveWindowPlacement(const gfx::Rect& bounds, bool maximized) {
+ // Save to the session storage service, used when reloading a past session.
+ // Note that we don't want to be the ones who cause lazy initialization of
+ // the session service. This function gets called during initial window
+ // showing, and we don't want to bring in the session service this early.
if (profile()->HasSessionService()) {
SessionService* session_service = profile()->GetSessionService();
if (session_service)
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index a1ff84e..1f21962 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -98,6 +98,8 @@ class Browser : public TabStripModelDelegate,
// State Storage and Retrieval for UI ///////////////////////////////////////
// Save and restore the window position.
+ std::wstring GetWindowPlacementKey() const;
+ bool ShouldSaveWindowPlacement() const;
void SaveWindowPlacement(const gfx::Rect& bounds, bool maximized);
gfx::Rect GetSavedWindowBounds() const;
bool GetSavedMaximizedState() const;
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index 873d38a..b13f0b3 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -709,10 +709,17 @@ bool BrowserView::ExecuteWindowsCommand(int command_id) {
return false;
}
+std::wstring BrowserView::GetWindowName() const {
+ return browser_->GetWindowPlacementKey();
+}
+
void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds,
bool maximized,
bool always_on_top) {
- browser_->SaveWindowPlacement(bounds, maximized);
+ if (browser_->ShouldSaveWindowPlacement()) {
+ WindowDelegate::SaveWindowPlacement(bounds, maximized, always_on_top);
+ browser_->SaveWindowPlacement(bounds, maximized);
+ }
}
bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const {
diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h
index bf6a41b..fcc0ee4 100644
--- a/chrome/browser/views/frame/browser_view.h
+++ b/chrome/browser/views/frame/browser_view.h
@@ -197,6 +197,7 @@ class BrowserView : public BrowserWindow,
virtual SkBitmap GetWindowIcon();
virtual bool ShouldShowWindowIcon() const;
virtual bool ExecuteWindowsCommand(int command_id);
+ virtual std::wstring GetWindowName() const;
virtual void SaveWindowPlacement(const gfx::Rect& bounds,
bool maximized,
bool always_on_top);