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

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: '' 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
« no previous file with comments | « chrome/browser/ui/gtk/browser_window_gtk.cc ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/chrome_views_delegate.cc
===================================================================
--- chrome/browser/ui/views/chrome_views_delegate.cc (revision 73335)
+++ chrome/browser/ui/views/chrome_views_delegate.cc (working copy)
@@ -5,11 +5,14 @@
#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 "chrome/common/pref_names.h"
#include "gfx/rect.h"
#include "ui/base/clipboard/clipboard.h"
@@ -17,6 +20,27 @@
#include "chrome/browser/app_icon_win.h"
#endif
+namespace {
+
+// Some window data should be stored in local state, instead of by profile; use
+// the window_name to differentiate between storage types. This function may
+// return NULL if the necessary PrefService has not yet been initialized.
+// TODO(mirandac): This function will also serve to separate windows by profile
+// in a multiprofile environment.
+PrefService* GetPrefsForWindow(const std::wstring& window_name) {
+ if (LowerCaseEqualsASCII(window_name, prefs::kTaskManagerWindowPlacement)) {
+ return g_browser_process->local_state();
+ } else {
+ if (!g_browser_process->profile_manager()) {
+ return NULL;
+ }
+ return g_browser_process->profile_manager()->GetDefaultProfile()->
+ GetPrefs();
+ }
+}
+
+} // namespace
+
///////////////////////////////////////////////////////////////////////////////
// ChromeViewsDelegate, views::ViewsDelegate implementation:
@@ -27,12 +51,12 @@
void ChromeViewsDelegate::SaveWindowPlacement(const std::wstring& window_name,
const gfx::Rect& bounds,
bool maximized) {
- if (!g_browser_process->local_state())
+ PrefService* prefs = GetPrefsForWindow(window_name);
+ if (!prefs)
return;
DictionaryValue* window_preferences =
- g_browser_process->local_state()->GetMutableDictionary(
- WideToUTF8(window_name).c_str());
+ prefs->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 +75,12 @@
bool ChromeViewsDelegate::GetSavedWindowBounds(const std::wstring& window_name,
gfx::Rect* bounds) const {
- if (!g_browser_process->local_state())
+ PrefService* prefs = GetPrefsForWindow(window_name);
+ if (!prefs)
return false;
const DictionaryValue* dictionary =
- g_browser_process->local_state()->GetDictionary(
- WideToUTF8(window_name).c_str());
+ prefs->GetDictionary(WideToUTF8(window_name).c_str());
int left, top, right, bottom;
if (!dictionary || !dictionary->GetInteger("left", &left) ||
!dictionary->GetInteger("top", &top) ||
@@ -71,12 +95,13 @@
bool ChromeViewsDelegate::GetSavedMaximizedState(
const std::wstring& window_name,
bool* maximized) const {
- if (!g_browser_process->local_state())
+ PrefService* prefs = GetPrefsForWindow(window_name);
+ if (!prefs)
return false;
const DictionaryValue* dictionary =
- g_browser_process->local_state()->GetDictionary(
- WideToUTF8(window_name).c_str());
+ prefs->GetDictionary(WideToUTF8(window_name).c_str());
+
return dictionary && dictionary->GetBoolean("maximized", maximized) &&
maximized;
}
« no previous file with comments | « chrome/browser/ui/gtk/browser_window_gtk.cc ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698