| Index: chrome/browser/ui/views/chrome_views_delegate.cc
|
| ===================================================================
|
| --- chrome/browser/ui/views/chrome_views_delegate.cc (revision 71191)
|
| +++ chrome/browser/ui/views/chrome_views_delegate.cc (working copy)
|
| @@ -5,9 +5,11 @@
|
| #include "chrome/browser/ui/views/chrome_views_delegate.h"
|
|
|
| #include "base/scoped_ptr.h"
|
| +#include "base/string_util.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/prefs/pref_service.h"
|
| +#include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/browser/ui/views/accessibility_event_router_views.h"
|
| #include "chrome/browser/ui/window_sizer.h"
|
| #include "gfx/rect.h"
|
| @@ -17,6 +19,23 @@
|
| #include "chrome/browser/app_icon_win.h"
|
| #endif
|
|
|
| +namespace {
|
| +
|
| +// The browser window placement data is stored by profile; all other window
|
| +// data is stored in Local State.
|
| +PrefService* GetPrefService(const std::wstring& window_name) {
|
| + if (StartsWith(window_name, L"browser", true)) {
|
| + return g_browser_process->profile_manager() ?
|
| + g_browser_process->profile_manager()->GetDefaultProfile()->GetPrefs() :
|
| + NULL;
|
| + } else {
|
| + return g_browser_process->local_state() ?
|
| + g_browser_process->local_state() : NULL;
|
| + }
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| ///////////////////////////////////////////////////////////////////////////////
|
| // ChromeViewsDelegate, views::ViewsDelegate implementation:
|
|
|
| @@ -27,12 +46,12 @@
|
| void ChromeViewsDelegate::SaveWindowPlacement(const std::wstring& window_name,
|
| const gfx::Rect& bounds,
|
| bool maximized) {
|
| - if (!g_browser_process->local_state())
|
| + PrefService* pref_service = GetPrefService(window_name);
|
| + if (!pref_service)
|
| return;
|
|
|
| - DictionaryValue* window_preferences =
|
| - g_browser_process->local_state()->GetMutableDictionary(
|
| - WideToUTF8(window_name).c_str());
|
| + DictionaryValue* window_preferences = pref_service->
|
| + GetMutableDictionary(WideToUTF8(window_name).c_str());
|
| window_preferences->SetInteger("left", bounds.x());
|
| window_preferences->SetInteger("top", bounds.y());
|
| window_preferences->SetInteger("right", bounds.right());
|
| @@ -51,12 +70,13 @@
|
|
|
| bool ChromeViewsDelegate::GetSavedWindowBounds(const std::wstring& window_name,
|
| gfx::Rect* bounds) const {
|
| - if (!g_browser_process->local_state())
|
| + PrefService* pref_service = GetPrefService(window_name);
|
| + if (!pref_service)
|
| return false;
|
|
|
| - const DictionaryValue* dictionary =
|
| - g_browser_process->local_state()->GetDictionary(
|
| - WideToUTF8(window_name).c_str());
|
| + const DictionaryValue* dictionary = pref_service->GetDictionary(
|
| + WideToUTF8(window_name).c_str());
|
| +
|
| int left, top, right, bottom;
|
| if (!dictionary || !dictionary->GetInteger("left", &left) ||
|
| !dictionary->GetInteger("top", &top) ||
|
| @@ -71,12 +91,13 @@
|
| bool ChromeViewsDelegate::GetSavedMaximizedState(
|
| const std::wstring& window_name,
|
| bool* maximized) const {
|
| - if (!g_browser_process->local_state())
|
| + PrefService* pref_service = GetPrefService(window_name);
|
| + if (!pref_service)
|
| return false;
|
|
|
| - const DictionaryValue* dictionary =
|
| - g_browser_process->local_state()->GetDictionary(
|
| - WideToUTF8(window_name).c_str());
|
| + const DictionaryValue* dictionary = pref_service->GetDictionary(
|
| + WideToUTF8(window_name).c_str());
|
| +
|
| return dictionary && dictionary->GetBoolean("maximized", maximized) &&
|
| maximized;
|
| }
|
|
|