Chromium Code Reviews| 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/browsing_data_helper.h" | 5 #include "chrome/browser/browsing_data_helper.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/extensions/extension_special_storage_policy.h" | |
| 9 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
| 11 #include "content/public/browser/child_process_security_policy.h" | 12 #include "content/public/browser/child_process_security_policy.h" |
| 12 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 14 | 15 |
| 15 // Static | 16 // Static |
| 16 bool BrowsingDataHelper::IsValidScheme(const std::string& scheme) { | 17 bool BrowsingDataHelper::IsValidScheme(const std::string& scheme) { |
| 17 // Special-case `file://` scheme iff cookies and site data are enabled via | 18 // Special-case `file://` scheme iff cookies and site data are enabled via |
| 18 // the `--allow-file-cookies` CLI flag. | 19 // the `--allow-file-cookies` CLI flag. |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 33 | 34 |
| 34 // Static | 35 // Static |
| 35 bool BrowsingDataHelper::IsValidScheme(const WebKit::WebString& scheme) { | 36 bool BrowsingDataHelper::IsValidScheme(const WebKit::WebString& scheme) { |
| 36 return BrowsingDataHelper::IsValidScheme(UTF16ToUTF8(scheme)); | 37 return BrowsingDataHelper::IsValidScheme(UTF16ToUTF8(scheme)); |
| 37 } | 38 } |
| 38 | 39 |
| 39 // Static | 40 // Static |
| 40 bool BrowsingDataHelper::HasValidScheme(const GURL& origin) { | 41 bool BrowsingDataHelper::HasValidScheme(const GURL& origin) { |
| 41 return BrowsingDataHelper::IsValidScheme(origin.scheme()); | 42 return BrowsingDataHelper::IsValidScheme(origin.scheme()); |
| 42 } | 43 } |
| 44 | |
| 45 // Static | |
| 46 bool BrowsingDataHelper::DoesOriginMatchMask(const GURL& origin, | |
| 47 int origin_set_mask, ExtensionSpecialStoragePolicy* policy) { | |
| 48 // If a websafe origin is unprotected, it matches iff UNPROTECTED_WEB. | |
| 49 if (!policy->IsStorageProtected(origin.GetOrigin()) && | |
| 50 BrowsingDataHelper::HasValidScheme(origin.GetOrigin()) && | |
| 51 origin_set_mask & UNPROTECTED_WEB) | |
| 52 return true; | |
| 53 | |
| 54 // Packaged apps and extensions match iff EXTENSION. | |
| 55 if (!BrowsingDataHelper::HasValidScheme(origin.GetOrigin()) && | |
|
Bernhard Bauer
2012/05/31 15:57:31
Could you change this check to just `origin.scheme
Mike West
2012/06/01 13:35:17
Running with `isWebScheme` and `isExtensionScheme`
| |
| 56 origin_set_mask & EXTENSION) | |
| 57 return true; | |
| 58 | |
| 59 // Hosted applications (protected and websafe origins) iff PROTECTED_WEB. | |
| 60 if (policy->IsStorageProtected(origin.GetOrigin()) && | |
| 61 BrowsingDataHelper::HasValidScheme(origin.GetOrigin()) && | |
| 62 origin_set_mask & PROTECTED_WEB) | |
| 63 return true; | |
| 64 | |
| 65 return false; | |
| 66 } | |
| OLD | NEW |