OLD | NEW |
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" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // - extensions requesting their own resources (frame_url check is for | 63 // - extensions requesting their own resources (frame_url check is for |
64 // images, page_url check is for iframes) | 64 // images, page_url check is for iframes) |
65 bool is_own_resource = frame_url.GetOrigin() == extension->url() || | 65 bool is_own_resource = frame_url.GetOrigin() == extension->url() || |
66 page_url.GetOrigin() == extension->url(); | 66 page_url.GetOrigin() == extension->url(); |
67 // - devtools (chrome-extension:// URLs are loaded into frames of devtools | 67 // - devtools (chrome-extension:// URLs are loaded into frames of devtools |
68 // to support the devtools extension APIs) | 68 // to support the devtools extension APIs) |
69 bool is_dev_tools = page_url.SchemeIs(chrome::kChromeDevToolsScheme) && | 69 bool is_dev_tools = page_url.SchemeIs(chrome::kChromeDevToolsScheme) && |
70 !extension->devtools_url().is_empty(); | 70 !extension->devtools_url().is_empty(); |
71 bool transition_allowed = | 71 bool transition_allowed = |
72 !content::PageTransitionIsWebTriggerable(transition_type); | 72 !content::PageTransitionIsWebTriggerable(transition_type); |
| 73 // - unreachable web page error page (to allow showing the icon of the |
| 74 // unreachable app on this page) |
| 75 bool is_error_page = frame_url == GURL(content::kUnreachableWebDataURL); |
73 | 76 |
74 if (!is_empty_origin && !is_own_resource && | 77 if (!is_empty_origin && !is_own_resource && |
75 !is_dev_tools && !transition_allowed) { | 78 !is_dev_tools && !transition_allowed && !is_error_page) { |
76 std::string message = base::StringPrintf( | 79 std::string message = base::StringPrintf( |
77 "Denying load of %s. Resources must be listed in the " | 80 "Denying load of %s. Resources must be listed in the " |
78 "web_accessible_resources manifest key in order to be loaded by " | 81 "web_accessible_resources manifest key in order to be loaded by " |
79 "pages outside the extension.", | 82 "pages outside the extension.", |
80 resource_url.spec().c_str()); | 83 resource_url.spec().c_str()); |
81 frame->addMessageToConsole( | 84 frame->addMessageToConsole( |
82 WebKit::WebConsoleMessage(WebKit::WebConsoleMessage::LevelError, | 85 WebKit::WebConsoleMessage(WebKit::WebConsoleMessage::LevelError, |
83 WebKit::WebString::fromUTF8(message))); | 86 WebKit::WebString::fromUTF8(message))); |
84 return false; | 87 return false; |
85 } | 88 } |
(...skipping 21 matching lines...) Expand all Loading... |
107 return false; | 110 return false; |
108 } | 111 } |
109 | 112 |
110 return true; | 113 return true; |
111 } | 114 } |
112 | 115 |
113 ResourceRequestPolicy::ResourceRequestPolicy() { | 116 ResourceRequestPolicy::ResourceRequestPolicy() { |
114 } | 117 } |
115 | 118 |
116 } // namespace extensions | 119 } // namespace extensions |
OLD | NEW |