| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_TABLE_MODEL_H_ | 5 #ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_TABLE_MODEL_H_ |
| 6 #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_TABLE_MODEL_H_ | 6 #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_TABLE_MODEL_H_ |
| 7 | 7 |
| 8 #include <set> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "app/table_model.h" | 11 #include "app/table_model.h" |
| 11 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 12 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
| 12 #include "chrome/common/content_settings.h" | 13 #include "chrome/common/content_settings.h" |
| 13 #include "chrome/common/content_settings_types.h" | 14 #include "chrome/common/content_settings_types.h" |
| 14 | 15 |
| 15 class GeolocationContentSettingsTableModel : public TableModel { | 16 class GeolocationContentSettingsTableModel : public TableModel { |
| 16 public: | 17 public: |
| 18 typedef std::set<size_t> Rows; |
| 19 |
| 17 explicit GeolocationContentSettingsTableModel( | 20 explicit GeolocationContentSettingsTableModel( |
| 18 GeolocationContentSettingsMap* map); | 21 GeolocationContentSettingsMap* map); |
| 19 | 22 |
| 20 // Return whether the given row can be removed. A parent with setting of | 23 // Return whether the given set of rows can be removed. A parent with setting |
| 21 // CONTENT_SETTING_DEFAULT can't be removed. | 24 // of CONTENT_SETTING_DEFAULT can't be removed unless all its children are |
| 22 bool CanRemoveException(int row) const; | 25 // also being removed. |
| 26 bool CanRemoveExceptions(const Rows& rows) const; |
| 23 | 27 |
| 24 // Removes the exception at the specified index from the map. If it is a | 28 // Removes the exceptions at the specified indexes. If an exception is a |
| 25 // parent, the row in model will be updated to have CONTENT_SETTING_DEFAULT. | 29 // parent, and it has children, the row in model will be updated to have |
| 26 // If it is the only child of a CONTENT_SETTING_DEFAULT parent, the parent | 30 // CONTENT_SETTING_DEFAULT. If it is the only child of a |
| 27 // will be removed from the model too. | 31 // CONTENT_SETTING_DEFAULT parent, the parent will be removed from the model |
| 28 void RemoveException(int row); | 32 // too. |
| 33 void RemoveExceptions(const Rows& rows); |
| 29 | 34 |
| 30 // Removes all the exceptions from both the map and model. | 35 // Removes all the exceptions from both the map and model. |
| 31 void RemoveAll(); | 36 void RemoveAll(); |
| 32 | 37 |
| 33 // TableModel overrides: | 38 // TableModel overrides: |
| 34 virtual int RowCount(); | 39 virtual int RowCount(); |
| 35 virtual std::wstring GetText(int row, int column_id); | 40 virtual std::wstring GetText(int row, int column_id); |
| 36 virtual void SetObserver(TableModelObserver* observer); | 41 virtual void SetObserver(TableModelObserver* observer); |
| 42 virtual int CompareValues(int row1, int row2, int column_id); |
| 37 | 43 |
| 38 private: | 44 private: |
| 39 struct Entry { | 45 struct Entry { |
| 40 Entry(const GURL& origin, | 46 Entry(const GURL& origin, |
| 41 const GURL& embedding_origin, | 47 const GURL& embedding_origin, |
| 42 ContentSetting setting); | 48 ContentSetting setting); |
| 43 | 49 |
| 44 GURL origin; | 50 GURL origin; |
| 45 GURL embedding_origin; | 51 GURL embedding_origin; |
| 46 ContentSetting setting; | 52 ContentSetting setting; |
| 47 }; | 53 }; |
| 48 | 54 |
| 49 void AddEntriesForOrigin( | 55 void AddEntriesForOrigin( |
| 50 const GURL& origin, | 56 const GURL& origin, |
| 51 const GeolocationContentSettingsMap::OneOriginSettings& settings); | 57 const GeolocationContentSettingsMap::OneOriginSettings& settings); |
| 52 | 58 |
| 53 GeolocationContentSettingsMap* map_; | 59 GeolocationContentSettingsMap* map_; |
| 54 | 60 |
| 55 typedef std::vector<Entry> EntriesVector; | 61 typedef std::vector<Entry> EntriesVector; |
| 56 EntriesVector entries_; | 62 EntriesVector entries_; |
| 57 | 63 |
| 58 TableModelObserver* observer_; | 64 TableModelObserver* observer_; |
| 59 | 65 |
| 60 DISALLOW_COPY_AND_ASSIGN(GeolocationContentSettingsTableModel); | 66 DISALLOW_COPY_AND_ASSIGN(GeolocationContentSettingsTableModel); |
| 61 }; | 67 }; |
| 62 | 68 |
| 63 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_TABLE_MODEL_H
_ | 69 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_CONTENT_SETTINGS_TABLE_MODEL_H
_ |
| OLD | NEW |