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

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

Issue 9909019: Add schema chrome-extension-resource:// for extension resources (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Update Created 8 years, 7 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
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/extensions/extension_resource_protocols.h"
6
7 #include "base/file_path.h"
8 #include "base/path_service.h"
9 #include "chrome/common/chrome_paths.h"
10 #include "chrome/common/extensions/extension_file_util.h"
11 #include "net/url_request/url_request_file_job.h"
12
13 namespace {
14
15 class ExtensionResourceProtocolHandler
16 : public net::URLRequestJobFactory::ProtocolHandler {
17 public:
18 ExtensionResourceProtocolHandler() {}
19 virtual ~ExtensionResourceProtocolHandler() {}
20
21 virtual net::URLRequestJob* MaybeCreateJob(
22 net::URLRequest* request) const OVERRIDE;
23
24 private:
25 DISALLOW_COPY_AND_ASSIGN(ExtensionResourceProtocolHandler);
26 };
27
28 class ExtensionResourcesJob : public net::URLRequestFileJob {
29 };
30
31 // Creates URLRequestJobs for chrome-extension-resource:// URLs.
32 net::URLRequestJob*
33 ExtensionResourceProtocolHandler::MaybeCreateJob(
34 net::URLRequest* request) const {
35 FilePath root_path;
36 PathService::Get(chrome::DIR_RESOURCES_EXTENSION, &root_path);
37 FilePath path;
38 {
39 base::ThreadRestrictions::ScopedAllowIO allow_io;
Elliot Glaysher 2012/05/17 19:23:41 The presubmit check is doing its job by complainin
Peng 2012/05/17 19:26:11 I can not find a easy way to fix it. :( Do you hav
40 path = extension_file_util::ExtensionResourceURLToFilePath(
41 request->url(), root_path);
42 }
43 return new net::URLRequestFileJob(request, path);
44 }
45
46 } // namespace
47
48 net::URLRequestJobFactory::ProtocolHandler*
49 CreateExtensionResourceProtocolHandler() {
50 return new ExtensionResourceProtocolHandler();
51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698