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

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

Issue 10821133: Move c/r/extensions/* into extensions namespace (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Latest master for cq Created 8 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
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/extension_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/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 #include "chrome/common/extensions/extension.h" 12 #include "chrome/common/extensions/extension.h"
13 #include "chrome/common/extensions/extension_set.h" 13 #include "chrome/common/extensions/extension_set.h"
14 #include "googleurl/src/gurl.h" 14 #include "googleurl/src/gurl.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
19 19
20 using extensions::Extension; 20 namespace extensions {
21 21
22 // static 22 // static
23 bool ExtensionResourceRequestPolicy::CanRequestResource( 23 bool ResourceRequestPolicy::CanRequestResource(
24 const GURL& resource_url, 24 const GURL& resource_url,
25 WebKit::WebFrame* frame, 25 WebKit::WebFrame* frame,
26 const ExtensionSet* loaded_extensions) { 26 const ExtensionSet* loaded_extensions) {
27 CHECK(resource_url.SchemeIs(chrome::kExtensionScheme)); 27 CHECK(resource_url.SchemeIs(chrome::kExtensionScheme));
28 28
29 const Extension* extension = 29 const Extension* extension =
30 loaded_extensions->GetExtensionOrAppByURL(ExtensionURLInfo(resource_url)); 30 loaded_extensions->GetExtensionOrAppByURL(ExtensionURLInfo(resource_url));
31 if (!extension) { 31 if (!extension) {
32 // Allow the load in the case of a non-existent extension. We'll just get a 32 // Allow the load in the case of a non-existent extension. We'll just get a
33 // 404 from the browser process. 33 // 404 from the browser process.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 WebKit::WebConsoleMessage(WebKit::WebConsoleMessage::LevelError, 77 WebKit::WebConsoleMessage(WebKit::WebConsoleMessage::LevelError,
78 WebKit::WebString::fromUTF8(message))); 78 WebKit::WebString::fromUTF8(message)));
79 return false; 79 return false;
80 } 80 }
81 } 81 }
82 82
83 return true; 83 return true;
84 } 84 }
85 85
86 // static 86 // static
87 bool ExtensionResourceRequestPolicy::CanRequestExtensionResourceScheme( 87 bool ResourceRequestPolicy::CanRequestExtensionResourceScheme(
88 const GURL& resource_url, 88 const GURL& resource_url,
89 WebKit::WebFrame* frame) { 89 WebKit::WebFrame* frame) {
90 CHECK(resource_url.SchemeIs(chrome::kExtensionResourceScheme)); 90 CHECK(resource_url.SchemeIs(chrome::kExtensionResourceScheme));
91 91
92 GURL frame_url = frame->document().url(); 92 GURL frame_url = frame->document().url();
93 if (!frame_url.is_empty() && 93 if (!frame_url.is_empty() &&
94 !frame_url.SchemeIs(chrome::kExtensionScheme)) { 94 !frame_url.SchemeIs(chrome::kExtensionScheme)) {
95 std::string message = base::StringPrintf( 95 std::string message = base::StringPrintf(
96 "Denying load of %s. chrome-extension-resources:// can only be " 96 "Denying load of %s. chrome-extension-resources:// can only be "
97 "loaded from extensions.", 97 "loaded from extensions.",
98 resource_url.spec().c_str()); 98 resource_url.spec().c_str());
99 frame->addMessageToConsole( 99 frame->addMessageToConsole(
100 WebKit::WebConsoleMessage(WebKit::WebConsoleMessage::LevelError, 100 WebKit::WebConsoleMessage(WebKit::WebConsoleMessage::LevelError,
101 WebKit::WebString::fromUTF8(message))); 101 WebKit::WebString::fromUTF8(message)));
102 return false; 102 return false;
103 } 103 }
104 104
105 return true; 105 return true;
106 } 106 }
107 107
108 ExtensionResourceRequestPolicy::ExtensionResourceRequestPolicy() { 108 ResourceRequestPolicy::ResourceRequestPolicy() {
109 } 109 }
110
111 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/resource_request_policy.h ('k') | chrome/renderer/extensions/runtime_custom_bindings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698