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// The details send with notifications about content setting changes.
6
7#ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_
8#define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_
9#pragma once
10
11#include "base/basictypes.h"
12#include "chrome/browser/content_settings/content_settings_pattern.h"
13#include "chrome/common/content_settings.h"
14
15// Details for the CONTENT_SETTINGS_CHANGED notification. This is sent when
16// content settings change for at least one host. If settings change for more
17// than one pattern in one user interaction, this will usually send a single
18// notification with update_all() returning true instead of one notification
19// for each pattern.
20class ContentSettingsDetails {
21 public:
22  // Update the setting that matches this pattern/content type/resource.
23  ContentSettingsDetails(const ContentSettingsPattern& pattern,
24                         ContentSettingsType type,
25                         const std::string& resource_identifier)
26      : pattern_(pattern),
27        type_(type),
28        resource_identifier_(resource_identifier) {}
29
30  // The pattern whose settings have changed.
31  const ContentSettingsPattern& pattern() const { return pattern_; }
32
33  // True if all settings should be updated for the given type.
34  bool update_all() const { return pattern_.AsString().empty(); }
35
36  // The type of the pattern whose settings have changed.
37  ContentSettingsType type() const { return type_; }
38
39  // The resource identifier for the settings type that has changed.
40  const std::string& resource_identifier() const {
41    return resource_identifier_;
42  }
43
44  // True if all types should be updated. If update_all() is false, this will
45  // be false as well (although the reverse does not hold true).
46  bool update_all_types() const {
47    return CONTENT_SETTINGS_TYPE_DEFAULT == type_;
48  }
49
50 private:
51  ContentSettingsPattern pattern_;
52  ContentSettingsType type_;
53  std::string resource_identifier_;
54};
55
56#endif  // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_
57