| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_PLUGIN_EXCEPTIONS_TABLE_MODEL_H_ | |
| 6 #define CHROME_BROWSER_PLUGIN_EXCEPTIONS_TABLE_MODEL_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/compiler_specific.h" | |
| 13 #include "chrome/browser/content_settings/host_content_settings_map.h" | |
| 14 #include "chrome/browser/remove_rows_table_model.h" | |
| 15 #include "content/common/notification_observer.h" | |
| 16 #include "webkit/plugins/npapi/plugin_list.h" | |
| 17 | |
| 18 class PluginExceptionsTableModel : public RemoveRowsTableModel, | |
| 19 public NotificationObserver { | |
| 20 public: | |
| 21 PluginExceptionsTableModel(HostContentSettingsMap* content_settings_map, | |
| 22 HostContentSettingsMap* otr_content_settings_map); | |
| 23 virtual ~PluginExceptionsTableModel(); | |
| 24 | |
| 25 // Load plugin exceptions from the HostContentSettingsMaps. You should call | |
| 26 // this method after creating a new PluginExceptionsTableModel. | |
| 27 void LoadSettings(); | |
| 28 | |
| 29 // RemoveRowsTableModel methods: | |
| 30 virtual bool CanRemoveRows(const Rows& rows) const; | |
| 31 virtual void RemoveRows(const Rows& rows); | |
| 32 virtual void RemoveAll(); | |
| 33 | |
| 34 // TableModel methods: | |
| 35 virtual int RowCount() OVERRIDE; | |
| 36 virtual string16 GetText(int row, int column_id) OVERRIDE; | |
| 37 virtual void SetObserver(ui::TableModelObserver* observer) OVERRIDE; | |
| 38 virtual bool HasGroups() OVERRIDE; | |
| 39 virtual Groups GetGroups() OVERRIDE; | |
| 40 virtual int GetGroupID(int row) OVERRIDE; | |
| 41 | |
| 42 // NotificationObserver methods: | |
| 43 virtual void Observe(int type, | |
| 44 const NotificationSource& source, | |
| 45 const NotificationDetails& details); | |
| 46 | |
| 47 protected: | |
| 48 // Subclasses can override this method for testing. | |
| 49 virtual void GetPlugins( | |
| 50 std::vector<webkit::npapi::PluginGroup>* plugin_groups); | |
| 51 | |
| 52 private: | |
| 53 friend class PluginExceptionsTableModelTest; | |
| 54 | |
| 55 struct SettingsEntry { | |
| 56 ContentSettingsPattern pattern; | |
| 57 int plugin_id; | |
| 58 ContentSetting setting; | |
| 59 bool is_otr; | |
| 60 }; | |
| 61 | |
| 62 void ClearSettings(); | |
| 63 void ReloadSettings(); | |
| 64 | |
| 65 scoped_refptr<HostContentSettingsMap> map_; | |
| 66 scoped_refptr<HostContentSettingsMap> otr_map_; | |
| 67 | |
| 68 std::vector<SettingsEntry> settings_; | |
| 69 std::vector<int> row_counts_; | |
| 70 std::vector<std::string> resources_; | |
| 71 TableModel::Groups groups_; | |
| 72 | |
| 73 NotificationRegistrar registrar_; | |
| 74 bool updates_disabled_; | |
| 75 | |
| 76 // Weak, can be NULL. Our owner should manage its lifetime, see | |
| 77 // TableModel::SetObserver(). | |
| 78 ui::TableModelObserver* observer_; | |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(PluginExceptionsTableModel); | |
| 81 }; | |
| 82 | |
| 83 #endif // CHROME_BROWSER_PLUGIN_EXCEPTIONS_TABLE_MODEL_H_ | |
| OLD | NEW |