| 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_EXCEPTIONS_TABLE_MODEL_H_ | 5 #ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_EXCEPTIONS_TABLE_MODEL_H_ |
| 6 #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_EXCEPTIONS_TABLE_MODEL_H_ | 6 #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_EXCEPTIONS_TABLE_MODEL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" |
| 11 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 12 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
| 12 #include "chrome/browser/remove_rows_table_model.h" | 13 #include "chrome/browser/remove_rows_table_model.h" |
| 13 #include "chrome/common/content_settings.h" | 14 #include "chrome/common/content_settings.h" |
| 14 #include "chrome/common/content_settings_types.h" | 15 #include "chrome/common/content_settings_types.h" |
| 15 | 16 |
| 16 class GeolocationExceptionsTableModel : public RemoveRowsTableModel { | 17 class GeolocationExceptionsTableModel : public RemoveRowsTableModel { |
| 17 public: | 18 public: |
| 18 explicit GeolocationExceptionsTableModel( | 19 explicit GeolocationExceptionsTableModel( |
| 19 GeolocationContentSettingsMap* map); | 20 GeolocationContentSettingsMap* map); |
| 20 virtual ~GeolocationExceptionsTableModel(); | 21 virtual ~GeolocationExceptionsTableModel(); |
| 21 | 22 |
| 22 // RemoveRowsTableModel overrides: | 23 // RemoveRowsTableModel overrides: |
| 23 | 24 |
| 24 // Return whether the given set of rows can be removed. A parent with setting | 25 // Return whether the given set of rows can be removed. A parent with setting |
| 25 // of CONTENT_SETTING_DEFAULT can't be removed unless all its children are | 26 // of CONTENT_SETTING_DEFAULT can't be removed unless all its children are |
| 26 // also being removed. | 27 // also being removed. |
| 27 virtual bool CanRemoveRows(const Rows& rows) const; | 28 virtual bool CanRemoveRows(const Rows& rows) const; |
| 28 | 29 |
| 29 // Removes the exceptions at the specified indexes. If an exception is a | 30 // Removes the exceptions at the specified indexes. If an exception is a |
| 30 // parent, and it has children, the row in model will be updated to have | 31 // parent, and it has children, the row in model will be updated to have |
| 31 // CONTENT_SETTING_DEFAULT. If it is the only child of a | 32 // CONTENT_SETTING_DEFAULT. If it is the only child of a |
| 32 // CONTENT_SETTING_DEFAULT parent, the parent will be removed from the model | 33 // CONTENT_SETTING_DEFAULT parent, the parent will be removed from the model |
| 33 // too. | 34 // too. |
| 34 virtual void RemoveRows(const Rows& rows); | 35 virtual void RemoveRows(const Rows& rows); |
| 35 | 36 |
| 36 // Removes all the exceptions from both the map and model. | 37 // Removes all the exceptions from both the map and model. |
| 37 virtual void RemoveAll(); | 38 virtual void RemoveAll(); |
| 38 | 39 |
| 39 // TableModel overrides: | 40 // TableModel overrides: |
| 40 virtual int RowCount(); | 41 virtual int RowCount() OVERRIDE; |
| 41 virtual std::wstring GetText(int row, int column_id); | 42 virtual string16 GetText(int row, int column_id) OVERRIDE; |
| 42 virtual void SetObserver(TableModelObserver* observer); | 43 virtual void SetObserver(TableModelObserver* observer) OVERRIDE; |
| 43 virtual int CompareValues(int row1, int row2, int column_id); | 44 virtual int CompareValues(int row1, int row2, int column_id) OVERRIDE; |
| 44 | 45 |
| 45 private: | 46 private: |
| 46 void AddEntriesForOrigin( | 47 void AddEntriesForOrigin( |
| 47 const GURL& origin, | 48 const GURL& origin, |
| 48 const GeolocationContentSettingsMap::OneOriginSettings& settings); | 49 const GeolocationContentSettingsMap::OneOriginSettings& settings); |
| 49 | 50 |
| 50 GeolocationContentSettingsMap* map_; | 51 GeolocationContentSettingsMap* map_; |
| 51 | 52 |
| 52 struct Entry; | 53 struct Entry; |
| 53 typedef std::vector<Entry> EntriesVector; | 54 typedef std::vector<Entry> EntriesVector; |
| 54 EntriesVector entries_; | 55 EntriesVector entries_; |
| 55 | 56 |
| 56 TableModelObserver* observer_; | 57 TableModelObserver* observer_; |
| 57 | 58 |
| 58 DISALLOW_COPY_AND_ASSIGN(GeolocationExceptionsTableModel); | 59 DISALLOW_COPY_AND_ASSIGN(GeolocationExceptionsTableModel); |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_EXCEPTIONS_TABLE_MODEL_H_ | 62 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_EXCEPTIONS_TABLE_MODEL_H_ |
| OLD | NEW |