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

Side by Side Diff: chrome/browser/extensions/extension_protocols.cc

Issue 31008: Coalesce more hardcoded schemes to using predefined constants. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension.cc ('k') | chrome/browser/extensions/user_script_master.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_protocols.h" 5 #include "chrome/browser/extensions/extension_protocols.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/browser/extensions/extension.h" 8 #include "chrome/browser/extensions/extension.h"
9 #include "chrome/browser/net/chrome_url_request_context.h" 9 #include "chrome/browser/net/chrome_url_request_context.h"
10 #include "chrome/common/url_constants.h"
10 #include "googleurl/src/url_util.h" 11 #include "googleurl/src/url_util.h"
11 #include "net/base/net_util.h" 12 #include "net/base/net_util.h"
12 #include "net/url_request/url_request_file_job.h" 13 #include "net/url_request/url_request_file_job.h"
13 14
14 // Defined in extension.h.
15 extern const char kExtensionURLScheme[];
16 extern const char kUserScriptURLScheme[];
17
18 // Factory registered with URLRequest to create URLRequestJobs for extension:// 15 // Factory registered with URLRequest to create URLRequestJobs for extension://
19 // URLs. 16 // URLs.
20 static URLRequestJob* CreateExtensionURLRequestJob(URLRequest* request, 17 static URLRequestJob* CreateExtensionURLRequestJob(URLRequest* request,
21 const std::string& scheme) { 18 const std::string& scheme) {
22 ChromeURLRequestContext* context = 19 ChromeURLRequestContext* context =
23 static_cast<ChromeURLRequestContext*>(request->context()); 20 static_cast<ChromeURLRequestContext*>(request->context());
24 21
25 // chrome-extension://extension-id/resource/path.js 22 // chrome-extension://extension-id/resource/path.js
26 FilePath directory_path = context->GetPathForExtension(request->url().host()); 23 FilePath directory_path = context->GetPathForExtension(request->url().host());
27 if (directory_path.value().empty()) 24 if (directory_path.value().empty())
(...skipping 16 matching lines...) Expand all
44 FilePath directory_path = context->user_script_dir_path(); 41 FilePath directory_path = context->user_script_dir_path();
45 std::string resource = request->url().path(); 42 std::string resource = request->url().path();
46 43
47 FilePath path = Extension::GetResourcePath(directory_path, resource); 44 FilePath path = Extension::GetResourcePath(directory_path, resource);
48 return new URLRequestFileJob(request, path); 45 return new URLRequestFileJob(request, path);
49 } 46 }
50 47
51 void RegisterExtensionProtocols() { 48 void RegisterExtensionProtocols() {
52 // Being a standard scheme allows us to resolve relative paths. This is used 49 // Being a standard scheme allows us to resolve relative paths. This is used
53 // by extensions, but not by standalone user scripts. 50 // by extensions, but not by standalone user scripts.
54 url_util::AddStandardScheme(kExtensionURLScheme); 51 url_util::AddStandardScheme(chrome::kExtensionScheme);
55 52
56 URLRequest::RegisterProtocolFactory(kExtensionURLScheme, 53 URLRequest::RegisterProtocolFactory(chrome::kExtensionScheme,
57 &CreateExtensionURLRequestJob); 54 &CreateExtensionURLRequestJob);
58 URLRequest::RegisterProtocolFactory(kUserScriptURLScheme, 55 URLRequest::RegisterProtocolFactory(chrome::kUserScriptScheme,
59 &CreateUserScriptURLRequestJob); 56 &CreateUserScriptURLRequestJob);
60 } 57 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension.cc ('k') | chrome/browser/extensions/user_script_master.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698