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

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

Issue 11624036: Move the parsing of homepage_url" and "devtools_page" out of Extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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/api/url_parser/url_info.h"
11 #include "chrome/common/extensions/extension.h" 12 #include "chrome/common/extensions/extension.h"
12 #include "chrome/common/extensions/extension_set.h" 13 #include "chrome/common/extensions/extension_set.h"
13 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
14 #include "content/public/common/page_transition_types.h" 15 #include "content/public/common/page_transition_types.h"
15 #include "extensions/common/constants.h" 16 #include "extensions/common/constants.h"
16 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 18 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h"
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 // Exceptions are: 62 // Exceptions are:
62 // - empty origin (needed for some edge cases when we have empty origins) 63 // - empty origin (needed for some edge cases when we have empty origins)
63 bool is_empty_origin = frame_url.is_empty(); 64 bool is_empty_origin = frame_url.is_empty();
64 // - extensions requesting their own resources (frame_url check is for 65 // - extensions requesting their own resources (frame_url check is for
65 // images, page_url check is for iframes) 66 // images, page_url check is for iframes)
66 bool is_own_resource = frame_url.GetOrigin() == extension->url() || 67 bool is_own_resource = frame_url.GetOrigin() == extension->url() ||
67 page_url.GetOrigin() == extension->url(); 68 page_url.GetOrigin() == extension->url();
68 // - devtools (chrome-extension:// URLs are loaded into frames of devtools 69 // - devtools (chrome-extension:// URLs are loaded into frames of devtools
69 // to support the devtools extension APIs) 70 // to support the devtools extension APIs)
70 bool is_dev_tools = page_url.SchemeIs(chrome::kChromeDevToolsScheme) && 71 bool is_dev_tools = page_url.SchemeIs(chrome::kChromeDevToolsScheme) &&
71 !extension->devtools_url().is_empty(); 72 !extensions::URLInfo::url(
73 extension, extensions::URLInfo::DEVTOOLS_PAGE).is_empty();
72 bool transition_allowed = 74 bool transition_allowed =
73 !content::PageTransitionIsWebTriggerable(transition_type); 75 !content::PageTransitionIsWebTriggerable(transition_type);
74 // - unreachable web page error page (to allow showing the icon of the 76 // - unreachable web page error page (to allow showing the icon of the
75 // unreachable app on this page) 77 // unreachable app on this page)
76 bool is_error_page = frame_url == GURL(content::kUnreachableWebDataURL); 78 bool is_error_page = frame_url == GURL(content::kUnreachableWebDataURL);
77 79
78 if (!is_empty_origin && !is_own_resource && 80 if (!is_empty_origin && !is_own_resource &&
79 !is_dev_tools && !transition_allowed && !is_error_page) { 81 !is_dev_tools && !transition_allowed && !is_error_page) {
80 std::string message = base::StringPrintf( 82 std::string message = base::StringPrintf(
81 "Denying load of %s. Resources must be listed in the " 83 "Denying load of %s. Resources must be listed in the "
(...skipping 29 matching lines...) Expand all
111 return false; 113 return false;
112 } 114 }
113 115
114 return true; 116 return true;
115 } 117 }
116 118
117 ResourceRequestPolicy::ResourceRequestPolicy() { 119 ResourceRequestPolicy::ResourceRequestPolicy() {
118 } 120 }
119 121
120 } // namespace extensions 122 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698