Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / content_settings / content_settings_details.h
1 // Copyright (c) 2011 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_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "chrome/common/content_settings.h"
12 #include "chrome/common/content_settings_pattern.h"
13 #include "components/content_settings/core/common/content_settings_types.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.
20 class ContentSettingsDetails {
21  public:
22   // Update the setting that matches this pattern/content type/resource.
23   ContentSettingsDetails(const ContentSettingsPattern& primary_pattern,
24                          const ContentSettingsPattern& secondary_pattern,
25                          ContentSettingsType type,
26                          const std::string& resource_identifier);
27
28   // The item pattern whose settings have changed.
29   const ContentSettingsPattern& primary_pattern() const {
30     return primary_pattern_;
31   }
32
33   // The top level frame pattern whose settings have changed.
34   const ContentSettingsPattern& secondary_pattern() const {
35     return secondary_pattern_;
36   }
37
38   // True if all settings should be updated for the given type.
39   bool update_all() const {
40     return primary_pattern_.ToString().empty() &&
41            secondary_pattern_.ToString().empty();
42   }
43
44   // The type of the pattern whose settings have changed.
45   ContentSettingsType type() const { return type_; }
46
47   // The resource identifier for the settings type that has changed.
48   const std::string& resource_identifier() const {
49     return resource_identifier_;
50   }
51
52   // True if all types should be updated. If update_all() is false, this will
53   // be false as well (although the reverse does not hold true).
54   bool update_all_types() const {
55     return CONTENT_SETTINGS_TYPE_DEFAULT == type_;
56   }
57
58  private:
59   ContentSettingsPattern primary_pattern_;
60   ContentSettingsPattern secondary_pattern_;
61   ContentSettingsType type_;
62   std::string resource_identifier_;
63
64   DISALLOW_COPY_AND_ASSIGN(ContentSettingsDetails);
65 };
66
67 #endif  // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_DETAILS_H_