| 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/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/string_piece.h" | 10 #include "base/string_piece.h" |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 case Feature::CONTENT_SCRIPT_CONTEXT: { | 569 case Feature::CONTENT_SCRIPT_CONTEXT: { |
| 570 module_system->Require("miscellaneous_bindings"); | 570 module_system->Require("miscellaneous_bindings"); |
| 571 module_system->Require("schema_generated_bindings"); | 571 module_system->Require("schema_generated_bindings"); |
| 572 module_system->Require("apitest"); | 572 module_system->Require("apitest"); |
| 573 | 573 |
| 574 // TODO(kalman): move this code back out of the switch and execute it | 574 // TODO(kalman): move this code back out of the switch and execute it |
| 575 // regardless of |context_type|. ExtensionAPI knows how to return the | 575 // regardless of |context_type|. ExtensionAPI knows how to return the |
| 576 // correct APIs, however, until it doesn't have a 2MB overhead we can't | 576 // correct APIs, however, until it doesn't have a 2MB overhead we can't |
| 577 // load it in every process. | 577 // load it in every process. |
| 578 scoped_ptr<std::set<std::string> > apis = | 578 scoped_ptr<std::set<std::string> > apis = |
| 579 ExtensionAPI::GetSharedInstance()->GetAPIsForContext( | 579 ExtensionAPI::GetInstance()->GetAPIsForContext( |
| 580 context_type, extension, url_info.url()); | 580 context_type, extension, url_info.url()); |
| 581 for (std::set<std::string>::iterator i = apis->begin(); i != apis->end(); | 581 for (std::set<std::string>::iterator i = apis->begin(); i != apis->end(); |
| 582 ++i) { | 582 ++i) { |
| 583 InstallBindings(module_system.get(), v8_context, *i); | 583 InstallBindings(module_system.get(), v8_context, *i); |
| 584 } | 584 } |
| 585 | 585 |
| 586 break; | 586 break; |
| 587 } | 587 } |
| 588 } | 588 } |
| 589 | 589 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 static const char kMessage[] = | 827 static const char kMessage[] = |
| 828 "You do not have permission to use '%s'. Be sure to declare" | 828 "You do not have permission to use '%s'. Be sure to declare" |
| 829 " in your manifest what permissions you need."; | 829 " in your manifest what permissions you need."; |
| 830 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 830 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); |
| 831 v8::ThrowException( | 831 v8::ThrowException( |
| 832 v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 832 v8::Exception::Error(v8::String::New(error_msg.c_str()))); |
| 833 return false; | 833 return false; |
| 834 } | 834 } |
| 835 | 835 |
| 836 if (!IsExtensionActive(extension->id()) && | 836 if (!IsExtensionActive(extension->id()) && |
| 837 ExtensionAPI::GetSharedInstance()->IsPrivileged(function_name)) { | 837 ExtensionAPI::GetInstance()->IsPrivileged(function_name)) { |
| 838 static const char kMessage[] = | 838 static const char kMessage[] = |
| 839 "%s can only be used in an extension process."; | 839 "%s can only be used in an extension process."; |
| 840 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); | 840 std::string error_msg = base::StringPrintf(kMessage, function_name.c_str()); |
| 841 v8::ThrowException( | 841 v8::ThrowException( |
| 842 v8::Exception::Error(v8::String::New(error_msg.c_str()))); | 842 v8::Exception::Error(v8::String::New(error_msg.c_str()))); |
| 843 return false; | 843 return false; |
| 844 } | 844 } |
| 845 | 845 |
| 846 return true; | 846 return true; |
| 847 } | 847 } |
| OLD | NEW |