| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/extension_special_storage_policy.h" | 5 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 17 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
| 18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 19 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 20 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
| 21 #include "components/content_settings/core/browser/cookie_settings.h" | 21 #include "components/content_settings/core/browser/cookie_settings.h" |
| 22 #include "components/content_settings/core/common/content_settings.h" | 22 #include "components/content_settings/core/common/content_settings.h" |
| 23 #include "components/content_settings/core/common/content_settings_types.h" | 23 #include "components/content_settings/core/common/content_settings_types.h" |
| 24 #include "components/content_settings/core/common/content_settings_utils.h" |
| 24 #include "content/public/browser/browser_context.h" | 25 #include "content/public/browser/browser_context.h" |
| 25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 26 #include "content/public/browser/storage_partition.h" | 27 #include "content/public/browser/storage_partition.h" |
| 27 #include "content/public/common/url_constants.h" | 28 #include "content/public/common/url_constants.h" |
| 28 #include "extensions/common/constants.h" | 29 #include "extensions/common/constants.h" |
| 29 #include "extensions/common/extension.h" | 30 #include "extensions/common/extension.h" |
| 30 #include "extensions/common/extension_set.h" | 31 #include "extensions/common/extension_set.h" |
| 31 #include "extensions/common/manifest_handlers/app_isolation_info.h" | 32 #include "extensions/common/manifest_handlers/app_isolation_info.h" |
| 32 #include "extensions/common/manifest_handlers/content_capabilities_handler.h" | 33 #include "extensions/common/manifest_handlers/content_capabilities_handler.h" |
| 33 #include "extensions/common/permissions/permissions_data.h" | 34 #include "extensions/common/permissions/permissions_data.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 117 |
| 117 bool ExtensionSpecialStoragePolicy::HasSessionOnlyOrigins() { | 118 bool ExtensionSpecialStoragePolicy::HasSessionOnlyOrigins() { |
| 118 if (cookie_settings_.get() == NULL) | 119 if (cookie_settings_.get() == NULL) |
| 119 return false; | 120 return false; |
| 120 if (cookie_settings_->GetDefaultCookieSetting(NULL) == | 121 if (cookie_settings_->GetDefaultCookieSetting(NULL) == |
| 121 CONTENT_SETTING_SESSION_ONLY) | 122 CONTENT_SETTING_SESSION_ONLY) |
| 122 return true; | 123 return true; |
| 123 ContentSettingsForOneType entries; | 124 ContentSettingsForOneType entries; |
| 124 cookie_settings_->GetCookieSettings(&entries); | 125 cookie_settings_->GetCookieSettings(&entries); |
| 125 for (size_t i = 0; i < entries.size(); ++i) { | 126 for (size_t i = 0; i < entries.size(); ++i) { |
| 126 if (entries[i].setting == CONTENT_SETTING_SESSION_ONLY) | 127 if (content_settings::ValueToContentSetting( |
| 128 entries[i].setting_value.get()) == CONTENT_SETTING_SESSION_ONLY) { |
| 127 return true; | 129 return true; |
| 130 } |
| 128 } | 131 } |
| 129 return false; | 132 return false; |
| 130 } | 133 } |
| 131 | 134 |
| 132 bool ExtensionSpecialStoragePolicy::HasIsolatedStorage(const GURL& origin) { | 135 bool ExtensionSpecialStoragePolicy::HasIsolatedStorage(const GURL& origin) { |
| 133 base::AutoLock locker(lock_); | 136 base::AutoLock locker(lock_); |
| 134 return isolated_extensions_.Contains(origin); | 137 return isolated_extensions_.Contains(origin); |
| 135 } | 138 } |
| 136 | 139 |
| 137 bool ExtensionSpecialStoragePolicy::IsStorageDurable(const GURL& origin) { | 140 bool ExtensionSpecialStoragePolicy::IsStorageDurable(const GURL& origin) { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } | 346 } |
| 344 | 347 |
| 345 void ExtensionSpecialStoragePolicy::SpecialCollection::Clear() { | 348 void ExtensionSpecialStoragePolicy::SpecialCollection::Clear() { |
| 346 ClearCache(); | 349 ClearCache(); |
| 347 extensions_.Clear(); | 350 extensions_.Clear(); |
| 348 } | 351 } |
| 349 | 352 |
| 350 void ExtensionSpecialStoragePolicy::SpecialCollection::ClearCache() { | 353 void ExtensionSpecialStoragePolicy::SpecialCollection::ClearCache() { |
| 351 cached_results_.clear(); | 354 cached_results_.clear(); |
| 352 } | 355 } |
| OLD | NEW |