diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-22 15:59:38 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-22 15:59:38 +0000 |
commit | 91605475412f64bccc339122d8bf6dbb33e1ee01 (patch) | |
tree | fe12eaa078e2b1dbb86805f3f30de479fd8f3909 | |
parent | dff5f0000f72dbda83428a85055a3441008619fd (diff) | |
download | chromium_src-91605475412f64bccc339122d8bf6dbb33e1ee01.zip chromium_src-91605475412f64bccc339122d8bf6dbb33e1ee01.tar.gz chromium_src-91605475412f64bccc339122d8bf6dbb33e1ee01.tar.bz2 |
Get rid of synchronous calls to getting plugins to help with http://codereview.chromium.org/7980011/.
The PluginExceptionsTableModel isn't used anymore.
Change print preview and using Reader with unsupported PDFs to tell the plugin filter which plugin name they want to use, instead of giving it the plugin directly. This makes the former not need to block on getting the plugins. The later still does, to know if Reader is installed or not, however it's trivial to make PDFHasUnsupportedFeature() get the plugins asynchronously because it's just a dispatcher for an async message.
Review URL: http://codereview.chromium.org/7977042
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102284 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chrome_plugin_service_filter.cc | 21 | ||||
-rw-r--r-- | chrome/browser/chrome_plugin_service_filter.h | 5 | ||||
-rw-r--r-- | chrome/browser/mock_plugin_exceptions_table_model.cc | 22 | ||||
-rw-r--r-- | chrome/browser/mock_plugin_exceptions_table_model.h | 29 | ||||
-rw-r--r-- | chrome/browser/pdf_unsupported_feature.cc | 8 | ||||
-rw-r--r-- | chrome/browser/plugin_exceptions_table_model.cc | 200 | ||||
-rw-r--r-- | chrome/browser/plugin_exceptions_table_model.h | 83 | ||||
-rw-r--r-- | chrome/browser/plugin_exceptions_table_model_unittest.cc | 220 | ||||
-rw-r--r-- | chrome/browser/printing/print_preview_tab_controller.cc | 28 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 3 |
11 files changed, 20 insertions, 601 deletions
diff --git a/chrome/browser/chrome_plugin_service_filter.cc b/chrome/browser/chrome_plugin_service_filter.cc index de45954..7c42234 100644 --- a/chrome/browser/chrome_plugin_service_filter.cc +++ b/chrome/browser/chrome_plugin_service_filter.cc @@ -5,6 +5,7 @@ #include "chrome/browser/chrome_plugin_service_filter.h" #include "base/logging.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/plugin_prefs.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_notification_types.h" @@ -13,8 +14,11 @@ #include "content/browser/renderer_host/render_process_host.h" #include "content/browser/resource_context.h" #include "content/common/notification_service.h" +#include "webkit/plugins/npapi/plugin_group.h" #include "webkit/plugins/npapi/plugin_list.h" +using webkit::npapi::PluginGroup; + // static ChromePluginServiceFilter* ChromePluginServiceFilter::GetInstance() { return Singleton<ChromePluginServiceFilter>::get(); @@ -38,12 +42,12 @@ void ChromePluginServiceFilter::OverridePluginForTab( int render_process_id, int render_view_id, const GURL& url, - const webkit::WebPluginInfo& plugin) { + const string16& plugin_name) { OverriddenPlugin overridden_plugin; overridden_plugin.render_process_id = render_process_id; overridden_plugin.render_view_id = render_view_id; overridden_plugin.url = url; - overridden_plugin.plugin = plugin; + overridden_plugin.plugin_name = plugin_name; base::AutoLock auto_lock(lock_); overridden_plugins_.push_back(overridden_plugin); } @@ -78,10 +82,15 @@ bool ChromePluginServiceFilter::ShouldUsePlugin( overridden_plugins_[i].render_view_id == render_view_id && (overridden_plugins_[i].url == url || overridden_plugins_[i].url.is_empty())) { - if (overridden_plugins_[i].plugin.path != plugin->path) - return false; - *plugin = overridden_plugins_[i].plugin; - return true; + + bool use = overridden_plugins_[i].plugin_name == plugin->name; + if (use && + plugin->name == ASCIIToUTF16(PluginGroup::kAdobeReaderGroupName)) { + // If the caller is forcing the Adobe Reader plugin, then don't show the + // blocked plugin UI if it's vulnerable. + plugin->version = ASCIIToUTF16("11.0.0.0"); + } + return use; } } diff --git a/chrome/browser/chrome_plugin_service_filter.h b/chrome/browser/chrome_plugin_service_filter.h index ed4510a..764e1e7 100644 --- a/chrome/browser/chrome_plugin_service_filter.h +++ b/chrome/browser/chrome_plugin_service_filter.h @@ -18,7 +18,6 @@ #include "content/common/notification_observer.h" #include "content/common/notification_registrar.h" #include "googleurl/src/gurl.h" -#include "webkit/plugins/webplugininfo.h" class PluginPrefs; class Profile; @@ -40,7 +39,7 @@ class ChromePluginServiceFilter : public content::PluginServiceFilter, void OverridePluginForTab(int render_process_id, int render_view_id, const GURL& url, - const webkit::WebPluginInfo& plugin); + const string16& plugin_name); // Restricts the given plugin to the given profile and origin of the given // URL. @@ -67,7 +66,7 @@ class ChromePluginServiceFilter : public content::PluginServiceFilter, int render_process_id; int render_view_id; GURL url; // If empty, the override applies to all urls in render_view. - webkit::WebPluginInfo plugin; + string16 plugin_name; }; ChromePluginServiceFilter(); diff --git a/chrome/browser/mock_plugin_exceptions_table_model.cc b/chrome/browser/mock_plugin_exceptions_table_model.cc deleted file mode 100644 index 281777b..0000000 --- a/chrome/browser/mock_plugin_exceptions_table_model.cc +++ /dev/null @@ -1,22 +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/mock_plugin_exceptions_table_model.h" - -MockPluginExceptionsTableModel::MockPluginExceptionsTableModel( - HostContentSettingsMap* map, - HostContentSettingsMap* otr_map) - : PluginExceptionsTableModel(map, otr_map) {} - -MockPluginExceptionsTableModel::~MockPluginExceptionsTableModel() {} - -void MockPluginExceptionsTableModel::set_plugins( - std::vector<webkit::npapi::PluginGroup>& plugins) { - plugins_ = plugins; -} - -void MockPluginExceptionsTableModel::GetPlugins( - std::vector<webkit::npapi::PluginGroup>* plugin_groups) { - *plugin_groups = plugins_; -} diff --git a/chrome/browser/mock_plugin_exceptions_table_model.h b/chrome/browser/mock_plugin_exceptions_table_model.h deleted file mode 100644 index 1fae316..0000000 --- a/chrome/browser/mock_plugin_exceptions_table_model.h +++ /dev/null @@ -1,29 +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. - -#ifndef CHROME_BROWSER_MOCK_PLUGIN_EXCEPTIONS_TABLE_MODEL_H_ -#define CHROME_BROWSER_MOCK_PLUGIN_EXCEPTIONS_TABLE_MODEL_H_ -#pragma once - -#include <vector> - -#include "chrome/browser/plugin_exceptions_table_model.h" - -class MockPluginExceptionsTableModel : public PluginExceptionsTableModel { - public: - MockPluginExceptionsTableModel(HostContentSettingsMap* map, - HostContentSettingsMap* otr_map); - virtual ~MockPluginExceptionsTableModel(); - - void set_plugins(std::vector<webkit::npapi::PluginGroup>& plugins); - - protected: - virtual void GetPlugins( - std::vector<webkit::npapi::PluginGroup>* plugin_groups); - - private: - std::vector<webkit::npapi::PluginGroup> plugins_; -}; - -#endif // CHROME_BROWSER_MOCK_PLUGIN_EXCEPTIONS_TABLE_MODEL_H_ diff --git a/chrome/browser/pdf_unsupported_feature.cc b/chrome/browser/pdf_unsupported_feature.cc index c5460f8..d69d8a0 100644 --- a/chrome/browser/pdf_unsupported_feature.cc +++ b/chrome/browser/pdf_unsupported_feature.cc @@ -140,17 +140,11 @@ void OpenUsingReader(TabContentsWrapper* tab, const WebPluginInfo& reader_plugin, InfoBarDelegate* old_delegate, InfoBarDelegate* new_delegate) { - WebPluginInfo plugin = reader_plugin; - // Give the plugin a new version so that the renderer doesn't show the blocked - // plugin UI if it's vulnerable, since we already went through the - // interstitial. - plugin.version = ASCIIToUTF16("11.0.0.0"); - ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( tab->render_view_host()->process()->id(), tab->render_view_host()->routing_id(), tab->tab_contents()->GetURL(), - plugin); + ASCIIToUTF16(PluginGroup::kAdobeReaderGroupName)); tab->render_view_host()->ReloadFrame(); if (new_delegate) { diff --git a/chrome/browser/plugin_exceptions_table_model.cc b/chrome/browser/plugin_exceptions_table_model.cc deleted file mode 100644 index a2e532b..0000000 --- a/chrome/browser/plugin_exceptions_table_model.cc +++ /dev/null @@ -1,200 +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/plugin_exceptions_table_model.h" - -#include "base/auto_reset.h" -#include "base/sys_string_conversions.h" -#include "base/utf_string_conversions.h" -#include "chrome/common/chrome_notification_types.h" -#include "content/common/notification_service.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/models/table_model_observer.h" - -PluginExceptionsTableModel::PluginExceptionsTableModel( - HostContentSettingsMap* content_settings_map, - HostContentSettingsMap* otr_content_settings_map) - : map_(content_settings_map), - otr_map_(otr_content_settings_map), - updates_disabled_(false), - observer_(NULL) { - registrar_.Add(this, chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED, - Source<HostContentSettingsMap>(map_)); - if (otr_map_) { - registrar_.Add(this, chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED, - Source<HostContentSettingsMap>(otr_map_)); - } -} - -PluginExceptionsTableModel::~PluginExceptionsTableModel() { -} - -bool PluginExceptionsTableModel::CanRemoveRows(const Rows& rows) const { - return !rows.empty(); -} - -void PluginExceptionsTableModel::RemoveRows(const Rows& rows) { - AutoReset<bool> tmp(&updates_disabled_, true); - bool reload_all = false; - // Iterate over the rows starting with the highest ones so we can delete - // entries from |settings_| without the other indices shifting. - for (Rows::const_reverse_iterator it = rows.rbegin(); - it != rows.rend(); ++it) { - DCHECK_LT(*it, settings_.size()); - SettingsEntry entry = settings_[*it]; - HostContentSettingsMap* map = entry.is_otr ? otr_map_ : map_; - map->SetContentSetting(entry.pattern, - ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_PLUGINS, - resources_[entry.plugin_id], - CONTENT_SETTING_DEFAULT); - settings_.erase(settings_.begin() + *it); - row_counts_[entry.plugin_id]--; - if (!reload_all) { - // If we remove the last exception for a plugin, recreate all groups - // to get correct IDs. - if (row_counts_[entry.plugin_id] == 0) { - reload_all = true; - } else { - if (observer_) - observer_->OnItemsRemoved(*it, 1); - } - } - } - if (reload_all) { - // This also notifies the observer. - ReloadSettings(); - } -} - -void PluginExceptionsTableModel::RemoveAll() { - AutoReset<bool> tmp(&updates_disabled_, true); - map_->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_PLUGINS); - if (otr_map_) - otr_map_->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_PLUGINS); - - ClearSettings(); - if (observer_) - observer_->OnModelChanged(); -} - -int PluginExceptionsTableModel::RowCount() { - return settings_.size(); -} - -string16 PluginExceptionsTableModel::GetText(int row, int column_id) { - DCHECK_GE(row, 0); - DCHECK_LT(row, static_cast<int>(settings_.size())); - SettingsEntry& entry = settings_[row]; - if (column_id == IDS_EXCEPTIONS_PATTERN_HEADER || - column_id == IDS_EXCEPTIONS_HOSTNAME_HEADER) { - return UTF8ToUTF16(entry.pattern.ToString()); - } else if (column_id == IDS_EXCEPTIONS_ACTION_HEADER) { - switch (entry.setting) { - case CONTENT_SETTING_ALLOW: - return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON); - case CONTENT_SETTING_BLOCK: - return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON); - default: - NOTREACHED(); - } - } else { - NOTREACHED(); - } - return string16(); -} - -bool PluginExceptionsTableModel::HasGroups() { - return true; -} - -void PluginExceptionsTableModel::SetObserver(ui::TableModelObserver* observer) { - observer_ = observer; -} - -ui::TableModel::Groups PluginExceptionsTableModel::GetGroups() { - return groups_; -} - -int PluginExceptionsTableModel::GetGroupID(int row) { - DCHECK_LT(row, static_cast<int>(settings_.size())); - return settings_[row].plugin_id; -} - -void PluginExceptionsTableModel::Observe(int type, - const NotificationSource& source, - const NotificationDetails& details) { - if (!updates_disabled_) - ReloadSettings(); -} - -void PluginExceptionsTableModel::ClearSettings() { - settings_.clear(); - groups_.clear(); - row_counts_.clear(); - resources_.clear(); -} - -void PluginExceptionsTableModel::GetPlugins( - std::vector<webkit::npapi::PluginGroup>* plugin_groups) { - webkit::npapi::PluginList::Singleton()->GetPluginGroups(false, plugin_groups); -} - -void PluginExceptionsTableModel::LoadSettings() { - int group_id = 0; - std::vector<webkit::npapi::PluginGroup> plugins; - GetPlugins(&plugins); - for (size_t i = 0; i < plugins.size(); ++i) { - std::string plugin = plugins[i].identifier(); - HostContentSettingsMap::SettingsForOneType settings; - map_->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_PLUGINS, - plugin, - &settings); - HostContentSettingsMap::SettingsForOneType otr_settings; - if (otr_map_) { - otr_map_->GetSettingsForOneType(CONTENT_SETTINGS_TYPE_PLUGINS, - plugin, - &otr_settings); - } - string16 title = plugins[i].GetGroupName(); - for (HostContentSettingsMap::SettingsForOneType::iterator setting_it = - settings.begin(); - setting_it != settings.end(); ++setting_it) { - SettingsEntry entry = { - setting_it->a, - group_id, - setting_it->c, - false - }; - settings_.push_back(entry); - } - for (HostContentSettingsMap::SettingsForOneType::iterator setting_it = - otr_settings.begin(); - setting_it != otr_settings.end(); ++setting_it) { - SettingsEntry entry = { - setting_it->a, - group_id, - setting_it->c, - true - }; - settings_.push_back(entry); - } - int num_plugins = settings.size() + otr_settings.size(); - if (num_plugins > 0) { - Group group = { title, group_id++ }; - groups_.push_back(group); - resources_.push_back(plugin); - row_counts_.push_back(num_plugins); - } - } -} - -void PluginExceptionsTableModel::ReloadSettings() { - ClearSettings(); - LoadSettings(); - - if (observer_) - observer_->OnModelChanged(); -} diff --git a/chrome/browser/plugin_exceptions_table_model.h b/chrome/browser/plugin_exceptions_table_model.h deleted file mode 100644 index 9f37621..0000000 --- a/chrome/browser/plugin_exceptions_table_model.h +++ /dev/null @@ -1,83 +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_PLUGIN_EXCEPTIONS_TABLE_MODEL_H_ -#define CHROME_BROWSER_PLUGIN_EXCEPTIONS_TABLE_MODEL_H_ -#pragma once - -#include <string> -#include <vector> - -#include "base/compiler_specific.h" -#include "chrome/browser/content_settings/host_content_settings_map.h" -#include "chrome/browser/remove_rows_table_model.h" -#include "content/common/notification_observer.h" -#include "webkit/plugins/npapi/plugin_list.h" - -class PluginExceptionsTableModel : public RemoveRowsTableModel, - public NotificationObserver { - public: - PluginExceptionsTableModel(HostContentSettingsMap* content_settings_map, - HostContentSettingsMap* otr_content_settings_map); - virtual ~PluginExceptionsTableModel(); - - // Load plugin exceptions from the HostContentSettingsMaps. You should call - // this method after creating a new PluginExceptionsTableModel. - void LoadSettings(); - - // RemoveRowsTableModel methods: - virtual bool CanRemoveRows(const Rows& rows) const; - virtual void RemoveRows(const Rows& rows); - virtual void RemoveAll(); - - // TableModel methods: - virtual int RowCount() OVERRIDE; - virtual string16 GetText(int row, int column_id) OVERRIDE; - virtual void SetObserver(ui::TableModelObserver* observer) OVERRIDE; - virtual bool HasGroups() OVERRIDE; - virtual Groups GetGroups() OVERRIDE; - virtual int GetGroupID(int row) OVERRIDE; - - // NotificationObserver methods: - virtual void Observe(int type, - const NotificationSource& source, - const NotificationDetails& details); - - protected: - // Subclasses can override this method for testing. - virtual void GetPlugins( - std::vector<webkit::npapi::PluginGroup>* plugin_groups); - - private: - friend class PluginExceptionsTableModelTest; - - struct SettingsEntry { - ContentSettingsPattern pattern; - int plugin_id; - ContentSetting setting; - bool is_otr; - }; - - void ClearSettings(); - void ReloadSettings(); - - scoped_refptr<HostContentSettingsMap> map_; - scoped_refptr<HostContentSettingsMap> otr_map_; - - std::vector<SettingsEntry> settings_; - std::vector<int> row_counts_; - std::vector<std::string> resources_; - TableModel::Groups groups_; - - NotificationRegistrar registrar_; - bool updates_disabled_; - - // Weak, can be NULL. Our owner should manage its lifetime, see - // TableModel::SetObserver(). - ui::TableModelObserver* observer_; - - DISALLOW_COPY_AND_ASSIGN(PluginExceptionsTableModel); -}; - -#endif // CHROME_BROWSER_PLUGIN_EXCEPTIONS_TABLE_MODEL_H_ diff --git a/chrome/browser/plugin_exceptions_table_model_unittest.cc b/chrome/browser/plugin_exceptions_table_model_unittest.cc deleted file mode 100644 index f37c6c1..0000000 --- a/chrome/browser/plugin_exceptions_table_model_unittest.cc +++ /dev/null @@ -1,220 +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 "base/auto_reset.h" -#include "base/command_line.h" -#include "base/utf_string_conversions.h" -#include "chrome/browser/mock_plugin_exceptions_table_model.h" -#include "chrome/common/chrome_switches.h" -#include "chrome/test/base/testing_pref_service.h" -#include "chrome/test/base/testing_profile.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "ui/base/models/table_model_observer.h" -#include "webkit/plugins/npapi/plugin_group.h" -#include "webkit/plugins/webplugininfo.h" - -// Can't be an internal namespace because PluginExceptionsTableModel declares -// as a friend. -namespace plugin_test_internal { - -using ::testing::_; -using ::testing::Invoke; - -class MockTableModelObserver : public ui::TableModelObserver { - public: - explicit MockTableModelObserver(ui::TableModel* model) - : model_(model) { - ON_CALL(*this, OnItemsRemoved(_, _)) - .WillByDefault( - Invoke(this, &MockTableModelObserver::CheckOnItemsRemoved)); - } - - MOCK_METHOD0(OnModelChanged, void()); - MOCK_METHOD2(OnItemsChanged, void(int start, int length)); - MOCK_METHOD2(OnItemsAdded, void(int start, int length)); - MOCK_METHOD2(OnItemsRemoved, void(int start, int length)); - - private: - void CheckOnItemsRemoved(int start, int length) { - if (!model_) - return; - // This method is called *after* the items have been removed, so we check if - // the first removed item was still inside the correct range. - EXPECT_LT(start, model_->RowCount() + 1); - } - - ui::TableModel* model_; -}; - -} // namespace plugin_test_internal - -using ::testing::InSequence; - -class PluginExceptionsTableModelTest : public testing::Test { - public: - PluginExceptionsTableModelTest() - : ui_thread_(BrowserThread::UI, &message_loop_), - command_line_(CommandLine::ForCurrentProcess(), - *CommandLine::ForCurrentProcess()) {} - - virtual void SetUp() { - CommandLine::ForCurrentProcess()->AppendSwitch( - switches::kEnableResourceContentSettings); - - profile_.reset(new TestingProfile()); - - HostContentSettingsMap* map = profile_->GetHostContentSettingsMap(); - - ContentSettingsPattern example_com = - ContentSettingsPattern::FromString("[*.]example.com"); - ContentSettingsPattern moose_org = - ContentSettingsPattern::FromString("[*.]moose.org"); - map->SetContentSetting(example_com, - ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_PLUGINS, - "a-foo", - CONTENT_SETTING_ALLOW); - map->SetContentSetting(moose_org, - ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_PLUGINS, - "b-bar", - CONTENT_SETTING_BLOCK); - map->SetContentSetting(example_com, - ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_PLUGINS, - "b-bar", - CONTENT_SETTING_ALLOW); - - table_model_.reset(new MockPluginExceptionsTableModel(map, NULL)); - - std::vector<webkit::npapi::PluginGroup> plugins; - webkit::WebPluginInfo foo_plugin; - foo_plugin.path = FilePath(FILE_PATH_LITERAL("a-foo")); - foo_plugin.name = ASCIIToUTF16("FooPlugin"); - scoped_ptr<webkit::npapi::PluginGroup> foo_group( - webkit::npapi::PluginGroup::FromWebPluginInfo(foo_plugin)); - plugins.push_back(*foo_group); - - webkit::WebPluginInfo bar_plugin; - bar_plugin.path = FilePath(FILE_PATH_LITERAL("b-bar")); - bar_plugin.name = ASCIIToUTF16("BarPlugin"); - scoped_ptr<webkit::npapi::PluginGroup> bar_group( - webkit::npapi::PluginGroup::FromWebPluginInfo(bar_plugin)); - plugins.push_back(*bar_group); - - table_model_->set_plugins(plugins); - table_model_->ReloadSettings(); - } - - protected: - void CheckInvariants() const { - typedef std::vector<PluginExceptionsTableModel::SettingsEntry> Entries; - const Entries& settings = table_model_->settings_; - const std::vector<int>& row_counts = table_model_->row_counts_; - const std::vector<std::string>& resources = table_model_->resources_; - const ui::TableModel::Groups& groups = table_model_->groups_; - - EXPECT_EQ(groups.size(), row_counts.size()); - EXPECT_EQ(groups.size(), resources.size()); - - int last_plugin = 0; - int count = 0; - for (Entries::const_iterator it = settings.begin(); - it != settings.end(); ++it) { - // Plugin IDs are indices into |groups|. - EXPECT_GE(it->plugin_id, 0); - EXPECT_LT(it->plugin_id, static_cast<int>(groups.size())); - if (it->plugin_id == last_plugin) { - count++; - } else { - // Plugin IDs are ascending one by one. - EXPECT_EQ(last_plugin+1, it->plugin_id); - - // Consecutive runs of plugins with id |x| are |row_counts[x]| long. - EXPECT_EQ(count, row_counts[last_plugin]); - count = 1; - last_plugin = it->plugin_id; - } - } - if (!row_counts.empty()) - EXPECT_EQ(count, row_counts[last_plugin]); - } - - protected: - MessageLoop message_loop_; - BrowserThread ui_thread_; - - scoped_ptr<TestingProfile> profile_; - scoped_ptr<MockPluginExceptionsTableModel> table_model_; - - private: - AutoReset<CommandLine> command_line_; -}; - -TEST_F(PluginExceptionsTableModelTest, Basic) { - EXPECT_EQ(3, table_model_->RowCount()); - CheckInvariants(); -} - -TEST_F(PluginExceptionsTableModelTest, RemoveOneRow) { - plugin_test_internal::MockTableModelObserver observer(table_model_.get()); - table_model_->SetObserver(&observer); - - EXPECT_CALL(observer, OnItemsRemoved(1, 1)); - RemoveRowsTableModel::Rows rows; - rows.insert(1); - table_model_->RemoveRows(rows); - EXPECT_EQ(2, table_model_->RowCount()); - EXPECT_EQ(2, static_cast<int>(table_model_->GetGroups().size())); - CheckInvariants(); - table_model_->SetObserver(NULL); -} - -TEST_F(PluginExceptionsTableModelTest, RemoveLastRowInGroup) { - plugin_test_internal::MockTableModelObserver observer(table_model_.get()); - table_model_->SetObserver(&observer); - - EXPECT_CALL(observer, OnModelChanged()); - RemoveRowsTableModel::Rows rows; - rows.insert(0); - table_model_->RemoveRows(rows); - EXPECT_EQ(2, table_model_->RowCount()); - EXPECT_EQ(1, static_cast<int>(table_model_->GetGroups().size())); - CheckInvariants(); - - HostContentSettingsMap* map = profile_->GetHostContentSettingsMap(); - EXPECT_CALL(observer, OnModelChanged()); - map->SetContentSetting(ContentSettingsPattern::FromString("[*.]blurp.net"), - ContentSettingsPattern::Wildcard(), - CONTENT_SETTINGS_TYPE_PLUGINS, - "b-bar", - CONTENT_SETTING_BLOCK); - EXPECT_EQ(3, table_model_->RowCount()); - - InSequence s; - EXPECT_CALL(observer, OnItemsRemoved(2, 1)); - EXPECT_CALL(observer, OnItemsRemoved(0, 1)); - rows.clear(); - rows.insert(0); - rows.insert(2); - table_model_->RemoveRows(rows); - EXPECT_EQ(1, table_model_->RowCount()); - EXPECT_EQ(1, static_cast<int>(table_model_->GetGroups().size())); - CheckInvariants(); - - table_model_->SetObserver(NULL); -} - -TEST_F(PluginExceptionsTableModelTest, RemoveAllRows) { - plugin_test_internal::MockTableModelObserver observer(table_model_.get()); - table_model_->SetObserver(&observer); - - EXPECT_CALL(observer, OnModelChanged()); - table_model_->RemoveAll(); - EXPECT_EQ(0, table_model_->RowCount()); - EXPECT_EQ(0, static_cast<int>(table_model_->GetGroups().size())); - CheckInvariants(); - table_model_->SetObserver(NULL); -} diff --git a/chrome/browser/printing/print_preview_tab_controller.cc b/chrome/browser/printing/print_preview_tab_controller.cc index 10cb9c6..a6fc0a4 100644 --- a/chrome/browser/printing/print_preview_tab_controller.cc +++ b/chrome/browser/printing/print_preview_tab_controller.cc @@ -28,41 +28,17 @@ #include "content/common/content_notification_types.h" #include "content/common/notification_details.h" #include "content/common/notification_source.h" -#include "webkit/plugins/npapi/plugin_group.h" -#include "webkit/plugins/npapi/plugin_list.h" #include "webkit/plugins/webplugininfo.h" -using webkit::npapi::PluginGroup; -using webkit::npapi::PluginList; -using webkit::WebPluginInfo; - namespace { void EnableInternalPDFPluginForTab(TabContentsWrapper* preview_tab) { // Always enable the internal PDF plugin for the print preview page. - string16 internal_pdf_group_name( - ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName)); - PluginGroup* internal_pdf_group = NULL; - std::vector<PluginGroup> plugin_groups; - PluginList::Singleton()->GetPluginGroups(false, &plugin_groups); - for (size_t i = 0; i < plugin_groups.size(); ++i) { - if (plugin_groups[i].GetGroupName() == internal_pdf_group_name) { - internal_pdf_group = &plugin_groups[i]; - break; - } - } - if (internal_pdf_group) { - const std::vector<WebPluginInfo>& plugins = - internal_pdf_group->web_plugin_infos(); - DCHECK_EQ(plugins.size(), 1U); - - webkit::WebPluginInfo plugin = plugins[0]; - ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( + ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( preview_tab->render_view_host()->process()->id(), preview_tab->render_view_host()->routing_id(), GURL(), - plugin); - } + ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName)); } void ResetPreviewTabOverrideTitle(TabContentsWrapper* preview_tab) { diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 8d0f543..0fb28a3 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1657,8 +1657,6 @@ 'browser/plugin_data_remover_helper.h', 'browser/plugin_download_helper.cc', 'browser/plugin_download_helper.h', - 'browser/plugin_exceptions_table_model.cc', - 'browser/plugin_exceptions_table_model.h', 'browser/plugin_installer_infobar_delegate.cc', 'browser/plugin_installer_infobar_delegate.h', 'browser/plugin_observer.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 91f2c06..4d3086f 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1322,8 +1322,6 @@ 'browser/metrics/thread_watcher_unittest.cc', 'browser/mock_keychain_mac.cc', 'browser/mock_keychain_mac.h', - 'browser/mock_plugin_exceptions_table_model.cc', - 'browser/mock_plugin_exceptions_table_model.h', 'browser/net/chrome_net_log_unittest.cc', 'browser/net/connection_tester_unittest.cc', 'browser/net/gaia/gaia_oauth_fetcher_unittest.cc', @@ -1355,7 +1353,6 @@ 'browser/password_manager/password_store_mac_unittest.cc', 'browser/password_manager/password_store_win_unittest.cc', 'browser/password_manager/password_store_x_unittest.cc', - 'browser/plugin_exceptions_table_model_unittest.cc', 'browser/plugin_prefs_unittest.cc', 'browser/policy/asynchronous_policy_loader_unittest.cc', 'browser/policy/asynchronous_policy_provider_unittest.cc', |