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

Side by Side Diff: content/common/url_constants.cc

Issue 8159006: Move kExtensionScheme from content to chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 years, 2 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
« no previous file with comments | « content/common/url_constants.h ('k') | content/renderer/render_view.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/common/url_constants.h" 5 #include "content/common/url_constants.h"
6 6
7 #include <stdio.h> 7 #include "base/string_util.h"
8 #include "googleurl/src/url_util.h"
9
10 namespace {
11 const char* kDefaultSavableSchemes[] = {
12 chrome::kHttpScheme,
13 chrome::kHttpsScheme,
14 chrome::kFileScheme,
15 chrome::kFtpScheme,
16 chrome::kChromeDevToolsScheme,
17 chrome::kChromeUIScheme,
18 NULL
19 };
20 char** g_savable_schemes = const_cast<char**>(kDefaultSavableSchemes);
21 } // namespace
8 22
9 namespace chrome { 23 namespace chrome {
10 24
11 const char* kSavableSchemes[] = {
12 kHttpScheme,
13 kHttpsScheme,
14 kFileScheme,
15 kFtpScheme,
16 kExtensionScheme,
17 kChromeDevToolsScheme,
18 kChromeUIScheme,
19 NULL
20 };
21
22 const char kAboutScheme[] = "about"; 25 const char kAboutScheme[] = "about";
23 const char kBlobScheme[] = "blob"; 26 const char kBlobScheme[] = "blob";
24 27
25 // Before adding new chrome schemes please check with security@chromium.org. 28 // Before adding new chrome schemes please check with security@chromium.org.
26 // There are security implications associated with introducing new schemes. 29 // There are security implications associated with introducing new schemes.
27 const char kChromeDevToolsScheme[] = "chrome-devtools"; 30 const char kChromeDevToolsScheme[] = "chrome-devtools";
28 const char kChromeInternalScheme[] = "chrome-internal"; 31 const char kChromeInternalScheme[] = "chrome-internal";
29 const char kChromeUIScheme[] = "chrome"; 32 const char kChromeUIScheme[] = "chrome";
30 const char kDataScheme[] = "data"; 33 const char kDataScheme[] = "data";
31 const char kExtensionScheme[] = "chrome-extension";
32 const char kFileScheme[] = "file"; 34 const char kFileScheme[] = "file";
33 const char kFileSystemScheme[] = "filesystem"; 35 const char kFileSystemScheme[] = "filesystem";
34 const char kFtpScheme[] = "ftp"; 36 const char kFtpScheme[] = "ftp";
35 const char kHttpScheme[] = "http"; 37 const char kHttpScheme[] = "http";
36 const char kHttpsScheme[] = "https"; 38 const char kHttpsScheme[] = "https";
37 const char kJavaScriptScheme[] = "javascript"; 39 const char kJavaScriptScheme[] = "javascript";
38 const char kMailToScheme[] = "mailto"; 40 const char kMailToScheme[] = "mailto";
39 const char kMetadataScheme[] = "metadata"; 41 const char kMetadataScheme[] = "metadata";
40 const char kViewSourceScheme[] = "view-source"; 42 const char kViewSourceScheme[] = "view-source";
41 43
42 const char kStandardSchemeSeparator[] = "://"; 44 const char kStandardSchemeSeparator[] = "://";
43 45
44 const char kAboutBlankURL[] = "about:blank"; 46 const char kAboutBlankURL[] = "about:blank";
45 const char kAboutCrashURL[] = "about:crash"; 47 const char kAboutCrashURL[] = "about:crash";
46 48
47 const char kUnreachableWebDataURL[] = "chrome://chromewebdata/"; 49 const char kUnreachableWebDataURL[] = "chrome://chromewebdata/";
48 50
51 const char** GetSavableSchemes() {
52 return const_cast<const char**>(g_savable_schemes);
53 }
54
55 void RegisterContentSchemes(const char** additional_savable_schemes) {
56 // Don't need "chrome-internal" which was used in old versions of Chrome for
57 // the new tab page.
58 url_util::AddStandardScheme(kChromeDevToolsScheme);
59 url_util::AddStandardScheme(kChromeUIScheme);
60 url_util::AddStandardScheme(kMetadataScheme);
61
62 // Prevent future modification of the standard schemes list. This is to
63 // prevent accidental creation of data races in the program. AddStandardScheme
64 // isn't threadsafe so must be called when GURL isn't used on any other
65 // thread. This is really easy to mess up, so we say that all calls to
66 // AddStandardScheme in Chrome must be inside this function.
67 url_util::LockStandardSchemes();
68
69 // We rely on the above lock to protect this part from being invoked twice.
70 if (additional_savable_schemes) {
71 int schemes = 0;
72 while (additional_savable_schemes[++schemes]);
73 // The array, and the copied schemes won't be freed, but will remain
74 // reachable.
75 g_savable_schemes = new char*[schemes + arraysize(kDefaultSavableSchemes)];
76 memcpy(g_savable_schemes,
77 kDefaultSavableSchemes,
78 arraysize(kDefaultSavableSchemes) * sizeof(char*));
79 for (int i = 0; i < schemes; ++i) {
80 g_savable_schemes[arraysize(kDefaultSavableSchemes) + i - 1] =
81 base::strdup(additional_savable_schemes[i]);
82 }
83 g_savable_schemes[arraysize(kDefaultSavableSchemes) + schemes - 1] = 0;
84 }
85 }
86
49 } // namespace chrome 87 } // namespace chrome
OLDNEW
« no previous file with comments | « content/common/url_constants.h ('k') | content/renderer/render_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698