summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
authorbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-25 14:25:33 +0000
committerbattre@chromium.org <battre@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-25 14:25:33 +0000
commit9a8c4020cf135d7a9073cf22a69427f1259c5ed5 (patch)
treea4125b4f356d75cdea03dab1a07f3ae14e579e89 /chrome/browser/ui
parent31a3130fedb27670365b40bc8cb6dc875957531f (diff)
downloadchromium_src-9a8c4020cf135d7a9073cf22a69427f1259c5ed5.zip
chromium_src-9a8c4020cf135d7a9073cf22a69427f1259c5ed5.tar.gz
chromium_src-9a8c4020cf135d7a9073cf22a69427f1259c5ed5.tar.bz2
Introduce incognito preference settings.
This CL introduces preference settings for incognito windows. The semantics are the following: - An extension can set regular preferences as before. These affect regular and incognito windows. - An extension can set regular preferences *and* incognito preferences. In this case, the incognito preferences affect only incognito windows. - If extension A sets reg+incognito, extension B sets reg but no incognito, extension B has higher precedence than A --> B's preferences hold for all regular and incognito windows. - Incognito preferences are never persisted to disk. In order to realize this, the ExtensionPrefs class allows setting regular and incognito extension controlled preferences. It allows creating an incognito version of the PrefService with an independent PrefValueStore. This (incognito) PrefValueStore and the original PrefValueStore share several of their PrefStores (i.e. DefaultPrefStore, CommandLinePrefStore, Configuration PrefStores) but differ in two pref stores: - We maintain two separate ExtensionPrefStores containing the effective preferences for regular and incognito windows. - We maintain two separate user pref stores. The regular JsonPrefStore is expanded by an OverlayPersistentPrefStore that maintains all write-operations in an in-memory overlay. Therefore, incognito changes are not visible in the file-backed JsonPrefStore. The two ExtensionPrefStores retrieve their effective values from a shared ExtensionPrefValueMap. The OffTheRecordProfileImpl provides a request_context_ that uses the new PrefService already. BUG=66027,69057 TEST=unit tests, will be fully testable once the Proxy Settings API allows incognito settings. Review URL: http://codereview.chromium.org/5915004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72489 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/browser.cc6
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller_unittest.mm12
-rw-r--r--chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h9
-rw-r--r--chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm37
-rw-r--r--chrome/browser/ui/cocoa/extensions/extension_popup_controller_unittest.mm9
-rw-r--r--chrome/browser/ui/cocoa/window_size_autosaver_unittest.mm10
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc3
7 files changed, 76 insertions, 10 deletions
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index 7352f92..b6aa9fc 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -285,6 +285,12 @@ Browser::~Browser() {
if (tab_restore_service)
tab_restore_service->BrowserClosed(this);
+ encoding_auto_detect_.Destroy();
+ printing_enabled_.Destroy();
+ dev_tools_disabled_.Destroy();
+ instant_enabled_.Destroy();
+ use_vertical_tabs_.Destroy();
+
if (profile_->IsOffTheRecord() &&
!BrowserList::IsOffTheRecordSessionActive()) {
// An off-the-record profile is no longer needed, this indirectly
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
index e0a9edd..497967b 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -85,14 +85,20 @@ TEST_F(BrowserWindowControllerTest, TestSaveWindowPosition) {
ASSERT_TRUE(prefs != NULL);
// Check to make sure there is no existing pref for window placement.
- ASSERT_TRUE(prefs->GetDictionary(prefs::kBrowserWindowPlacement) == NULL);
+ const DictionaryValue* browser_window_placement =
+ prefs->GetDictionary(prefs::kBrowserWindowPlacement);
+ ASSERT_TRUE(browser_window_placement);
+ EXPECT_TRUE(browser_window_placement->empty());
// Ask the window to save its position, then check that a preference
// 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);
+ browser_window_placement =
+ prefs->GetDictionary(prefs::kBrowserWindowPlacement);
+ ASSERT_TRUE(browser_window_placement);
+ EXPECT_FALSE(browser_window_placement->empty());
}
TEST_F(BrowserWindowControllerTest, TestFullScreenWindow) {
diff --git a/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h b/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h
index e40388f..9af03e1 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h
+++ b/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h
@@ -21,6 +21,7 @@ class Profile;
namespace extension_action_context_menu {
class DevmodeObserver;
+class ProfileObserverBridge;
} // namespace extension_action_context_menu
@@ -42,6 +43,10 @@ class DevmodeObserver;
// The observer used to listen for pref changed notifications.
scoped_ptr<extension_action_context_menu::DevmodeObserver> observer_;
+ // The observer used to reset |observer_| when the profile is destroyed.
+ scoped_ptr<extension_action_context_menu::ProfileObserverBridge>
+ profile_observer_;
+
// Used to load the extension icon asynchronously on the I/O thread then show
// the uninstall confirmation dialog.
scoped_ptr<AsyncUninstaller> uninstaller_;
@@ -55,6 +60,10 @@ class DevmodeObserver;
// Show or hide the inspector menu item.
- (void)updateInspectorItem;
+// Notifies the ExtensionActionContextMenu that the profile is is being
+// destroyed.
+- (void)invalidateProfile;
+
@end
typedef ExtensionActionContextMenu ExtensionActionContextMenuMac;
diff --git a/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm b/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm
index 705276e..b8475ea 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm
+++ b/chrome/browser/ui/cocoa/extensions/extension_action_context_menu.mm
@@ -25,6 +25,7 @@
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/notification_details.h"
#include "chrome/common/notification_observer.h"
+#include "chrome/common/notification_source.h"
#include "chrome/common/notification_type.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
@@ -92,6 +93,34 @@ class DevmodeObserver : public NotificationObserver {
PrefChangeRegistrar registrar_;
};
+class ProfileObserverBridge : public NotificationObserver {
+ public:
+ ProfileObserverBridge(ExtensionActionContextMenu* owner,
+ const Profile* profile)
+ : owner_(owner),
+ profile_(profile) {
+ registrar_.Add(this, NotificationType::PROFILE_DESTROYED,
+ Source<Profile>(profile));
+ }
+
+ ~ProfileObserverBridge() {}
+
+ // Overridden from NotificationObserver
+ void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ if (type == NotificationType::PROFILE_DESTROYED &&
+ source == Source<Profile>(profile_)) {
+ [owner_ invalidateProfile];
+ }
+ }
+
+ private:
+ ExtensionActionContextMenu* owner_;
+ const Profile* profile_;
+ NotificationRegistrar registrar_;
+};
+
} // namespace extension_action_context_menu
@interface ExtensionActionContextMenu(Private)
@@ -177,6 +206,9 @@ int CurrentTabId() {
PrefService* service = profile_->GetPrefs();
observer_.reset(
new extension_action_context_menu::DevmodeObserver(self, service));
+ profile_observer_.reset(
+ new extension_action_context_menu::ProfileObserverBridge(self,
+ profile));
[self updateInspectorItem];
return self;
@@ -275,4 +307,9 @@ int CurrentTabId() {
return YES;
}
+- (void)invalidateProfile {
+ observer_.reset();
+ profile_ = NULL;
+}
+
@end
diff --git a/chrome/browser/ui/cocoa/extensions/extension_popup_controller_unittest.mm b/chrome/browser/ui/cocoa/extensions/extension_popup_controller_unittest.mm
index 992dd2c..a0b5614 100644
--- a/chrome/browser/ui/cocoa/extensions/extension_popup_controller_unittest.mm
+++ b/chrome/browser/ui/cocoa/extensions/extension_popup_controller_unittest.mm
@@ -1,10 +1,10 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
#include "base/message_loop.h"
#include "base/scoped_nsobject.h"
-#include "chrome/browser/extensions/extension_pref_store.h"
+#include "chrome/browser/extensions/extension_pref_value_map.h"
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -28,10 +28,10 @@ class ExtensionTestingProfile : public TestingProfile {
DCHECK(!GetExtensionService());
manager_.reset(ExtensionProcessManager::Create(this));
- ExtensionPrefStore* pref_store = new ExtensionPrefStore;
+ extension_pref_value_map_.reset(new ExtensionPrefValueMap);
extension_prefs_.reset(new ExtensionPrefs(GetPrefs(),
GetExtensionsInstallDir(),
- pref_store));
+ extension_pref_value_map_.get()));
service_ = new ExtensionService(this,
CommandLine::ForCurrentProcess(),
GetExtensionsInstallDir(),
@@ -61,6 +61,7 @@ class ExtensionTestingProfile : public TestingProfile {
scoped_ptr<ExtensionProcessManager> manager_;
scoped_ptr<ExtensionPrefs> extension_prefs_;
scoped_refptr<ExtensionService> service_;
+ scoped_ptr<ExtensionPrefValueMap> extension_pref_value_map_;
DISALLOW_COPY_AND_ASSIGN(ExtensionTestingProfile);
};
diff --git a/chrome/browser/ui/cocoa/window_size_autosaver_unittest.mm b/chrome/browser/ui/cocoa/window_size_autosaver_unittest.mm
index c3b33ed..3b95440 100644
--- a/chrome/browser/ui/cocoa/window_size_autosaver_unittest.mm
+++ b/chrome/browser/ui/cocoa/window_size_autosaver_unittest.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -44,7 +44,9 @@ TEST_F(WindowSizeAutosaverTest, RestoresAndSavesPos) {
ASSERT_TRUE(pref != NULL);
// Check to make sure there is no existing pref for window placement.
- ASSERT_TRUE(pref->GetDictionary(path_) == NULL);
+ const DictionaryValue* placement = pref->GetDictionary(path_);
+ ASSERT_TRUE(placement);
+ EXPECT_TRUE(placement->empty());
// Replace the window with one that doesn't have resize controls.
[window_ close];
@@ -109,7 +111,9 @@ TEST_F(WindowSizeAutosaverTest, RestoresAndSavesRect) {
ASSERT_TRUE(pref != NULL);
// Check to make sure there is no existing pref for window placement.
- ASSERT_TRUE(pref->GetDictionary(path_) == NULL);
+ const DictionaryValue* placement = pref->GetDictionary(path_);
+ ASSERT_TRUE(placement);
+ EXPECT_TRUE(placement->empty());
// Ask the window to save its position, then check that a preference
// exists. We're technically passing in a pointer to the user prefs
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 484295b..06e23d4 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -480,6 +480,9 @@ BrowserView::~BrowserView() {
delete tabstrip_;
tabstrip_ = NULL;
+ // Child views maintain PrefMember attributes that point to
+ // OffTheRecordProfile's PrefService which gets deleted by ~Browser.
+ RemoveAllChildViews(true);
// Explicitly set browser_ to NULL.
browser_.reset();
}