Print Preview: Changing displayed error message when PDF Viewer is missing.
[chromium-blink-merge.git] / chrome / browser / plugin_exceptions_table_model.h
blob55fc6460d5bbae1bf832284b1e584e864d80fa47
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_
7 #pragma once
9 #include <string>
10 #include <vector>
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"
18 struct WebPluginInfo;
20 class PluginExceptionsTableModel : public RemoveRowsTableModel,
21 public NotificationObserver {
22 public:
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.
29 void LoadSettings();
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);
49 protected:
50 // Subclasses can override this method for testing.
51 virtual void GetPlugins(
52 std::vector<webkit::npapi::PluginGroup>* plugin_groups);
54 private:
55 friend class PluginExceptionsTableModelTest;
57 struct SettingsEntry {
58 ContentSettingsPattern pattern;
59 int plugin_id;
60 ContentSetting setting;
61 bool is_otr;
64 void ClearSettings();
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_