summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-20 08:47:37 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-20 08:47:37 +0000
commit916b78c371bdc95769d001c192ab6016cc0ae6c4 (patch)
treee68bfdeec237056176ca257bf7244d5eecba5bf6 /chrome/browser
parent6849fd9c1d7296744df5a10a03060138f104c3db (diff)
downloadchromium_src-916b78c371bdc95769d001c192ab6016cc0ae6c4.zip
chromium_src-916b78c371bdc95769d001c192ab6016cc0ae6c4.tar.gz
chromium_src-916b78c371bdc95769d001c192ab6016cc0ae6c4.tar.bz2
Refcount the host content settings map from the content exceptions table model.
Otherwise, we run into a problem when the incognito profile goes away while the user is editing exceptions. BUG=51959 TEST=ContentExceptionsTableModelTest.* Review URL: http://codereview.chromium.org/3446013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59915 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/content_exceptions_table_model.h5
-rw-r--r--chrome/browser/content_exceptions_table_model_unittest.cc34
-rw-r--r--chrome/browser/host_content_settings_map.cc4
-rw-r--r--chrome/browser/host_content_settings_map.h3
4 files changed, 37 insertions, 9 deletions
diff --git a/chrome/browser/content_exceptions_table_model.h b/chrome/browser/content_exceptions_table_model.h
index f30633f..8e29591 100644
--- a/chrome/browser/content_exceptions_table_model.h
+++ b/chrome/browser/content_exceptions_table_model.h
@@ -9,6 +9,7 @@
#include <string>
#include "app/table_model.h"
+#include "base/ref_counted.h"
#include "chrome/common/content_settings.h"
#include "chrome/common/content_settings_types.h"
#include "chrome/browser/host_content_settings_map.h"
@@ -63,8 +64,8 @@ class ContentExceptionsTableModel : public TableModel {
return is_off_the_record ? off_the_record_entries_ : entries_;
}
- HostContentSettingsMap* map_;
- HostContentSettingsMap* off_the_record_map_;
+ scoped_refptr<HostContentSettingsMap> map_;
+ scoped_refptr<HostContentSettingsMap> off_the_record_map_;
ContentSettingsType content_type_;
HostContentSettingsMap::SettingsForOneType entries_;
HostContentSettingsMap::SettingsForOneType off_the_record_entries_;
diff --git a/chrome/browser/content_exceptions_table_model_unittest.cc b/chrome/browser/content_exceptions_table_model_unittest.cc
new file mode 100644
index 0000000..646ab9e
--- /dev/null
+++ b/chrome/browser/content_exceptions_table_model_unittest.cc
@@ -0,0 +1,34 @@
+// 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.
+
+#include "chrome/browser/content_exceptions_table_model.h"
+
+#include "chrome/test/testing_profile.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+class ContentExceptionsTableModelTest : public testing::Test {
+ public:
+ ContentExceptionsTableModelTest()
+ : ui_thread_(ChromeThread::UI, &message_loop_) {}
+
+ protected:
+ MessageLoop message_loop_;
+ ChromeThread ui_thread_;
+};
+
+TEST_F(ContentExceptionsTableModelTest, Incognito) {
+ TestingProfile profile;
+ TestingProfile* otr_profile = new TestingProfile();
+ otr_profile->set_off_the_record(true);
+ ContentExceptionsTableModel model(profile.GetHostContentSettingsMap(),
+ otr_profile->GetHostContentSettingsMap(),
+ CONTENT_SETTINGS_TYPE_COOKIES);
+ delete otr_profile;
+ model.AddException(HostContentSettingsMap::Pattern("example.com"),
+ CONTENT_SETTING_BLOCK, true);
+}
+
+} // namespace
diff --git a/chrome/browser/host_content_settings_map.cc b/chrome/browser/host_content_settings_map.cc
index e5c8bc4..cffe57e 100644
--- a/chrome/browser/host_content_settings_map.cc
+++ b/chrome/browser/host_content_settings_map.cc
@@ -741,10 +741,6 @@ void HostContentSettingsMap::ResetToDefaults() {
}
}
-bool HostContentSettingsMap::IsOffTheRecord() {
- return profile_->IsOffTheRecord();
-}
-
void HostContentSettingsMap::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
diff --git a/chrome/browser/host_content_settings_map.h b/chrome/browser/host_content_settings_map.h
index 2be7e23..ff9c8f0 100644
--- a/chrome/browser/host_content_settings_map.h
+++ b/chrome/browser/host_content_settings_map.h
@@ -230,9 +230,6 @@ class HostContentSettingsMap
// This should only be called on the UI thread.
void ResetToDefaults();
- // Whether this settings map is associated with an OTR session.
- bool IsOffTheRecord();
-
// NotificationObserver implementation.
virtual void Observe(NotificationType type,
const NotificationSource& source,