OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "components/content_settings/core/browser/content_settings_usages_state
.h" | 5 #include "components/content_settings/core/browser/content_settings_usages_state
.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "components/content_settings/core/browser/host_content_settings_map.h" | 10 #include "components/content_settings/core/browser/host_content_settings_map.h" |
11 #include "components/prefs/pref_service.h" | |
12 #include "components/url_formatter/url_formatter.h" | 11 #include "components/url_formatter/url_formatter.h" |
13 | 12 |
14 ContentSettingsUsagesState::CommittedDetails::CommittedDetails() | 13 ContentSettingsUsagesState::CommittedDetails::CommittedDetails() |
15 : current_url_valid(false) { | 14 : current_url_valid(false) { |
16 } | 15 } |
17 | 16 |
18 ContentSettingsUsagesState::CommittedDetails::~CommittedDetails() {} | 17 ContentSettingsUsagesState::CommittedDetails::~CommittedDetails() {} |
19 | 18 |
20 ContentSettingsUsagesState::ContentSettingsUsagesState( | 19 ContentSettingsUsagesState::ContentSettingsUsagesState( |
21 HostContentSettingsMap* host_content_settings_map, | 20 HostContentSettingsMap* host_content_settings_map, |
22 ContentSettingsType type, | 21 ContentSettingsType type) |
23 const std::string& accept_language_pref, | |
24 PrefService* prefs) | |
25 : host_content_settings_map_(host_content_settings_map), | 22 : host_content_settings_map_(host_content_settings_map), |
26 pref_service_(prefs), | |
27 accept_language_pref_(accept_language_pref), | |
28 type_(type) { | 23 type_(type) { |
29 } | 24 } |
30 | 25 |
31 ContentSettingsUsagesState::~ContentSettingsUsagesState() { | 26 ContentSettingsUsagesState::~ContentSettingsUsagesState() { |
32 } | 27 } |
33 | 28 |
34 void ContentSettingsUsagesState::OnPermissionSet( | 29 void ContentSettingsUsagesState::OnPermissionSet( |
35 const GURL& requesting_origin, bool allowed) { | 30 const GURL& requesting_origin, bool allowed) { |
36 state_map_[requesting_origin] = | 31 state_map_[requesting_origin] = |
37 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; | 32 allowed ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 if (saved_setting != i->second) | 94 if (saved_setting != i->second) |
100 *tab_state_flags |= TABSTATE_HAS_CHANGED; | 95 *tab_state_flags |= TABSTATE_HAS_CHANGED; |
101 if (saved_setting != CONTENT_SETTING_ASK) | 96 if (saved_setting != CONTENT_SETTING_ASK) |
102 *tab_state_flags |= TABSTATE_HAS_ANY_ICON; | 97 *tab_state_flags |= TABSTATE_HAS_ANY_ICON; |
103 } | 98 } |
104 } | 99 } |
105 | 100 |
106 std::string ContentSettingsUsagesState::GURLToFormattedHost( | 101 std::string ContentSettingsUsagesState::GURLToFormattedHost( |
107 const GURL& url) const { | 102 const GURL& url) const { |
108 base::string16 display_host; | 103 base::string16 display_host; |
109 url_formatter::AppendFormattedHost( | 104 url_formatter::AppendFormattedHost(url, &display_host); |
110 url, pref_service_->GetString(accept_language_pref_), &display_host); | |
111 return base::UTF16ToUTF8(display_host); | 105 return base::UTF16ToUTF8(display_host); |
112 } | 106 } |
OLD | NEW |