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.
5 #ifndef CHROME_BROWSER_PLUGIN_EXCEPTIONS_TABLE_MODEL_H_
6 #define CHROME_BROWSER_PLUGIN_EXCEPTIONS_TABLE_MODEL_H_
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"
20 class PluginExceptionsTableModel
: public RemoveRowsTableModel
,
21 public NotificationObserver
{
23 PluginExceptionsTableModel(HostContentSettingsMap
* content_settings_map
,
24 HostContentSettingsMap
* otr_content_settings_map
);
25 virtual ~PluginExceptionsTableModel();
27 // Load plugin exceptions from the HostContentSettingsMaps. You should call
28 // this method after creating a new PluginExceptionsTableModel.
31 // RemoveRowsTableModel methods:
32 virtual bool CanRemoveRows(const Rows
& rows
) const;
33 virtual void RemoveRows(const Rows
& rows
);
34 virtual void RemoveAll();
36 // TableModel methods:
37 virtual int RowCount() OVERRIDE
;
38 virtual string16
GetText(int row
, int column_id
) OVERRIDE
;
39 virtual void SetObserver(ui::TableModelObserver
* observer
) OVERRIDE
;
40 virtual bool HasGroups() OVERRIDE
;
41 virtual Groups
GetGroups() OVERRIDE
;
42 virtual int GetGroupID(int row
) OVERRIDE
;
44 // NotificationObserver methods:
45 virtual void Observe(NotificationType type
,
46 const NotificationSource
& source
,
47 const NotificationDetails
& details
);
50 // Subclasses can override this method for testing.
51 virtual void GetPlugins(
52 std::vector
<webkit::npapi::PluginGroup
>* plugin_groups
);
55 friend class PluginExceptionsTableModelTest
;
57 struct SettingsEntry
{
58 ContentSettingsPattern pattern
;
60 ContentSetting setting
;
65 void ReloadSettings();
67 scoped_refptr
<HostContentSettingsMap
> map_
;
68 scoped_refptr
<HostContentSettingsMap
> otr_map_
;
70 std::vector
<SettingsEntry
> settings_
;
71 std::vector
<int> row_counts_
;
72 std::vector
<std::string
> resources_
;
73 TableModel::Groups groups_
;
75 NotificationRegistrar registrar_
;
76 bool updates_disabled_
;
78 // Weak, can be NULL. Our owner should manage its lifetime, see
79 // TableModel::SetObserver().
80 ui::TableModelObserver
* observer_
;
82 DISALLOW_COPY_AND_ASSIGN(PluginExceptionsTableModel
);
85 #endif // CHROME_BROWSER_PLUGIN_EXCEPTIONS_TABLE_MODEL_H_