Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(853)

Side by Side Diff: chrome/browser/browsing_data/browsing_data_helper.cc

Issue 2661543003: Introduce the concept of web schemes capable of storage (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/browsing_data/browsing_data_helper_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/browsing_data_helper.h" 5 #include "chrome/browser/browsing_data/browsing_data_helper.h"
6 6
7 #include <vector>
8
7 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/common/url_constants.h"
9 #include "content/public/browser/child_process_security_policy.h"
10 #include "extensions/common/constants.h" 10 #include "extensions/common/constants.h"
11 #include "storage/browser/quota/special_storage_policy.h" 11 #include "storage/browser/quota/special_storage_policy.h"
12 #include "url/gurl.h" 12 #include "url/gurl.h"
13 #include "url/url_util.h"
13 14
14 // Static 15 // Static
15 bool BrowsingDataHelper::IsWebScheme(const std::string& scheme) { 16 bool BrowsingDataHelper::IsWebScheme(const std::string& scheme) {
16 // All "web safe" schemes are valid, except `chrome-extension://` 17 const std::vector<std::string>& schemes = url::GetWebStorageSchemes();
17 // and `chrome-devtools://`. 18 return std::find(schemes.begin(), schemes.end(), scheme) != schemes.end();
18 content::ChildProcessSecurityPolicy* policy =
19 content::ChildProcessSecurityPolicy::GetInstance();
20 return (policy->IsWebSafeScheme(scheme) &&
21 !BrowsingDataHelper::IsExtensionScheme(scheme) &&
22 scheme != content::kChromeDevToolsScheme);
23 } 19 }
24 20
25 // Static 21 // Static
26 bool BrowsingDataHelper::HasWebScheme(const GURL& origin) { 22 bool BrowsingDataHelper::HasWebScheme(const GURL& origin) {
27 return BrowsingDataHelper::IsWebScheme(origin.scheme()); 23 return BrowsingDataHelper::IsWebScheme(origin.scheme());
28 } 24 }
29 25
30 // Static 26 // Static
31 bool BrowsingDataHelper::IsExtensionScheme(const std::string& scheme) { 27 bool BrowsingDataHelper::IsExtensionScheme(const std::string& scheme) {
32 return scheme == extensions::kExtensionScheme; 28 return scheme == extensions::kExtensionScheme;
(...skipping 22 matching lines...) Expand all
55 51
56 // Hosted applications (protected and websafe origins) iff PROTECTED_WEB. 52 // Hosted applications (protected and websafe origins) iff PROTECTED_WEB.
57 if (policy && 53 if (policy &&
58 policy->IsStorageProtected(origin.GetOrigin()) && 54 policy->IsStorageProtected(origin.GetOrigin()) &&
59 BrowsingDataHelper::HasWebScheme(origin.GetOrigin()) && 55 BrowsingDataHelper::HasWebScheme(origin.GetOrigin()) &&
60 origin_type_mask & PROTECTED_WEB) 56 origin_type_mask & PROTECTED_WEB)
61 return true; 57 return true;
62 58
63 return false; 59 return false;
64 } 60 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browsing_data/browsing_data_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698