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