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

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

Issue 10805015: Move browsing_data_helper files into a separate directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix chrome_frame build Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/browsing_data_helper.h"
6
7 #include "base/command_line.h"
8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/extensions/extension_special_storage_policy.h"
10 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/url_constants.h"
12 #include "content/public/browser/child_process_security_policy.h"
13 #include "googleurl/src/gurl.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
15
16 // Static
17 bool BrowsingDataHelper::IsWebScheme(const std::string& scheme) {
18 // Special-case `file://` scheme iff cookies and site data are enabled via
19 // the `--allow-file-cookies` CLI flag.
20 if (scheme == chrome::kFileScheme) {
21 return CommandLine::ForCurrentProcess()->HasSwitch(
22 switches::kEnableFileCookies);
23
24 // Otherwise, all "web safe" schemes are valid, except `chrome-extension://`
25 // and `chrome-devtools://`.
26 } else {
27 content::ChildProcessSecurityPolicy* policy =
28 content::ChildProcessSecurityPolicy::GetInstance();
29 return (policy->IsWebSafeScheme(scheme) &&
30 !BrowsingDataHelper::IsExtensionScheme(scheme) &&
31 scheme != chrome::kChromeDevToolsScheme);
32 }
33 }
34
35 // Static
36 bool BrowsingDataHelper::IsWebScheme(const WebKit::WebString& scheme) {
37 return BrowsingDataHelper::IsWebScheme(UTF16ToUTF8(scheme));
38 }
39
40 // Static
41 bool BrowsingDataHelper::HasWebScheme(const GURL& origin) {
42 return BrowsingDataHelper::IsWebScheme(origin.scheme());
43 }
44
45 // Static
46 bool BrowsingDataHelper::IsExtensionScheme(const std::string& scheme) {
47 return scheme == chrome::kExtensionScheme;
48 }
49
50 // Static
51 bool BrowsingDataHelper::IsExtensionScheme(const WebKit::WebString& scheme) {
52 return BrowsingDataHelper::IsExtensionScheme(UTF16ToUTF8(scheme));
53 }
54
55 // Static
56 bool BrowsingDataHelper::HasExtensionScheme(const GURL& origin) {
57 return BrowsingDataHelper::IsExtensionScheme(origin.scheme());
58 }
59
60 // Static
61 bool BrowsingDataHelper::DoesOriginMatchMask(const GURL& origin,
62 int origin_set_mask, ExtensionSpecialStoragePolicy* policy) {
63 // Packaged apps and extensions match iff EXTENSION.
64 if (BrowsingDataHelper::HasExtensionScheme(origin.GetOrigin()) &&
65 origin_set_mask & EXTENSION)
66 return true;
67
68 // If a websafe origin is unprotected, it matches iff UNPROTECTED_WEB.
69 if (!policy->IsStorageProtected(origin.GetOrigin()) &&
70 BrowsingDataHelper::HasWebScheme(origin.GetOrigin()) &&
71 origin_set_mask & UNPROTECTED_WEB)
72 return true;
73
74 // Hosted applications (protected and websafe origins) iff PROTECTED_WEB.
75 if (policy->IsStorageProtected(origin.GetOrigin()) &&
76 BrowsingDataHelper::HasWebScheme(origin.GetOrigin()) &&
77 origin_set_mask & PROTECTED_WEB)
78 return true;
79
80 return false;
81 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data_helper.h ('k') | chrome/browser/browsing_data_helper_browsertest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698