geolocation_exceptions_table_model.h revision 731df977c0511bca2206b5f333555b1205ff1f43
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 "chrome/browser/geolocation/geolocation_content_settings_map.h"
12#include "chrome/browser/remove_rows_table_model.h"
13#include "chrome/common/content_settings.h"
14#include "chrome/common/content_settings_types.h"
15
16class GeolocationExceptionsTableModel : public RemoveRowsTableModel {
17 public:
18  explicit GeolocationExceptionsTableModel(
19      GeolocationContentSettingsMap* map);
20  virtual ~GeolocationExceptionsTableModel();
21
22  // RemoveRowsTableModel overrides:
23
24  // 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  // also being removed.
27  virtual bool CanRemoveRows(const Rows& rows) const;
28
29  // 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  // 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  // too.
34  virtual void RemoveRows(const Rows& rows);
35
36  // Removes all the exceptions from both the map and model.
37  virtual void RemoveAll();
38
39  // TableModel overrides:
40  virtual int RowCount();
41  virtual std::wstring GetText(int row, int column_id);
42  virtual void SetObserver(TableModelObserver* observer);
43  virtual int CompareValues(int row1, int row2, int column_id);
44
45 private:
46  void AddEntriesForOrigin(
47      const GURL& origin,
48      const GeolocationContentSettingsMap::OneOriginSettings& settings);
49
50  GeolocationContentSettingsMap* map_;
51
52  struct Entry;
53  typedef std::vector<Entry> EntriesVector;
54  EntriesVector entries_;
55
56  TableModelObserver* observer_;
57
58  DISALLOW_COPY_AND_ASSIGN(GeolocationExceptionsTableModel);
59};
60
61#endif  // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_EXCEPTIONS_TABLE_MODEL_H_
62