| 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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 332 if (extension_id != "invalid") { |
| 333 // chrome-extension:// URL is navigated to, so it passes the initial | 333 // Ignore "invalid" because CSP blocks extension page loading by |
| 334 // checks, but the URL gets changed to "chrome-extension://invalid" | 334 // switching the extension ID to "invalid". This isn't interesting. |
| 335 // afterwards (see chrome_content_renderer_client.cc). An extension | 335 LOG(ERROR) << "Extension \"" << extension_id << "\" not found"; |
| 336 // page still gets loaded, just for the extension with ID "invalid", | 336 RenderThread::Get()->RecordUserMetrics("ExtensionNotFound_ED"); |
| 337 // which of course isn't found so GetById extension will be NULL. | 337 } |
| 338 // | |
| 339 // Reference: http://crbug.com/111614. | |
| 340 CHECK_EQ("invalid", extension_id); | |
| 341 return false; | 338 return false; |
| 342 } | 339 } |
| 343 return util::AllowAPIInjection(custom_binding_api_name, *extension, this); | 340 return util::AllowAPIInjection(custom_binding_api_name, *extension, this); |
| 344 } | 341 } |
| 345 | 342 |
| 346 return true; | 343 return true; |
| 347 } | 344 } |
| 348 | 345 |
| 349 return false; | 346 return false; |
| 350 } | 347 } |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 webrequest_adblock_ = adblock; | 538 webrequest_adblock_ = adblock; |
| 542 webrequest_adblock_plus_ = adblock_plus; | 539 webrequest_adblock_plus_ = adblock_plus; |
| 543 webrequest_other_ = other; | 540 webrequest_other_ = other; |
| 544 } | 541 } |
| 545 | 542 |
| 546 void ExtensionDispatcher::OnShouldClose(const std::string& extension_id, | 543 void ExtensionDispatcher::OnShouldClose(const std::string& extension_id, |
| 547 int sequence_id) { | 544 int sequence_id) { |
| 548 RenderThread::Get()->Send( | 545 RenderThread::Get()->Send( |
| 549 new ExtensionHostMsg_ShouldCloseAck(extension_id, sequence_id)); | 546 new ExtensionHostMsg_ShouldCloseAck(extension_id, sequence_id)); |
| 550 } | 547 } |
| OLD | NEW |