Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7977)

Unified Diff: chrome/browser/ui/views/chrome_views_delegate.cc

Issue 5915006: Remove user-related data from local_state and add to user_preferences, i... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: svn pset Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}

Powered by Google App Engine
This is Rietveld 408576698