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/browser/extensions/api/web_request/web_request_api.h" | 5 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 using extensions::web_navigation_api_helpers::GetFrameId; | 77 using extensions::web_navigation_api_helpers::GetFrameId; |
78 | 78 |
79 namespace helpers = extension_web_request_api_helpers; | 79 namespace helpers = extension_web_request_api_helpers; |
80 namespace keys = extension_web_request_api_constants; | 80 namespace keys = extension_web_request_api_constants; |
81 namespace web_request = extensions::api::web_request; | 81 namespace web_request = extensions::api::web_request; |
82 namespace declarative_keys = extensions::declarative_webrequest_constants; | 82 namespace declarative_keys = extensions::declarative_webrequest_constants; |
83 namespace activitylog = activity_log_web_request_constants; | 83 namespace activitylog = activity_log_web_request_constants; |
84 | 84 |
85 namespace { | 85 namespace { |
86 | 86 |
| 87 const char kWebRequest[] = "webRequest"; |
| 88 const char kWebView[] = "webview"; |
| 89 |
87 // List of all the webRequest events. | 90 // List of all the webRequest events. |
88 const char* const kWebRequestEvents[] = { | 91 const char* const kWebRequestEvents[] = { |
89 keys::kOnBeforeRedirectEvent, | 92 keys::kOnBeforeRedirectEvent, |
90 keys::kOnBeforeRequestEvent, | 93 keys::kOnBeforeRequestEvent, |
91 keys::kOnBeforeSendHeadersEvent, | 94 keys::kOnBeforeSendHeadersEvent, |
92 keys::kOnCompletedEvent, | 95 keys::kOnCompletedEvent, |
93 keys::kOnErrorOccurredEvent, | 96 keys::kOnErrorOccurredEvent, |
94 keys::kOnSendHeadersEvent, | 97 keys::kOnSendHeadersEvent, |
95 keys::kOnAuthRequiredEvent, | 98 keys::kOnAuthRequiredEvent, |
96 keys::kOnResponseStartedEvent, | 99 keys::kOnResponseStartedEvent, |
(...skipping 24 matching lines...) Expand all Loading... |
121 case ExtensionWebRequestEventRouter::kOnErrorOccurred: | 124 case ExtensionWebRequestEventRouter::kOnErrorOccurred: |
122 return keys::kOnErrorOccurred; | 125 return keys::kOnErrorOccurred; |
123 case ExtensionWebRequestEventRouter::kOnCompleted: | 126 case ExtensionWebRequestEventRouter::kOnCompleted: |
124 return keys::kOnCompleted; | 127 return keys::kOnCompleted; |
125 } | 128 } |
126 NOTREACHED(); | 129 NOTREACHED(); |
127 return "Not reached"; | 130 return "Not reached"; |
128 } | 131 } |
129 | 132 |
130 bool IsWebRequestEvent(const std::string& event_name) { | 133 bool IsWebRequestEvent(const std::string& event_name) { |
| 134 std::string web_request_event_name(event_name); |
| 135 if (web_request_event_name.find(kWebView) != std::string::npos) |
| 136 web_request_event_name.replace(0, sizeof(kWebView) - 1, kWebRequest); |
131 return std::find(kWebRequestEvents, ARRAYEND(kWebRequestEvents), | 137 return std::find(kWebRequestEvents, ARRAYEND(kWebRequestEvents), |
132 event_name) != ARRAYEND(kWebRequestEvents); | 138 web_request_event_name) != ARRAYEND(kWebRequestEvents); |
133 } | 139 } |
134 | 140 |
135 // Returns whether |request| has been triggered by an extension in | 141 // Returns whether |request| has been triggered by an extension in |
136 // |extension_info_map|. | 142 // |extension_info_map|. |
137 bool IsRequestFromExtension(const net::URLRequest* request, | 143 bool IsRequestFromExtension(const net::URLRequest* request, |
138 const ExtensionInfoMap* extension_info_map) { | 144 const ExtensionInfoMap* extension_info_map) { |
139 // |extension_info_map| is NULL for system-level requests. | 145 // |extension_info_map| is NULL for system-level requests. |
140 if (!extension_info_map) | 146 if (!extension_info_map) |
141 return false; | 147 return false; |
142 | 148 |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 headers_value->Append(ToHeaderDictionary(it.name(), it.value())); | 322 headers_value->Append(ToHeaderDictionary(it.name(), it.value())); |
317 return headers_value; | 323 return headers_value; |
318 } | 324 } |
319 | 325 |
320 // Creates a StringValue with the status line of |headers|. If |headers| is | 326 // Creates a StringValue with the status line of |headers|. If |headers| is |
321 // NULL, an empty string is returned. Ownership is passed to the caller. | 327 // NULL, an empty string is returned. Ownership is passed to the caller. |
322 StringValue* GetStatusLine(net::HttpResponseHeaders* headers) { | 328 StringValue* GetStatusLine(net::HttpResponseHeaders* headers) { |
323 return new StringValue(headers ? headers->GetStatusLine() : std::string()); | 329 return new StringValue(headers ? headers->GetStatusLine() : std::string()); |
324 } | 330 } |
325 | 331 |
| 332 void RemoveEventListenerOnUI( |
| 333 void* profile_id, |
| 334 const std::string& event_name, |
| 335 int process_id, |
| 336 const std::string& extension_id) { |
| 337 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 338 |
| 339 Profile* profile = reinterpret_cast<Profile*>(profile_id); |
| 340 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) |
| 341 return; |
| 342 |
| 343 extensions::EventRouter* event_router = |
| 344 extensions::ExtensionSystem::Get(profile)->event_router(); |
| 345 if (!event_router) |
| 346 return; |
| 347 |
| 348 content::RenderProcessHost* process = |
| 349 content::RenderProcessHost::FromID(process_id); |
| 350 if (!process) |
| 351 return; |
| 352 |
| 353 event_router->RemoveEventListener(event_name, process, extension_id); |
| 354 } |
| 355 |
326 // Sends an event to subscribers of chrome.declarativeWebRequest.onMessage. | 356 // Sends an event to subscribers of chrome.declarativeWebRequest.onMessage. |
327 // |extension_id| identifies the extension that sends and receives the event. | 357 // |extension_id| identifies the extension that sends and receives the event. |
328 // |event_argument| is passed to the event listener. | 358 // |event_argument| is passed to the event listener. |
329 void SendOnMessageEventOnUI( | 359 void SendOnMessageEventOnUI( |
330 void* profile_id, | 360 void* profile_id, |
331 const std::string& extension_id, | 361 const std::string& extension_id, |
332 scoped_ptr<base::DictionaryValue> event_argument) { | 362 scoped_ptr<base::DictionaryValue> event_argument) { |
333 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 363 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
334 | 364 |
335 Profile* profile = reinterpret_cast<Profile*>(profile_id); | 365 Profile* profile = reinterpret_cast<Profile*>(profile_id); |
(...skipping 20 matching lines...) Expand all Loading... |
356 // added. | 386 // added. |
357 // NOTE(benjhayden) New APIs should not use this sub_event_name trick! It does | 387 // NOTE(benjhayden) New APIs should not use this sub_event_name trick! It does |
358 // not play well with event pages. See downloads.onDeterminingFilename and | 388 // not play well with event pages. See downloads.onDeterminingFilename and |
359 // ExtensionDownloadsEventRouter for an alternative approach. | 389 // ExtensionDownloadsEventRouter for an alternative approach. |
360 struct ExtensionWebRequestEventRouter::EventListener { | 390 struct ExtensionWebRequestEventRouter::EventListener { |
361 std::string extension_id; | 391 std::string extension_id; |
362 std::string extension_name; | 392 std::string extension_name; |
363 std::string sub_event_name; | 393 std::string sub_event_name; |
364 RequestFilter filter; | 394 RequestFilter filter; |
365 int extra_info_spec; | 395 int extra_info_spec; |
366 int target_process_id; | 396 int embedder_process_id; |
367 int target_route_id; | 397 int web_view_instance_id; |
368 base::WeakPtr<IPC::Sender> ipc_sender; | 398 base::WeakPtr<IPC::Sender> ipc_sender; |
369 mutable std::set<uint64> blocked_requests; | 399 mutable std::set<uint64> blocked_requests; |
370 | 400 |
371 // Comparator to work with std::set. | 401 // Comparator to work with std::set. |
372 bool operator<(const EventListener& that) const { | 402 bool operator<(const EventListener& that) const { |
373 if (extension_id < that.extension_id) | 403 if (extension_id < that.extension_id) |
374 return true; | 404 return true; |
375 if (extension_id == that.extension_id && | 405 if (extension_id == that.extension_id && |
376 sub_event_name < that.sub_event_name) | 406 sub_event_name < that.sub_event_name) |
377 return true; | 407 return true; |
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 } | 1147 } |
1118 | 1148 |
1119 bool ExtensionWebRequestEventRouter::AddEventListener( | 1149 bool ExtensionWebRequestEventRouter::AddEventListener( |
1120 void* profile, | 1150 void* profile, |
1121 const std::string& extension_id, | 1151 const std::string& extension_id, |
1122 const std::string& extension_name, | 1152 const std::string& extension_name, |
1123 const std::string& event_name, | 1153 const std::string& event_name, |
1124 const std::string& sub_event_name, | 1154 const std::string& sub_event_name, |
1125 const RequestFilter& filter, | 1155 const RequestFilter& filter, |
1126 int extra_info_spec, | 1156 int extra_info_spec, |
1127 int target_process_id, | 1157 int embedder_process_id, |
1128 int target_route_id, | 1158 int web_view_instance_id, |
1129 base::WeakPtr<IPC::Sender> ipc_sender) { | 1159 base::WeakPtr<IPC::Sender> ipc_sender) { |
| 1160 |
1130 if (!IsWebRequestEvent(event_name)) | 1161 if (!IsWebRequestEvent(event_name)) |
1131 return false; | 1162 return false; |
1132 | 1163 |
1133 EventListener listener; | 1164 EventListener listener; |
1134 listener.extension_id = extension_id; | 1165 listener.extension_id = extension_id; |
1135 listener.extension_name = extension_name; | 1166 listener.extension_name = extension_name; |
1136 listener.sub_event_name = sub_event_name; | 1167 listener.sub_event_name = sub_event_name; |
1137 listener.filter = filter; | 1168 listener.filter = filter; |
1138 listener.extra_info_spec = extra_info_spec; | 1169 listener.extra_info_spec = extra_info_spec; |
1139 listener.ipc_sender = ipc_sender; | 1170 listener.ipc_sender = ipc_sender; |
1140 listener.target_process_id = target_process_id; | 1171 listener.embedder_process_id = embedder_process_id; |
1141 listener.target_route_id = target_route_id; | 1172 listener.web_view_instance_id = web_view_instance_id; |
1142 | 1173 |
1143 if (listeners_[profile][event_name].count(listener) != 0u) { | 1174 if (listeners_[profile][event_name].count(listener) != 0u) { |
1144 // This is likely an abuse of the API by a malicious extension. | 1175 // This is likely an abuse of the API by a malicious extension. |
1145 return false; | 1176 return false; |
1146 } | 1177 } |
1147 listeners_[profile][event_name].insert(listener); | 1178 listeners_[profile][event_name].insert(listener); |
1148 return true; | 1179 return true; |
1149 } | 1180 } |
1150 | 1181 |
1151 void ExtensionWebRequestEventRouter::RemoveEventListener( | 1182 void ExtensionWebRequestEventRouter::RemoveEventListener( |
(...skipping 25 matching lines...) Expand all Loading... |
1177 for (std::set<uint64>::iterator it = found->blocked_requests.begin(); | 1208 for (std::set<uint64>::iterator it = found->blocked_requests.begin(); |
1178 it != found->blocked_requests.end(); ++it) { | 1209 it != found->blocked_requests.end(); ++it) { |
1179 DecrementBlockCount(profile, extension_id, event_name, *it, NULL); | 1210 DecrementBlockCount(profile, extension_id, event_name, *it, NULL); |
1180 } | 1211 } |
1181 | 1212 |
1182 listeners_[profile][event_name].erase(listener); | 1213 listeners_[profile][event_name].erase(listener); |
1183 | 1214 |
1184 helpers::ClearCacheOnNavigation(); | 1215 helpers::ClearCacheOnNavigation(); |
1185 } | 1216 } |
1186 | 1217 |
| 1218 void ExtensionWebRequestEventRouter::RemoveWebViewEventListeners( |
| 1219 void* profile, |
| 1220 const std::string& extension_id, |
| 1221 int embedder_process_id, |
| 1222 int web_view_instance_id) { |
| 1223 // Iterate over all listeners of all WebRequest events to delete |
| 1224 // any listeners that belong to the provided <webview>. |
| 1225 ListenerMapForProfile& map_for_profile = listeners_[profile]; |
| 1226 for (ListenerMapForProfile::iterator event_iter = map_for_profile.begin(); |
| 1227 event_iter != map_for_profile.end(); ++event_iter) { |
| 1228 std::vector<EventListener> listeners_to_delete; |
| 1229 std::set<EventListener>& listeners = event_iter->second; |
| 1230 for (std::set<EventListener>::iterator listener_iter = listeners.begin(); |
| 1231 listener_iter != listeners.end(); ++listener_iter) { |
| 1232 const EventListener& listener = *listener_iter; |
| 1233 if (listener.embedder_process_id == embedder_process_id && |
| 1234 listener.web_view_instance_id == web_view_instance_id) |
| 1235 listeners_to_delete.push_back(listener); |
| 1236 } |
| 1237 for (size_t i = 0; i < listeners_to_delete.size(); ++i) { |
| 1238 EventListener& listener = listeners_to_delete[i]; |
| 1239 content::BrowserThread::PostTask( |
| 1240 content::BrowserThread::UI, |
| 1241 FROM_HERE, |
| 1242 base::Bind(&RemoveEventListenerOnUI, |
| 1243 profile, |
| 1244 listener.sub_event_name, |
| 1245 embedder_process_id, |
| 1246 extension_id)); |
| 1247 } |
| 1248 } |
| 1249 } |
| 1250 |
1187 void ExtensionWebRequestEventRouter::OnOTRProfileCreated( | 1251 void ExtensionWebRequestEventRouter::OnOTRProfileCreated( |
1188 void* original_profile, void* otr_profile) { | 1252 void* original_profile, void* otr_profile) { |
1189 cross_profile_map_[original_profile] = otr_profile; | 1253 cross_profile_map_[original_profile] = otr_profile; |
1190 cross_profile_map_[otr_profile] = original_profile; | 1254 cross_profile_map_[otr_profile] = original_profile; |
1191 } | 1255 } |
1192 | 1256 |
1193 void ExtensionWebRequestEventRouter::OnOTRProfileDestroyed( | 1257 void ExtensionWebRequestEventRouter::OnOTRProfileDestroyed( |
1194 void* original_profile, void* otr_profile) { | 1258 void* original_profile, void* otr_profile) { |
1195 cross_profile_map_.erase(otr_profile); | 1259 cross_profile_map_.erase(otr_profile); |
1196 cross_profile_map_.erase(original_profile); | 1260 cross_profile_map_.erase(original_profile); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1254 int tab_id, | 1318 int tab_id, |
1255 int window_id, | 1319 int window_id, |
1256 int render_process_host_id, | 1320 int render_process_host_id, |
1257 int routing_id, | 1321 int routing_id, |
1258 ResourceType::Type resource_type, | 1322 ResourceType::Type resource_type, |
1259 bool is_async_request, | 1323 bool is_async_request, |
1260 bool is_request_from_extension, | 1324 bool is_request_from_extension, |
1261 int* extra_info_spec, | 1325 int* extra_info_spec, |
1262 std::vector<const ExtensionWebRequestEventRouter::EventListener*>* | 1326 std::vector<const ExtensionWebRequestEventRouter::EventListener*>* |
1263 matching_listeners) { | 1327 matching_listeners) { |
| 1328 std::string web_request_event_name(event_name); |
1264 ExtensionRendererState::WebViewInfo web_view_info; | 1329 ExtensionRendererState::WebViewInfo web_view_info; |
1265 bool is_guest = ExtensionRendererState::GetInstance()-> | 1330 bool is_guest = ExtensionRendererState::GetInstance()-> |
1266 GetWebViewInfo(render_process_host_id, routing_id, &web_view_info); | 1331 GetWebViewInfo(render_process_host_id, routing_id, &web_view_info); |
1267 std::set<EventListener>& listeners = listeners_[profile][event_name]; | 1332 if (is_guest) |
| 1333 web_request_event_name.replace(0, sizeof(kWebRequest) - 1, kWebView); |
| 1334 |
| 1335 std::set<EventListener>& listeners = |
| 1336 listeners_[profile][web_request_event_name]; |
1268 for (std::set<EventListener>::iterator it = listeners.begin(); | 1337 for (std::set<EventListener>::iterator it = listeners.begin(); |
1269 it != listeners.end(); ++it) { | 1338 it != listeners.end(); ++it) { |
1270 if (!it->ipc_sender.get()) { | 1339 if (!it->ipc_sender.get()) { |
1271 // The IPC sender has been deleted. This listener will be removed soon | 1340 // The IPC sender has been deleted. This listener will be removed soon |
1272 // via a call to RemoveEventListener. For now, just skip it. | 1341 // via a call to RemoveEventListener. For now, just skip it. |
1273 continue; | 1342 continue; |
1274 } | 1343 } |
1275 | 1344 |
1276 if (is_guest && (it->target_process_id != render_process_host_id|| | 1345 if (is_guest && |
1277 it->target_route_id != routing_id)) | 1346 (it->embedder_process_id != web_view_info.embedder_process_id || |
| 1347 it->web_view_instance_id != web_view_info.web_view_instance_id)) |
1278 continue; | 1348 continue; |
1279 | 1349 |
1280 if (!it->filter.urls.is_empty() && !it->filter.urls.MatchesURL(url)) | 1350 if (!it->filter.urls.is_empty() && !it->filter.urls.MatchesURL(url)) |
1281 continue; | 1351 continue; |
1282 if (it->filter.tab_id != -1 && tab_id != it->filter.tab_id) | 1352 if (it->filter.tab_id != -1 && tab_id != it->filter.tab_id) |
1283 continue; | 1353 continue; |
1284 if (it->filter.window_id != -1 && window_id != it->filter.window_id) | 1354 if (it->filter.window_id != -1 && window_id != it->filter.window_id) |
1285 continue; | 1355 continue; |
1286 if (!it->filter.types.empty() && | 1356 if (!it->filter.types.empty() && |
1287 std::find(it->filter.types.begin(), it->filter.types.end(), | 1357 std::find(it->filter.types.begin(), it->filter.types.end(), |
1288 resource_type) == it->filter.types.end()) | 1358 resource_type) == it->filter.types.end()) |
1289 continue; | 1359 continue; |
1290 | 1360 |
1291 if (!WebRequestPermissions::CanExtensionAccessURL( | 1361 if (!is_guest && !WebRequestPermissions::CanExtensionAccessURL( |
1292 extension_info_map, it->extension_id, url, crosses_incognito, | 1362 extension_info_map, it->extension_id, url, crosses_incognito, |
1293 WebRequestPermissions::REQUIRE_HOST_PERMISSION)) | 1363 WebRequestPermissions::REQUIRE_HOST_PERMISSION)) |
1294 continue; | 1364 continue; |
1295 | 1365 |
1296 bool blocking_listener = | 1366 bool blocking_listener = |
1297 (it->extra_info_spec & | 1367 (it->extra_info_spec & |
1298 (ExtraInfoSpec::BLOCKING | ExtraInfoSpec::ASYNC_BLOCKING)) != 0; | 1368 (ExtraInfoSpec::BLOCKING | ExtraInfoSpec::ASYNC_BLOCKING)) != 0; |
1299 | 1369 |
1300 // We do not want to notify extensions about XHR requests that are | 1370 // We do not want to notify extensions about XHR requests that are |
1301 // triggered by themselves. This is a workaround to prevent deadlocks | 1371 // triggered by themselves. This is a workaround to prevent deadlocks |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1969 ExtensionWebRequestEventRouter::ExtraInfoSpec::InitFromValue( | 2039 ExtensionWebRequestEventRouter::ExtraInfoSpec::InitFromValue( |
1970 *value, &extra_info_spec)); | 2040 *value, &extra_info_spec)); |
1971 } | 2041 } |
1972 | 2042 |
1973 std::string event_name; | 2043 std::string event_name; |
1974 EXTENSION_FUNCTION_VALIDATE(args_->GetString(3, &event_name)); | 2044 EXTENSION_FUNCTION_VALIDATE(args_->GetString(3, &event_name)); |
1975 | 2045 |
1976 std::string sub_event_name; | 2046 std::string sub_event_name; |
1977 EXTENSION_FUNCTION_VALIDATE(args_->GetString(4, &sub_event_name)); | 2047 EXTENSION_FUNCTION_VALIDATE(args_->GetString(4, &sub_event_name)); |
1978 | 2048 |
| 2049 int web_view_instance_id = 0; |
| 2050 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(5, &web_view_instance_id)); |
| 2051 |
| 2052 base::WeakPtr<ChromeRenderMessageFilter> ipc_sender = ipc_sender_weak(); |
| 2053 |
| 2054 int embedder_process_id = |
| 2055 ipc_sender.get() ? ipc_sender->render_process_id() : -1; |
| 2056 |
1979 const Extension* extension = | 2057 const Extension* extension = |
1980 extension_info_map()->extensions().GetByID(extension_id()); | 2058 extension_info_map()->extensions().GetByID(extension_id()); |
1981 std::string extension_name = extension ? extension->name() : extension_id(); | 2059 std::string extension_name = extension ? extension->name() : extension_id(); |
1982 | 2060 |
| 2061 bool is_guest = web_view_instance_id != 0; |
1983 // We check automatically whether the extension has the 'webRequest' | 2062 // We check automatically whether the extension has the 'webRequest' |
1984 // permission. For blocking calls we require the additional permission | 2063 // permission. For blocking calls we require the additional permission |
1985 // 'webRequestBlocking'. | 2064 // 'webRequestBlocking'. |
1986 if ((extra_info_spec & | 2065 if ((!is_guest && extra_info_spec & |
1987 (ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING | | 2066 (ExtensionWebRequestEventRouter::ExtraInfoSpec::BLOCKING | |
1988 ExtensionWebRequestEventRouter::ExtraInfoSpec::ASYNC_BLOCKING)) && | 2067 ExtensionWebRequestEventRouter::ExtraInfoSpec::ASYNC_BLOCKING)) && |
1989 !extension->HasAPIPermission( | 2068 !extension->HasAPIPermission( |
1990 extensions::APIPermission::kWebRequestBlocking)) { | 2069 extensions::APIPermission::kWebRequestBlocking)) { |
1991 error_ = keys::kBlockingPermissionRequired; | 2070 error_ = keys::kBlockingPermissionRequired; |
1992 return false; | 2071 return false; |
1993 } | 2072 } |
1994 | 2073 |
1995 // We allow to subscribe to patterns that are broader than the host | 2074 // We allow to subscribe to patterns that are broader than the host |
1996 // permissions. E.g., we could subscribe to http://www.example.com/* | 2075 // permissions. E.g., we could subscribe to http://www.example.com/* |
1997 // while having host permissions for http://www.example.com/foo/* and | 2076 // while having host permissions for http://www.example.com/foo/* and |
1998 // http://www.example.com/bar/*. | 2077 // http://www.example.com/bar/*. |
1999 // For this reason we do only a coarse check here to warn the extension | 2078 // For this reason we do only a coarse check here to warn the extension |
2000 // developer if he does something obviously wrong. | 2079 // developer if he does something obviously wrong. |
2001 if (extensions::PermissionsData::GetEffectiveHostPermissions( | 2080 if (!is_guest && extensions::PermissionsData::GetEffectiveHostPermissions( |
2002 extension).is_empty()) { | 2081 extension).is_empty()) { |
2003 error_ = keys::kHostPermissionsRequired; | 2082 error_ = keys::kHostPermissionsRequired; |
2004 return false; | 2083 return false; |
2005 } | 2084 } |
2006 | 2085 |
2007 bool success = | 2086 bool success = |
2008 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( | 2087 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( |
2009 profile_id(), extension_id(), extension_name, | 2088 profile_id(), extension_id(), extension_name, |
2010 event_name, sub_event_name, filter, | 2089 event_name, sub_event_name, filter, extra_info_spec, |
2011 extra_info_spec, -1, -1, ipc_sender_weak()); | 2090 embedder_process_id, web_view_instance_id, ipc_sender_weak()); |
2012 EXTENSION_FUNCTION_VALIDATE(success); | 2091 EXTENSION_FUNCTION_VALIDATE(success); |
2013 | 2092 |
2014 helpers::ClearCacheOnNavigation(); | 2093 helpers::ClearCacheOnNavigation(); |
2015 | 2094 |
2016 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 2095 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
2017 &helpers::NotifyWebRequestAPIUsed, | 2096 &helpers::NotifyWebRequestAPIUsed, |
2018 profile_id(), make_scoped_refptr(GetExtension()))); | 2097 profile_id(), make_scoped_refptr(GetExtension()))); |
2019 | 2098 |
2020 return true; | 2099 return true; |
2021 } | 2100 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2181 } else if ((*it)->name().find("AdBlock") != std::string::npos) { | 2260 } else if ((*it)->name().find("AdBlock") != std::string::npos) { |
2182 adblock = true; | 2261 adblock = true; |
2183 } else { | 2262 } else { |
2184 other = true; | 2263 other = true; |
2185 } | 2264 } |
2186 } | 2265 } |
2187 } | 2266 } |
2188 | 2267 |
2189 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); | 2268 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); |
2190 } | 2269 } |
OLD | NEW |