diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-28 09:23:16 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-28 09:23:16 +0000 |
commit | 4e0b2f346a77e78d0511644a0f749aabb3252c33 (patch) | |
tree | 7b060aca9f399daefbc462d5ad79d846846e667f | |
parent | 3b84e912304a48d9d0a6b51590c9e714fc65dfe8 (diff) | |
download | chromium_src-4e0b2f346a77e78d0511644a0f749aabb3252c33.zip chromium_src-4e0b2f346a77e78d0511644a0f749aabb3252c33.tar.gz chromium_src-4e0b2f346a77e78d0511644a0f749aabb3252c33.tar.bz2 |
Remove dead code (ContentExceptionsTableModel)
BUG=77547
TEST=None
Review URL: http://codereview.chromium.org/6753001
Patch from Vipul Bhasin <vipul.bhasin@gmail.com>.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79535 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/content_exceptions_table_model.cc | 135 | ||||
-rw-r--r-- | chrome/browser/content_exceptions_table_model.h | 79 | ||||
-rw-r--r-- | chrome/browser/content_exceptions_table_model_unittest.cc | 35 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 1 |
5 files changed, 0 insertions, 252 deletions
diff --git a/chrome/browser/content_exceptions_table_model.cc b/chrome/browser/content_exceptions_table_model.cc deleted file mode 100644 index 8383c2f..0000000 --- a/chrome/browser/content_exceptions_table_model.cc +++ /dev/null @@ -1,135 +0,0 @@ -// 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 "base/utf_string_conversions.h" -#include "chrome/browser/content_settings/host_content_settings_map.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/models/table_model_observer.h" - -ContentExceptionsTableModel::ContentExceptionsTableModel( - HostContentSettingsMap* map, - HostContentSettingsMap* off_the_record_map, - ContentSettingsType type) - : map_(map), - off_the_record_map_(off_the_record_map), - content_type_(type), - observer_(NULL) { - // Load the contents. - map->GetSettingsForOneType(type, "", &entries_); - if (off_the_record_map) { - off_the_record_map->GetSettingsForOneType(type, - "", - &off_the_record_entries_); - } -} - -ContentExceptionsTableModel::~ContentExceptionsTableModel() {} - -void ContentExceptionsTableModel::AddException( - const ContentSettingsPattern& original_pattern, - ContentSetting setting, - bool is_off_the_record) { - DCHECK(!is_off_the_record || off_the_record_map_); - - int insert_position = - is_off_the_record ? RowCount() : static_cast<int>(entries_.size()); - - const ContentSettingsPattern pattern( - original_pattern.CanonicalizePattern()); - - entries(is_off_the_record).push_back( - HostContentSettingsMap::PatternSettingPair(pattern, setting)); - map(is_off_the_record)->SetContentSetting(pattern, - content_type_, - "", - setting); - if (observer_) - observer_->OnItemsAdded(insert_position, 1); -} - -void ContentExceptionsTableModel::RemoveException(int row) { - bool is_off_the_record = entry_is_off_the_record(row); - int position_to_delete = - is_off_the_record ? row - static_cast<int>(entries_.size()) : row; - const HostContentSettingsMap::PatternSettingPair& pair = entry_at(row); - - map(is_off_the_record)->SetContentSetting( - pair.first, content_type_, "", CONTENT_SETTING_DEFAULT); - entries(is_off_the_record).erase( - entries(is_off_the_record).begin() + position_to_delete); - if (observer_) - observer_->OnItemsRemoved(row, 1); -} - -void ContentExceptionsTableModel::RemoveAll() { - int old_row_count = RowCount(); - entries_.clear(); - off_the_record_entries_.clear(); - map_->ClearSettingsForOneType(content_type_); - if (off_the_record_map_) - off_the_record_map_->ClearSettingsForOneType(content_type_); - if (observer_) - observer_->OnItemsRemoved(0, old_row_count); -} - -int ContentExceptionsTableModel::IndexOfExceptionByPattern( - const ContentSettingsPattern& original_pattern, - bool is_off_the_record) { - DCHECK(!is_off_the_record || off_the_record_map_); - - int offset = - is_off_the_record ? static_cast<int>(entries_.size()) : 0; - - const ContentSettingsPattern pattern( - original_pattern.CanonicalizePattern()); - - // This is called on every key type in the editor. Move to a map if we end up - // with lots of exceptions. - for (size_t i = 0; i < entries(is_off_the_record).size(); ++i) { - if (entries(is_off_the_record)[i].first == pattern) - return offset + static_cast<int>(i); - } - return -1; -} - -int ContentExceptionsTableModel::RowCount() { - return static_cast<int>(entries_.size() + off_the_record_entries_.size()); -} - -string16 ContentExceptionsTableModel::GetText(int row, int column_id) { - HostContentSettingsMap::PatternSettingPair entry = entry_at(row); - - switch (column_id) { - case IDS_EXCEPTIONS_PATTERN_HEADER: - return UTF8ToUTF16(entry.first.AsString()); - - case IDS_EXCEPTIONS_ACTION_HEADER: - switch (entry.second) { - case CONTENT_SETTING_ALLOW: - return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON); - case CONTENT_SETTING_BLOCK: - return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON); - case CONTENT_SETTING_ASK: - return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ASK_BUTTON); - case CONTENT_SETTING_SESSION_ONLY: - return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_SESSION_ONLY_BUTTON); - default: - NOTREACHED(); - } - break; - - default: - NOTREACHED(); - } - - return string16(); -} - -void ContentExceptionsTableModel::SetObserver( - ui::TableModelObserver* observer) { - observer_ = observer; -} diff --git a/chrome/browser/content_exceptions_table_model.h b/chrome/browser/content_exceptions_table_model.h deleted file mode 100644 index 2620209..0000000 --- a/chrome/browser/content_exceptions_table_model.h +++ /dev/null @@ -1,79 +0,0 @@ -// 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. - -#ifndef CHROME_BROWSER_CONTENT_EXCEPTIONS_TABLE_MODEL_H_ -#define CHROME_BROWSER_CONTENT_EXCEPTIONS_TABLE_MODEL_H_ -#pragma once - -#include <string> - -#include "base/compiler_specific.h" -#include "base/memory/ref_counted.h" -#include "chrome/common/content_settings.h" -#include "chrome/common/content_settings_types.h" -#include "chrome/browser/content_settings/host_content_settings_map.h" -#include "ui/base/models/table_model.h" - -class ContentExceptionsTableModel : public ui::TableModel { - public: - ContentExceptionsTableModel(HostContentSettingsMap* map, - HostContentSettingsMap* off_the_record_map, - ContentSettingsType content_type); - virtual ~ContentExceptionsTableModel(); - - HostContentSettingsMap* map() const { return map_; } - HostContentSettingsMap* off_the_record_map() const { - return off_the_record_map_; - } - ContentSettingsType content_type() const { return content_type_; } - - bool entry_is_off_the_record(int index) { - return index >= static_cast<int>(entries_.size()); - } - - const HostContentSettingsMap::PatternSettingPair& entry_at(int index) { - return (entry_is_off_the_record(index) ? - off_the_record_entries_[index - entries_.size()] : entries_[index]); - } - - // Adds a new exception on the map and table model. - void AddException(const ContentSettingsPattern& pattern, - ContentSetting setting, - bool is_off_the_record); - - // Removes the exception at the specified index from both the map and model. - void RemoveException(int row); - - // Removes all the exceptions from both the map and model. - void RemoveAll(); - - // Returns the index of the specified exception given a host, or -1 if there - // is no exception for the specified host. - int IndexOfExceptionByPattern(const ContentSettingsPattern& pattern, - bool is_off_the_record); - - // TableModel overrides: - virtual int RowCount() OVERRIDE; - virtual string16 GetText(int row, int column_id) OVERRIDE; - virtual void SetObserver(ui::TableModelObserver* observer) OVERRIDE; - - private: - HostContentSettingsMap* map(bool is_off_the_record) { - return is_off_the_record ? off_the_record_map_ : map_; - } - HostContentSettingsMap::SettingsForOneType& entries(bool is_off_the_record) { - return is_off_the_record ? off_the_record_entries_ : entries_; - } - - scoped_refptr<HostContentSettingsMap> map_; - scoped_refptr<HostContentSettingsMap> off_the_record_map_; - ContentSettingsType content_type_; - HostContentSettingsMap::SettingsForOneType entries_; - HostContentSettingsMap::SettingsForOneType off_the_record_entries_; - ui::TableModelObserver* observer_; - - DISALLOW_COPY_AND_ASSIGN(ContentExceptionsTableModel); -}; - -#endif // CHROME_BROWSER_CONTENT_EXCEPTIONS_TABLE_MODEL_H_ diff --git a/chrome/browser/content_exceptions_table_model_unittest.cc b/chrome/browser/content_exceptions_table_model_unittest.cc deleted file mode 100644 index 677a9de..0000000 --- a/chrome/browser/content_exceptions_table_model_unittest.cc +++ /dev/null @@ -1,35 +0,0 @@ -// 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 "chrome/browser/content_exceptions_table_model.h" - -#include "chrome/test/testing_browser_process_test.h" -#include "chrome/test/testing_profile.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -class ContentExceptionsTableModelTest : public TestingBrowserProcessTest { - public: - ContentExceptionsTableModelTest() - : ui_thread_(BrowserThread::UI, &message_loop_) {} - - protected: - MessageLoop message_loop_; - BrowserThread ui_thread_; -}; - -TEST_F(ContentExceptionsTableModelTest, Incognito) { - TestingProfile profile; - TestingProfile* otr_profile = new TestingProfile(); - otr_profile->set_incognito(true); - ContentExceptionsTableModel model(profile.GetHostContentSettingsMap(), - otr_profile->GetHostContentSettingsMap(), - CONTENT_SETTINGS_TYPE_COOKIES); - delete otr_profile; - model.AddException(ContentSettingsPattern("example.com"), - CONTENT_SETTING_BLOCK, true); -} - -} // namespace diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index cd219a6..ae10e47 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -742,8 +742,6 @@ 'browser/cocoa/scoped_authorizationref.h', 'browser/command_updater.cc', 'browser/command_updater.h', - 'browser/content_exceptions_table_model.cc', - 'browser/content_exceptions_table_model.h', 'browser/content_setting_bubble_model.cc', 'browser/content_setting_bubble_model.h', 'browser/content_setting_combo_model.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index a8ca9d1..a5346ca 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1254,7 +1254,6 @@ 'browser/diagnostics/diagnostics_model_unittest.cc', 'browser/cocoa/keystone_glue_unittest.mm', 'browser/command_updater_unittest.cc', - 'browser/content_exceptions_table_model_unittest.cc', 'browser/content_settings/content_settings_pattern_unittest.cc', 'browser/content_settings/content_settings_provider_unittest.cc', 'browser/content_settings/host_content_settings_map_unittest.cc', |