summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/debugger/devtools_window.cc4
-rw-r--r--chrome/browser/net/predictor_api.cc12
-rw-r--r--chrome/browser/prefs/browser_prefs.cc32
-rw-r--r--chrome/browser/prefs/browser_prefs.h12
-rw-r--r--chrome/browser/prefs/pref_service_uitest.cc96
-rw-r--r--chrome/browser/profiles/profile_impl.cc5
-rw-r--r--chrome/browser/ui/browser.cc21
-rw-r--r--chrome/browser/ui/browser.h7
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller.mm6
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_private.mm7
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_unittest.mm4
-rw-r--r--chrome/browser/ui/cocoa/dev_tools_controller.h6
-rw-r--r--chrome/browser/ui/cocoa/dev_tools_controller.mm19
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc14
-rw-r--r--chrome/browser/ui/views/chrome_views_delegate.cc20
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc8
-rw-r--r--chrome/browser/ui/window_sizer.cc19
-rw-r--r--chrome/browser/ui/window_sizer.h5
-rw-r--r--chrome/common/pref_names.cc10
-rw-r--r--chrome/test/data/profiles/window_placement/Default/Preferences12
20 files changed, 88 insertions, 231 deletions
diff --git a/chrome/browser/debugger/devtools_window.cc b/chrome/browser/debugger/devtools_window.cc
index 9407eb1..9e86f28 100644
--- a/chrome/browser/debugger/devtools_window.cc
+++ b/chrome/browser/debugger/devtools_window.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -216,7 +216,7 @@ void DevToolsWindow::CreateDevToolsBrowser() {
wp_key.append("_");
wp_key.append(kDevToolsApp);
- PrefService* prefs = profile_->GetPrefs();
+ PrefService* prefs = g_browser_process->local_state();
if (!prefs->FindPreference(wp_key.c_str())) {
prefs->RegisterDictionaryPref(wp_key.c_str());
}
diff --git a/chrome/browser/net/predictor_api.cc b/chrome/browser/net/predictor_api.cc
index 52a1497..e16e8e9 100644
--- a/chrome/browser/net/predictor_api.cc
+++ b/chrome/browser/net/predictor_api.cc
@@ -20,7 +20,6 @@
#include "chrome/browser/net/preconnect.h"
#include "chrome/browser/net/referrer.h"
#include "chrome/browser/net/url_info.h"
-#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/profiles/profile.h"
@@ -395,15 +394,16 @@ static void InitNetworkPredictor(TimeDelta max_dns_queue_delay,
prefs::kDnsPrefetchingHostReferralList)->DeepCopy());
// Remove obsolete preferences from local state if necessary.
- int current_version =
- local_state->GetInteger(prefs::kMultipleProfilePrefMigration);
- if ((current_version & browser::DNS_PREFS) == 0) {
+ int dns_prefs_version =
+ user_prefs->GetInteger(prefs::kMultipleProfilePrefMigration);
+ if (dns_prefs_version < 1) {
+ // These prefs only need to be registered if they need to be cleared from
+ // local state.
local_state->RegisterListPref(prefs::kDnsStartupPrefetchList);
local_state->RegisterListPref(prefs::kDnsHostReferralList);
local_state->ClearPref(prefs::kDnsStartupPrefetchList);
local_state->ClearPref(prefs::kDnsHostReferralList);
- local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
- current_version | browser::DNS_PREFS);
+ user_prefs->SetInteger(prefs::kMultipleProfilePrefMigration, 1);
}
g_browser_process->io_thread()->InitNetworkPredictor(
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 9bf8f4e0..4bbd995 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -55,7 +55,6 @@
#include "chrome/browser/translate/translate_prefs.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/upgrade_detector.h"
-#include "chrome/common/pref_names.h"
#if defined(TOOLKIT_VIEWS) // TODO(port): whittle this down as we port
#include "chrome/browser/ui/views/browser_actions_container.h"
@@ -160,35 +159,4 @@ void RegisterUserPrefs(PrefService* user_prefs) {
policy::ProfilePolicyContext::RegisterUserPrefs(user_prefs);
}
-void MigrateBrowserPrefs(PrefService* user_prefs, PrefService* local_state) {
- // Copy pref values which have been migrated to user_prefs from local_state,
- // or remove them from local_state outright, if copying is not required.
- int current_version =
- local_state->GetInteger(prefs::kMultipleProfilePrefMigration);
-
- if ((current_version & WINDOWS_PREFS) == 0) {
- // Migrate the devtools split location preference.
- local_state->RegisterIntegerPref(prefs::kDevToolsSplitLocation, -1);
- DCHECK(user_prefs->FindPreference(prefs::kDevToolsSplitLocation));
- if (local_state->HasPrefPath(prefs::kDevToolsSplitLocation)) {
- user_prefs->SetInteger(prefs::kDevToolsSplitLocation,
- local_state->GetInteger(prefs::kDevToolsSplitLocation));
- }
- local_state->ClearPref(prefs::kDevToolsSplitLocation);
-
- // Migrate the browser window placement preference.
- local_state->RegisterDictionaryPref(prefs::kBrowserWindowPlacement);
- DCHECK(user_prefs->FindPreference(prefs::kBrowserWindowPlacement));
- if (local_state->HasPrefPath(prefs::kBrowserWindowPlacement)) {
- user_prefs->Set(prefs::kBrowserWindowPlacement,
- *(local_state->FindPreference(prefs::kBrowserWindowPlacement)->
- GetValue()->DeepCopy()));
- }
- local_state->ClearPref(prefs::kBrowserWindowPlacement);
-
- local_state->SetInteger(prefs::kMultipleProfilePrefMigration,
- current_version | WINDOWS_PREFS);
- }
-}
-
} // namespace browser
diff --git a/chrome/browser/prefs/browser_prefs.h b/chrome/browser/prefs/browser_prefs.h
index 4df26c1..ef109a4 100644
--- a/chrome/browser/prefs/browser_prefs.h
+++ b/chrome/browser/prefs/browser_prefs.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -10,19 +10,11 @@ class PrefService;
namespace browser {
-// Bitmask for kMultipleProfilePrefMigration.
-enum MigratedPreferences {
- NO_PREFS = 0,
- DNS_PREFS = 1 << 0,
- WINDOWS_PREFS = 1 << 1,
-};
-
// Makes the PrefService objects aware of all the prefs.
void RegisterAllPrefs(PrefService* user_prefs, PrefService* local_state);
void RegisterLocalState(PrefService* local_state);
void RegisterUserPrefs(PrefService* user_prefs);
-// Migrate prefs from local_state to user_prefs.
-void MigrateBrowserPrefs(PrefService* user_prefs, PrefService* local_state);
+
} // namespace browser
#endif // CHROME_BROWSER_PREFS_BROWSER_PREFS_H__
diff --git a/chrome/browser/prefs/pref_service_uitest.cc b/chrome/browser/prefs/pref_service_uitest.cc
index c6540d74..9712481 100644
--- a/chrome/browser/prefs/pref_service_uitest.cc
+++ b/chrome/browser/prefs/pref_service_uitest.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -29,27 +29,17 @@ class PreferenceServiceTest : public UITest {
file_util::Delete(tmp_profile_, true);
file_util::CreateDirectory(tmp_profile_);
- FilePath reference_pref_file;
- if (new_profile_) {
- reference_pref_file = test_data_directory_
- .AppendASCII("profiles")
- .AppendASCII("window_placement")
- .AppendASCII("Default")
- .Append(chrome::kPreferencesFilename);
- tmp_pref_file_ = tmp_profile_.AppendASCII("Default");
- ASSERT_TRUE(file_util::CreateDirectory(tmp_pref_file_));
- tmp_pref_file_ = tmp_pref_file_.Append(chrome::kPreferencesFilename);
- } else {
- reference_pref_file = test_data_directory_
+ FilePath reference_pref_file =
+ test_data_directory_
.AppendASCII("profiles")
.AppendASCII("window_placement")
.Append(chrome::kLocalStateFilename);
- tmp_pref_file_ = tmp_profile_.Append(chrome::kLocalStateFilename);
- }
+
+ tmp_pref_file_ = tmp_profile_.Append(chrome::kLocalStateFilename);
ASSERT_TRUE(file_util::PathExists(reference_pref_file));
- // Copy only the Preferences file if |new_profile_|, or Local State if not,
- // and the rest will be automatically created.
+
+ // Copy only the Local State file, the rest will be automatically created
ASSERT_TRUE(file_util::CopyFile(reference_pref_file, tmp_pref_file_));
#if defined(OS_WIN)
@@ -76,21 +66,20 @@ class PreferenceServiceTest : public UITest {
}
public:
- bool new_profile_;
FilePath tmp_pref_file_;
FilePath tmp_profile_;
};
-#if !defined(OS_LINUX)
+#if defined(OS_WIN)
// This test verifies that the window position from the prefs file is restored
// when the app restores. This doesn't really make sense on Linux, where
// the window manager might fight with you over positioning. However, we
// might be able to make this work on buildbots.
+// Also, not sure what should happen on the mac. In any case, the code below
+// (minus the Windows bits) compiles fine on my Linux box now.
// TODO(port): revisit this.
TEST_F(PreferenceServiceTest, PreservedWindowPlacementIsLoaded) {
- // The window should open with the new reference profile, with window
- // placement values stored in the user data directory.
- new_profile_ = true;
+ // The window should open with the reference profile
ASSERT_TRUE(LaunchAppWithProfile());
ASSERT_TRUE(file_util::PathExists(tmp_pref_file_));
@@ -143,66 +132,3 @@ TEST_F(PreferenceServiceTest, PreservedWindowPlacementIsLoaded) {
EXPECT_EQ(is_maximized, is_window_maximized);
}
#endif
-
-#if !defined(OS_LINUX)
-TEST_F(PreferenceServiceTest, PreservedWindowPlacementIsMigrated) {
- // The window should open with the old reference profile, with window
- // placement values stored in Local State.
- new_profile_ = false;
- ASSERT_TRUE(LaunchAppWithProfile());
-
- ASSERT_TRUE(file_util::PathExists(tmp_pref_file_));
-
- JSONFileValueSerializer deserializer(tmp_pref_file_);
- scoped_ptr<Value> root(deserializer.Deserialize(NULL, NULL));
-
- ASSERT_TRUE(root.get());
- ASSERT_TRUE(root->IsType(Value::TYPE_DICTIONARY));
-
- // Retrieve the screen rect for the launched window
- scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0));
- ASSERT_TRUE(browser.get());
- scoped_refptr<WindowProxy> window(browser->GetWindow());
- ASSERT_TRUE(window.get());
-
- gfx::Rect bounds;
- ASSERT_TRUE(window->GetBounds(&bounds));
-
- // Values from old reference profile in Local State should have been
- // correctly migrated to the user's Preferences -- if so, the window
- // should be set to values taken from the user's Local State.
- DictionaryValue* root_dict = static_cast<DictionaryValue*>(root.get());
-
- // Retrieve the expected rect values from User Preferences, where they
- // should have been migrated from Local State.
- int bottom = 0;
- std::string kBrowserWindowPlacement(prefs::kBrowserWindowPlacement);
- EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + ".bottom",
- &bottom));
- EXPECT_EQ(bottom, bounds.y() + bounds.height());
-
- int top = 0;
- EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + ".top",
- &top));
- EXPECT_EQ(top, bounds.y());
-
- int left = 0;
- EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + ".left",
- &left));
- EXPECT_EQ(left, bounds.x());
-
- int right = 0;
- EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + ".right",
- &right));
- EXPECT_EQ(right, bounds.x() + bounds.width());
-
- // Find if launched window is maximized.
- bool is_window_maximized = false;
- ASSERT_TRUE(window->IsMaximized(&is_window_maximized));
- bool is_maximized = false;
- EXPECT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + ".maximized",
- &is_maximized));
- EXPECT_EQ(is_maximized, is_window_maximized);
-}
-#endif
-
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index cdb7091..3b540d1 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -667,11 +667,6 @@ PrefService* ProfileImpl::GetPrefs() {
// register known prefs as soon as possible.
Profile::RegisterUserPrefs(prefs_.get());
browser::RegisterUserPrefs(prefs_.get());
- // TODO(mirandac): remove migration code after 6 months (crbug.com/69995).
- if (g_browser_process->local_state()) {
- browser::MigrateBrowserPrefs(prefs_.get(),
- g_browser_process->local_state());
- }
// The last session exited cleanly if there is no pref for
// kSessionExitedCleanly or the value for kSessionExitedCleanly is true.
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 81fb6db..54f8677 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -543,7 +543,7 @@ TabContents* Browser::OpenApplicationWindow(
else
app_name = web_app::GenerateApplicationNameFromURL(url);
- RegisterAppPrefs(app_name, profile);
+ RegisterAppPrefs(app_name);
bool as_panel = extension && (container == extension_misc::LAUNCH_PANEL);
@@ -739,7 +739,7 @@ gfx::Rect Browser::GetSavedWindowBounds() const {
gfx::Rect restored_bounds = override_bounds_;
bool maximized;
- WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, this,
+ WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, NULL,
&restored_bounds, &maximized);
return restored_bounds;
}
@@ -758,7 +758,7 @@ bool Browser::GetSavedMaximizedState() const {
// An explicit maximized state was not set. Query the window sizer.
gfx::Rect restored_bounds;
bool maximized = false;
- WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, this,
+ WindowSizer::GetBrowserWindowBounds(app_name_, restored_bounds, NULL,
&restored_bounds, &maximized);
return maximized;
}
@@ -1974,10 +1974,11 @@ void Browser::SetNewHomePagePrefs(PrefService* prefs) {
// static
void Browser::RegisterPrefs(PrefService* prefs) {
+ prefs->RegisterDictionaryPref(prefs::kBrowserWindowPlacement);
prefs->RegisterIntegerPref(prefs::kOptionsWindowLastTabIndex, 0);
+ prefs->RegisterIntegerPref(prefs::kDevToolsSplitLocation, -1);
prefs->RegisterDictionaryPref(prefs::kPreferencesWindowPlacement);
prefs->RegisterIntegerPref(prefs::kExtensionSidebarWidth, -1);
- prefs->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0);
// Educated guess: Chrome has a bundled Flash version supporting
// clearing LSO data, Chromium hasn't.
#if defined(GOOGLE_CHROME_BUILD)
@@ -2025,8 +2026,7 @@ void Browser::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterStringPref(prefs::kCloudPrintEmail, std::string());
prefs->RegisterBooleanPref(prefs::kDevToolsDisabled, false);
prefs->RegisterRealPref(prefs::kDefaultZoomLevel, 0.0);
- prefs->RegisterIntegerPref(prefs::kDevToolsSplitLocation, -1);
- prefs->RegisterDictionaryPref(prefs::kBrowserWindowPlacement);
+ prefs->RegisterIntegerPref(prefs::kMultipleProfilePrefMigration, 0);
// We need to register the type of this preference in order to query
// it even though it's only typically controlled via policy.
prefs->RegisterBooleanPref(prefs::kDisable3DAPIs, false);
@@ -2964,7 +2964,7 @@ bool Browser::IsApplication() const {
void Browser::ConvertContentsToApplication(TabContents* contents) {
const GURL& url = contents->controller().GetActiveEntry()->url();
std::string app_name = web_app::GenerateApplicationNameFromURL(url);
- RegisterAppPrefs(app_name, contents->profile());
+ RegisterAppPrefs(app_name);
DetachContents(contents);
Browser* app_browser = Browser::CreateForApp(
@@ -4118,7 +4118,7 @@ void Browser::TabDetachedAtImpl(TabContentsWrapper* contents, int index,
}
// static
-void Browser::RegisterAppPrefs(const std::string& app_name, Profile* profile) {
+void Browser::RegisterAppPrefs(const std::string& app_name) {
// A set of apps that we've already started.
static std::set<std::string>* g_app_names = NULL;
@@ -4134,7 +4134,10 @@ void Browser::RegisterAppPrefs(const std::string& app_name, Profile* profile) {
std::string window_pref(prefs::kBrowserWindowPlacement);
window_pref.append("_");
window_pref.append(app_name);
- profile->GetPrefs()->RegisterDictionaryPref(window_pref.c_str());
+ PrefService* prefs = g_browser_process->local_state();
+ DCHECK(prefs);
+
+ prefs->RegisterDictionaryPref(window_pref.c_str());
}
void Browser::TabRestoreServiceChanged(TabRestoreService* service) {
diff --git a/chrome/browser/ui/browser.h b/chrome/browser/ui/browser.h
index 63f7d5c..a72e7e9 100644
--- a/chrome/browser/ui/browser.h
+++ b/chrome/browser/ui/browser.h
@@ -959,10 +959,9 @@ class Browser : public TabHandlerDelegate,
void TabDetachedAtImpl(TabContentsWrapper* contents,
int index, DetachType type);
- // Create a preference dictionary for the provided application name, in the
- // given user profile. This is done only once per application name / per
- // session / per user profile.
- static void RegisterAppPrefs(const std::string& app_name, Profile* profile);
+ // Create a preference dictionary for the provided application name. This is
+ // done only once per application name / per session.
+ static void RegisterAppPrefs(const std::string& app_name);
// Shared code between Reload() and ReloadIgnoringCache().
void ReloadInternal(WindowOpenDisposition disposition, bool ignore_cache);
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm
index 9ad91e5..d761f54 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -479,8 +479,7 @@
}
- (void)updateDevToolsForContents:(TabContents*)contents {
- [devToolsController_ updateDevToolsForTabContents:contents
- withProfile:browser_->profile()];
+ [devToolsController_ updateDevToolsForTabContents:contents];
[devToolsController_ ensureContentsVisible];
}
@@ -1429,8 +1428,7 @@
windowShim_->UpdateTitleBar();
[sidebarController_ updateSidebarForTabContents:contents];
- [devToolsController_ updateDevToolsForTabContents:contents
- withProfile:browser_->profile()];
+ [devToolsController_ updateDevToolsForTabContents:contents];
// Update the bookmark bar.
// Must do it after sidebar and devtools update, otherwise bookmark bar might
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
index 5898ba5..73c6e01 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -62,12 +62,11 @@ const CGFloat kLocBarBottomInset = 1;
if (browser_ != BrowserList::GetLastActive())
return;
- if (!browser_->profile()->GetPrefs() ||
- !browser_->ShouldSaveWindowPlacement()) {
+ if (!g_browser_process || !g_browser_process->local_state() ||
+ !browser_->ShouldSaveWindowPlacement())
return;
- }
- [self saveWindowPositionToPrefs:browser_->profile()->GetPrefs()];
+ [self saveWindowPositionToPrefs:g_browser_process->local_state()];
}
- (void)saveWindowPositionToPrefs:(PrefService*)prefs {
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
index 6fd75b4..4351532 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
@@ -88,7 +88,9 @@ TEST_F(BrowserWindowControllerTest, TestSaveWindowPosition) {
ASSERT_TRUE(prefs->GetDictionary(prefs::kBrowserWindowPlacement) == NULL);
// Ask the window to save its position, then check that a preference
- // exists.
+ // exists. We're technically passing in a pointer to the user prefs
+ // and not the local state prefs, but a PrefService* is a
+ // PrefService*, and this is a unittest.
[controller_ saveWindowPositionToPrefs:prefs];
EXPECT_TRUE(prefs->GetDictionary(prefs::kBrowserWindowPlacement) != NULL);
}
diff --git a/chrome/browser/ui/cocoa/dev_tools_controller.h b/chrome/browser/ui/cocoa/dev_tools_controller.h
index 4555b9a..c89a9f8 100644
--- a/chrome/browser/ui/cocoa/dev_tools_controller.h
+++ b/chrome/browser/ui/cocoa/dev_tools_controller.h
@@ -14,12 +14,11 @@
@class NSSplitView;
@class NSView;
-class Profile;
class TabContents;
// A class that handles updates of the devTools view within a browser window.
// It swaps in the relevant devTools contents for a given TabContents or removes
-// the view, if there's no devTools contents to show.
+// the vew, if there's no devTools contents to show.
@interface DevToolsController : NSObject {
@private
// A view hosting docked devTools contents.
@@ -41,8 +40,7 @@ class TabContents;
// Depending on |contents|'s state, decides whether the docked web inspector
// should be shown or hidden and adjusts its height (|delegate_| handles
// the actual resize).
-- (void)updateDevToolsForTabContents:(TabContents*)contents
- withProfile:(Profile*)profile;
+- (void)updateDevToolsForTabContents:(TabContents*)contents;
// Call when the devTools view is properly sized and the render widget host view
// should be put into the view hierarchy.
diff --git a/chrome/browser/ui/cocoa/dev_tools_controller.mm b/chrome/browser/ui/cocoa/dev_tools_controller.mm
index 617d773..4d29794 100644
--- a/chrome/browser/ui/cocoa/dev_tools_controller.mm
+++ b/chrome/browser/ui/cocoa/dev_tools_controller.mm
@@ -11,7 +11,6 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#import "chrome/browser/ui/cocoa/view_id_util.h"
#include "chrome/common/pref_names.h"
@@ -29,8 +28,7 @@ const int kMinWebHeight = 50;
@interface DevToolsController (Private)
-- (void)showDevToolsContents:(TabContents*)devToolsContents
- withProfile:(Profile*)profile;
+- (void)showDevToolsContents:(TabContents*)devToolsContents;
- (void)resizeDevToolsToNewHeight:(CGFloat)height;
@end
@@ -65,21 +63,19 @@ const int kMinWebHeight = 50;
return splitView_.get();
}
-- (void)updateDevToolsForTabContents:(TabContents*)contents
- withProfile:(Profile*)profile {
+- (void)updateDevToolsForTabContents:(TabContents*)contents {
// Get current devtools content.
TabContents* devToolsContents = contents ?
DevToolsWindow::GetDevToolsContents(contents) : NULL;
- [self showDevToolsContents:devToolsContents withProfile:profile];
+ [self showDevToolsContents:devToolsContents];
}
- (void)ensureContentsVisible {
[contentsController_ ensureContentsVisible];
}
-- (void)showDevToolsContents:(TabContents*)devToolsContents
- withProfile:(Profile*)profile {
+- (void)showDevToolsContents:(TabContents*)devToolsContents {
[contentsController_ ensureContentsSizeDoesNotChange];
NSArray* subviews = [splitView_ subviews];
@@ -95,8 +91,8 @@ const int kMinWebHeight = 50;
CGFloat splitOffset = 0;
if ([subviews count] == 1) {
// Load the default split offset.
- splitOffset = profile->GetPrefs()->
- GetInteger(prefs::kDevToolsSplitLocation);
+ splitOffset = g_browser_process->local_state()->GetInteger(
+ prefs::kDevToolsSplitLocation);
if (splitOffset < 0) {
// Initial load, set to default value.
splitOffset = kDefaultContentsSplitOffset;
@@ -121,8 +117,7 @@ const int kMinWebHeight = 50;
NSView* oldDevToolsContentsView = [subviews objectAtIndex:1];
// Store split offset when hiding devtools window only.
int splitOffset = NSHeight([oldDevToolsContentsView frame]);
-
- profile->GetPrefs()->SetInteger(
+ g_browser_process->local_state()->SetInteger(
prefs::kDevToolsSplitLocation, splitOffset);
[oldDevToolsContentsView removeFromSuperview];
[splitView_ adjustSubviews];
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index a4b5c0b..6b18b39 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -1273,8 +1273,8 @@ void BrowserWindowGtk::UpdateDevToolsForContents(TabContents* contents) {
} else if (should_hide) {
// Store split offset when hiding devtools window only.
gint divider_offset = gtk_paned_get_position(GTK_PANED(contents_split_));
- browser_->profile()->GetPrefs()->
- SetInteger(prefs::kDevToolsSplitLocation, divider_offset);
+ g_browser_process->local_state()->SetInteger(
+ prefs::kDevToolsSplitLocation, divider_offset);
gtk_widget_hide(devtools_container_->widget());
}
}
@@ -1597,8 +1597,8 @@ void BrowserWindowGtk::InitWidgets() {
FALSE, TRUE);
gtk_box_pack_end(GTK_BOX(render_area_vbox_), contents_split_, TRUE, TRUE, 0);
// Restore split offset.
- int split_offset = browser_->profile()->GetPrefs()->
- GetInteger(prefs::kDevToolsSplitLocation);
+ int split_offset = g_browser_process->local_state()->GetInteger(
+ prefs::kDevToolsSplitLocation);
if (split_offset != -1) {
if (split_offset < kMinDevToolsHeight)
split_offset = kMinDevToolsHeight;
@@ -1758,13 +1758,13 @@ void BrowserWindowGtk::SaveWindowPosition() {
// We also need to save the placement for startup.
// This is a web of calls between views and delegates on Windows, but the
// crux of the logic follows. See also cocoa/browser_window_controller.mm.
- if (!browser_->profile()->GetPrefs())
+ if (!g_browser_process->local_state())
return;
std::string window_name = browser_->GetWindowPlacementKey();
DictionaryValue* window_preferences =
- browser_->profile()->GetPrefs()->
- GetMutableDictionary(window_name.c_str());
+ g_browser_process->local_state()->GetMutableDictionary(
+ window_name.c_str());
// Note that we store left/top for consistency with Windows, but that we
// *don't* obey them; we only use them for computing width/height. See
// comments in SetGeometryHints().
diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc
index 8f3cd43..86faf4c 100644
--- a/chrome/browser/ui/views/chrome_views_delegate.cc
+++ b/chrome/browser/ui/views/chrome_views_delegate.cc
@@ -8,7 +8,6 @@
#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"
@@ -28,12 +27,12 @@ ui::Clipboard* ChromeViewsDelegate::GetClipboard() const {
void ChromeViewsDelegate::SaveWindowPlacement(const std::wstring& window_name,
const gfx::Rect& bounds,
bool maximized) {
- if (!g_browser_process->profile_manager())
+ if (!g_browser_process->local_state())
return;
DictionaryValue* window_preferences =
- g_browser_process->profile_manager()->GetDefaultProfile()->GetPrefs()->
- GetMutableDictionary(WideToUTF8(window_name).c_str());
+ g_browser_process->local_state()->GetMutableDictionary(
+ WideToUTF8(window_name).c_str());
window_preferences->SetInteger("left", bounds.x());
window_preferences->SetInteger("top", bounds.y());
window_preferences->SetInteger("right", bounds.right());
@@ -52,12 +51,12 @@ void ChromeViewsDelegate::SaveWindowPlacement(const std::wstring& window_name,
bool ChromeViewsDelegate::GetSavedWindowBounds(const std::wstring& window_name,
gfx::Rect* bounds) const {
- if (!g_browser_process->profile_manager())
+ if (!g_browser_process->local_state())
return false;
const DictionaryValue* dictionary =
- g_browser_process->profile_manager()->GetDefaultProfile()->GetPrefs()->
- GetDictionary(WideToUTF8(window_name).c_str());
+ g_browser_process->local_state()->GetDictionary(
+ WideToUTF8(window_name).c_str());
int left, top, right, bottom;
if (!dictionary || !dictionary->GetInteger("left", &left) ||
!dictionary->GetInteger("top", &top) ||
@@ -72,13 +71,12 @@ bool ChromeViewsDelegate::GetSavedWindowBounds(const std::wstring& window_name,
bool ChromeViewsDelegate::GetSavedMaximizedState(
const std::wstring& window_name,
bool* maximized) const {
- if (!g_browser_process->profile_manager())
+ if (!g_browser_process->local_state())
return false;
const DictionaryValue* dictionary =
- g_browser_process->profile_manager()->GetDefaultProfile()->GetPrefs()->
- GetDictionary(WideToUTF8(window_name).c_str());
-
+ g_browser_process->local_state()->GetDictionary(
+ WideToUTF8(window_name).c_str());
return dictionary && dictionary->GetBoolean("maximized", maximized) &&
maximized;
}
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index b09fccb2..1637c7a 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -2102,8 +2102,8 @@ void BrowserView::UpdateDevToolsForContents(TabContentsWrapper* wrapper) {
}
// Restore split offset.
- int split_offset = browser_->profile()->GetPrefs()->
- GetInteger(prefs::kDevToolsSplitLocation);
+ int split_offset = g_browser_process->local_state()->GetInteger(
+ prefs::kDevToolsSplitLocation);
if (split_offset == -1) {
// Initial load, set to default value.
split_offset = 2 * contents_split_->height() / 3;
@@ -2119,8 +2119,8 @@ void BrowserView::UpdateDevToolsForContents(TabContentsWrapper* wrapper) {
Layout();
} else if (should_hide) {
// Store split offset when hiding devtools window only.
- browser_->profile()->GetPrefs()->SetInteger(prefs::kDevToolsSplitLocation,
- contents_split_->divider_offset());
+ g_browser_process->local_state()->SetInteger(
+ prefs::kDevToolsSplitLocation, contents_split_->divider_offset());
// Restore focus to the last focused view when hiding devtools window.
devtools_focus_tracker_->FocusLastFocusedExternalView();
diff --git a/chrome/browser/ui/window_sizer.cc b/chrome/browser/ui/window_sizer.cc
index e1dd834..292f5fc 100644
--- a/chrome/browser/ui/window_sizer.cc
+++ b/chrome/browser/ui/window_sizer.cc
@@ -6,7 +6,6 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
@@ -17,9 +16,9 @@
// and persistent state from the browser window and the user's profile.
class DefaultStateProvider : public WindowSizer::StateProvider {
public:
- explicit DefaultStateProvider(const std::string& app_name,
- const Browser* browser) : app_name_(app_name),
- browser_(browser) {
+ explicit DefaultStateProvider(const std::string& app_name, Browser* browser)
+ : app_name_(app_name),
+ browser_(browser) {
}
// Overridden from WindowSizer::StateProvider:
@@ -34,11 +33,11 @@ class DefaultStateProvider : public WindowSizer::StateProvider {
key.append(app_name_);
}
- if (!browser_->profile()->GetPrefs())
+ if (!g_browser_process->local_state())
return false;
const DictionaryValue* wp_pref =
- browser_->profile()->GetPrefs()->GetDictionary(key.c_str());
+ g_browser_process->local_state()->GetDictionary(key.c_str());
int top = 0, left = 0, bottom = 0, right = 0;
bool has_prefs =
wp_pref &&
@@ -75,9 +74,9 @@ class DefaultStateProvider : public WindowSizer::StateProvider {
// If a reference browser is set, use its window. Otherwise find last
// active.
BrowserWindow* window = NULL;
- // Window may be null if browser is just starting up.
- if (browser_ && browser_->window()) {
+ if (browser_) {
window = browser_->window();
+ DCHECK(window);
} else {
BrowserList::const_reverse_iterator it = BrowserList::begin_last_active();
BrowserList::const_reverse_iterator end = BrowserList::end_last_active();
@@ -103,7 +102,7 @@ class DefaultStateProvider : public WindowSizer::StateProvider {
std::string app_name_;
// If set, is used as the reference browser for GetLastActiveWindowState.
- const Browser* browser_;
+ Browser* browser_;
DISALLOW_COPY_AND_ASSIGN(DefaultStateProvider);
};
@@ -133,7 +132,7 @@ WindowSizer::~WindowSizer() {
// static
void WindowSizer::GetBrowserWindowBounds(const std::string& app_name,
const gfx::Rect& specified_bounds,
- const Browser* browser,
+ Browser* browser,
gfx::Rect* window_bounds,
bool* maximized) {
const WindowSizer sizer(new DefaultStateProvider(app_name, browser),
diff --git a/chrome/browser/ui/window_sizer.h b/chrome/browser/ui/window_sizer.h
index a943f43..7d34399 100644
--- a/chrome/browser/ui/window_sizer.h
+++ b/chrome/browser/ui/window_sizer.h
@@ -121,7 +121,7 @@ class WindowSizer {
// non-NULL value for |browser|.
static void GetBrowserWindowBounds(const std::string& app_name,
const gfx::Rect& specified_bounds,
- const Browser* browser,
+ Browser* browser,
gfx::Rect* window_bounds,
bool* maximized);
@@ -181,5 +181,4 @@ class WindowSizer {
DISALLOW_COPY_AND_ASSIGN(WindowSizer);
};
-#endif // CHROME_BROWSER_UI_WINDOW_SIZER_H_
-
+#endif // CHROME_BROWSER_WINDOW_SIZER_H_
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 22f533c..d53f112 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -252,13 +252,11 @@ const char kInstantPromo[] = "instant.promo";
// Used to migrate preferences from local state to user preferences to
// enable multiple profiles.
-// BITMASK with possible values (see browser_prefs.cc for enum):
-// 0: No preferences migrated.
-// 1: DNS preferences migrated: kDnsPrefetchingStartupList and HostReferralList
-// 2: Browser window preferences migrated: kDevToolsSplitLocation and
-// kBrowserWindowPlacement
+// Holds possible values:
+// 0: no preferences migrated yet.
+// 1: dns prefetching preferences stored in user preferences.
const char kMultipleProfilePrefMigration[] =
- "local_state.multiple_profile_prefs_version";
+ "profile.multiple_profile_prefs_version";
#if defined(USE_NSS) || defined(USE_OPENSSL)
// Prefs for SSLConfigServicePref. Currently, these are only present on
diff --git a/chrome/test/data/profiles/window_placement/Default/Preferences b/chrome/test/data/profiles/window_placement/Default/Preferences
deleted file mode 100644
index 5a87bcd..0000000
--- a/chrome/test/data/profiles/window_placement/Default/Preferences
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "browser" : {
- "window_placement" : {
- "bottom" : 400,
- "left" : 50,
- "maximized" : false,
- "right" : 450,
- "top" : 50
- }
- }
-}
-