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

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

Issue 3116011: Revert 56059 - Merge 55103 - Refactored extension privilege enumeration and i... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Created 10 years, 4 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
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 } // namespace 68 } // namespace
69 69
70 // Factory registered with URLRequest to create URLRequestJobs for extension:// 70 // Factory registered with URLRequest to create URLRequestJobs for extension://
71 // URLs. 71 // URLs.
72 static URLRequestJob* CreateExtensionURLRequestJob(URLRequest* request, 72 static URLRequestJob* CreateExtensionURLRequestJob(URLRequest* request,
73 const std::string& scheme) { 73 const std::string& scheme) {
74 ChromeURLRequestContext* context = 74 ChromeURLRequestContext* context =
75 static_cast<ChromeURLRequestContext*>(request->context()); 75 static_cast<ChromeURLRequestContext*>(request->context());
76 76
77 // Don't allow toplevel navigations to extension resources in incognito mode.
78 // This is because an extension must run in a single process, and an incognito
79 // tab prevents that.
80 // TODO(mpcomplete): better error code.
77 const ResourceDispatcherHostRequestInfo* info = 81 const ResourceDispatcherHostRequestInfo* info =
78 ResourceDispatcherHost::InfoForRequest(request); 82 ResourceDispatcherHost::InfoForRequest(request);
79
80 // Don't allow extension resources to be loaded from origins which are not
81 // present in the extension's effective host permissions with the exception
82 // of empty origins and extension schemes.
83 if (!info->frame_origin().empty() &&
84 !GURL(info->frame_origin()).SchemeIs(chrome::kExtensionScheme)) {
85 ExtensionExtent host_permissions =
86 context->GetEffectiveHostPermissionsForExtension(request->url().host());
87 if (!host_permissions.ContainsURL(GURL(info->frame_origin())))
88 return new URLRequestErrorJob(request, net::ERR_ADDRESS_UNREACHABLE);
89 }
90
91 // Don't allow toplevel navigations to extension resources in incognito mode.
92 // This is because an extension must run in a single process, and an
93 // incognito tab prevents that.
94 // TODO(mpcomplete): better error code.
95 if (context->is_off_the_record() && 83 if (context->is_off_the_record() &&
96 info && info->resource_type() == ResourceType::MAIN_FRAME) 84 info && info->resource_type() == ResourceType::MAIN_FRAME)
97 return new URLRequestErrorJob(request, net::ERR_ADDRESS_UNREACHABLE); 85 return new URLRequestErrorJob(request, net::ERR_ADDRESS_UNREACHABLE);
98 86
99 // chrome-extension://extension-id/resource/path.js 87 // chrome-extension://extension-id/resource/path.js
100 const std::string& extension_id = request->url().host(); 88 const std::string& extension_id = request->url().host();
101 FilePath directory_path = context->GetPathForExtension(extension_id); 89 FilePath directory_path = context->GetPathForExtension(extension_id);
102 if (directory_path.value().empty()) { 90 if (directory_path.value().empty()) {
103 LOG(WARNING) << "Failed to GetPathForExtension: " << extension_id; 91 LOG(WARNING) << "Failed to GetPathForExtension: " << extension_id;
104 return NULL; 92 return NULL;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 140
153 return new URLRequestFileJob(request, resource.GetFilePath()); 141 return new URLRequestFileJob(request, resource.GetFilePath());
154 } 142 }
155 143
156 void RegisterExtensionProtocols() { 144 void RegisterExtensionProtocols() {
157 URLRequest::RegisterProtocolFactory(chrome::kExtensionScheme, 145 URLRequest::RegisterProtocolFactory(chrome::kExtensionScheme,
158 &CreateExtensionURLRequestJob); 146 &CreateExtensionURLRequestJob);
159 URLRequest::RegisterProtocolFactory(chrome::kUserScriptScheme, 147 URLRequest::RegisterProtocolFactory(chrome::kUserScriptScheme,
160 &CreateUserScriptURLRequestJob); 148 &CreateUserScriptURLRequestJob);
161 } 149 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_ui.cc ('k') | chrome/browser/net/chrome_url_request_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698