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

Side by Side Diff: chrome/renderer/extensions/resource_request_policy.cc

Issue 11821009: move 'web_accessible_resources' parsing out of Extension class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@url_parse
Patch Set: patch rebased Created 7 years, 11 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
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 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 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/renderer/extensions/resource_request_policy.h" 5 #include "chrome/renderer/extensions/resource_request_policy.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
11 #include "chrome/common/extensions/extension.h" 11 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/extensions/extension_set.h" 12 #include "chrome/common/extensions/extension_set.h"
13 #include "chrome/common/extensions/manifest_url_handler.h" 13 #include "chrome/common/extensions/manifest_url_handler.h"
14 #include "chrome/common/extensions/web_accessible_resources_handler.h"
14 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
15 #include "content/public/common/page_transition_types.h" 16 #include "content/public/common/page_transition_types.h"
16 #include "extensions/common/constants.h" 17 #include "extensions/common/constants.h"
17 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
18 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" 19 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
22 23
23 namespace extensions { 24 namespace extensions {
(...skipping 20 matching lines...) Expand all
44 // launchers. 45 // launchers.
45 std::string resource_root_relative_path = 46 std::string resource_root_relative_path =
46 resource_url.path().empty() ? "" : resource_url.path().substr(1); 47 resource_url.path().empty() ? "" : resource_url.path().substr(1);
47 if (extension->is_hosted_app() && 48 if (extension->is_hosted_app() &&
48 !extension->icons().ContainsPath(resource_root_relative_path)) { 49 !extension->icons().ContainsPath(resource_root_relative_path)) {
49 LOG(ERROR) << "Denying load of " << resource_url.spec() << " from " 50 LOG(ERROR) << "Denying load of " << resource_url.spec() << " from "
50 << "hosted app."; 51 << "hosted app.";
51 return false; 52 return false;
52 } 53 }
53 54
54 // Disallow loading of extension resources which are not explicitely listed 55 // Disallow loading of extension resources which are not explicitly listed
55 // as web accessible if the manifest version is 2 or greater. 56 // as web accessible if the manifest version is 2 or greater.
56 if (!extension->IsResourceWebAccessible(resource_url.path()) && 57 if (!WebAccessibleResourcesInfo::IsResourceWebAccessible(
58 extension, resource_url.path()) &&
57 !CommandLine::ForCurrentProcess()->HasSwitch( 59 !CommandLine::ForCurrentProcess()->HasSwitch(
58 switches::kDisableExtensionsResourceWhitelist)) { 60 switches::kDisableExtensionsResourceWhitelist)) {
59 GURL frame_url = frame->document().url(); 61 GURL frame_url = frame->document().url();
60 GURL page_url = frame->top()->document().url(); 62 GURL page_url = frame->top()->document().url();
61 63
62 // Exceptions are: 64 // Exceptions are:
63 // - empty origin (needed for some edge cases when we have empty origins) 65 // - empty origin (needed for some edge cases when we have empty origins)
64 bool is_empty_origin = frame_url.is_empty(); 66 bool is_empty_origin = frame_url.is_empty();
65 // - extensions requesting their own resources (frame_url check is for 67 // - extensions requesting their own resources (frame_url check is for
66 // images, page_url check is for iframes) 68 // images, page_url check is for iframes)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 return false; 114 return false;
113 } 115 }
114 116
115 return true; 117 return true;
116 } 118 }
117 119
118 ResourceRequestPolicy::ResourceRequestPolicy() { 120 ResourceRequestPolicy::ResourceRequestPolicy() {
119 } 121 }
120 122
121 } // namespace extensions 123 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/chrome_content_renderer_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698