diff options
author | laforge@chromium.org <laforge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-24 05:11:15 +0000 |
---|---|---|
committer | laforge@chromium.org <laforge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-24 05:11:15 +0000 |
commit | 96fe47aa1e089d08f628f5f1c709b2f944138de9 (patch) | |
tree | d9467f3592d4e2fabad33ccdc1e7b8e4860f0c0a | |
parent | 72af2d77ef52d17802ff7aff7a5ff08bcda375e8 (diff) | |
download | chromium_src-96fe47aa1e089d08f628f5f1c709b2f944138de9.zip chromium_src-96fe47aa1e089d08f628f5f1c709b2f944138de9.tar.gz chromium_src-96fe47aa1e089d08f628f5f1c709b2f944138de9.tar.bz2 |
Revert 60413 - Revert 60057 - Merge 59915 - 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
TBR=jochen@chromium.org
Review URL: http://codereview.chromium.org/3450018
TBR=jochen@chromium.org
Review URL: http://codereview.chromium.org/3455021
TBR=laforge@chromium.org
git-svn-id: svn://svn.chromium.org/chrome/branches/517/src@60423 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/content_exceptions_table_model.h | 5 | ||||
-rw-r--r-- | chrome/browser/content_exceptions_table_model_unittest.cc | 34 | ||||
-rw-r--r-- | chrome/browser/host_content_settings_map.cc | 4 | ||||
-rw-r--r-- | chrome/browser/host_content_settings_map.h | 3 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 1 |
5 files changed, 38 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 b44485d..3aa86a3 100644 --- a/chrome/browser/host_content_settings_map.cc +++ b/chrome/browser/host_content_settings_map.cc @@ -706,10 +706,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 0bf8044..c44c55c 100644 --- a/chrome/browser/host_content_settings_map.h +++ b/chrome/browser/host_content_settings_map.h @@ -224,9 +224,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, diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index da27477..d154bd6 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1040,6 +1040,7 @@ 'browser/cocoa/wrench_menu_button_cell_unittest.mm', 'browser/cocoa/wrench_menu_controller_unittest.mm', 'browser/command_updater_unittest.cc', + 'browser/content_exceptions_table_model_unittest.cc', 'browser/cookies_tree_model_unittest.cc', 'browser/debugger/devtools_manager_unittest.cc', 'browser/device_orientation/provider_unittest.cc', |