Chromium Code Reviews| 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/extension_dispatcher.h" | 5 #include "chrome/renderer/extensions/extension_dispatcher.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/common/child_process_logging.h" | 8 #include "chrome/common/child_process_logging.h" |
| 9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 if (context_type == ChromeV8Context::CONTENT_SCRIPT || | 321 if (context_type == ChromeV8Context::CONTENT_SCRIPT || |
| 322 extensions_.ExtensionBindingsAllowed(ExtensionURLInfo( | 322 extensions_.ExtensionBindingsAllowed(ExtensionURLInfo( |
| 323 frame->document().securityOrigin(), | 323 frame->document().securityOrigin(), |
| 324 UserScriptSlave::GetDataSourceURLForFrame(frame)))) { | 324 UserScriptSlave::GetDataSourceURLForFrame(frame)))) { |
| 325 // If the extension is a custom API binding, only allow if the extension | 325 // If the extension is a custom API binding, only allow if the extension |
| 326 // has permission to use the API. | 326 // has permission to use the API. |
| 327 std::string custom_binding_api_name = util::GetAPIName(v8_extension_name); | 327 std::string custom_binding_api_name = util::GetAPIName(v8_extension_name); |
| 328 if (!custom_binding_api_name.empty()) { | 328 if (!custom_binding_api_name.empty()) { |
| 329 std::string extension_id = GetExtensionID(frame, world_id); | 329 std::string extension_id = GetExtensionID(frame, world_id); |
| 330 const Extension* extension = extensions_.GetByID(extension_id); | 330 const Extension* extension = extensions_.GetByID(extension_id); |
| 331 if (!extension) { | 331 if (!extension) |
| 332 // This can happen when a resource is blocked due to CSP; a valid | |
| 333 // chrome-extension:// URL is navigated to, so it passes the initial | |
| 334 // checks, but the URL gets changed to "chrome-extension://invalid" | |
| 335 // afterwards (see chrome_content_renderer_client.cc). An extension | |
| 336 // page still gets loaded, just for the extension with ID "invalid", | |
| 337 // which of course isn't found so GetById extension will be NULL. | |
| 338 // | |
| 339 // Reference: http://crbug.com/111614. | |
| 340 CHECK_EQ("invalid", extension_id); | |
|
Aaron Boodman
2012/03/16 03:48:28
Can you LOG(ERROR) the details? This seems weird,
not at google - send to devlin
2012/03/16 04:54:46
Done.
| |
| 341 return false; | 332 return false; |
| 342 } | |
| 343 return util::AllowAPIInjection(custom_binding_api_name, *extension, this); | 333 return util::AllowAPIInjection(custom_binding_api_name, *extension, this); |
| 344 } | 334 } |
| 345 | 335 |
| 346 return true; | 336 return true; |
| 347 } | 337 } |
| 348 | 338 |
| 349 return false; | 339 return false; |
| 350 } | 340 } |
| 351 | 341 |
| 352 void ExtensionDispatcher::DidCreateScriptContext( | 342 void ExtensionDispatcher::DidCreateScriptContext( |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 541 webrequest_adblock_ = adblock; | 531 webrequest_adblock_ = adblock; |
| 542 webrequest_adblock_plus_ = adblock_plus; | 532 webrequest_adblock_plus_ = adblock_plus; |
| 543 webrequest_other_ = other; | 533 webrequest_other_ = other; |
| 544 } | 534 } |
| 545 | 535 |
| 546 void ExtensionDispatcher::OnShouldClose(const std::string& extension_id, | 536 void ExtensionDispatcher::OnShouldClose(const std::string& extension_id, |
| 547 int sequence_id) { | 537 int sequence_id) { |
| 548 RenderThread::Get()->Send( | 538 RenderThread::Get()->Send( |
| 549 new ExtensionHostMsg_ShouldCloseAck(extension_id, sequence_id)); | 539 new ExtensionHostMsg_ShouldCloseAck(extension_id, sequence_id)); |
| 550 } | 540 } |
| OLD | NEW |