Index: chrome/browser/extensions/extension_tabs_module.cc |
=================================================================== |
--- chrome/browser/extensions/extension_tabs_module.cc (revision 24584) |
+++ chrome/browser/extensions/extension_tabs_module.cc (working copy) |
@@ -766,6 +766,45 @@ |
Release(); // balanced in Run() |
} |
+bool ExecuteScriptWithUrlFunction::RunImpl() { |
+ if (args_->IsType(Value::TYPE_NULL)) |
+ return false; |
+ std::string url_string; |
+ EXTENSION_FUNCTION_VALIDATE(args_->GetAsString(&url_string)); |
+ scoped_ptr<GURL> url(new GURL(url_string)); |
+ if (!url->is_valid()) { |
+ // The path as passed in is not valid. Try converting to absolute path. |
+ *url = AbsolutePath(profile(), extension_id(), url_string); |
+ if (!url->is_valid()) { |
+ error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kInvalidUrlError, |
+ url_string); |
+ return false; |
+ } |
+ } |
+ |
+ // Check whether host of the URL is same with the extension. |
+ if (url->host() != extension_id()) { |
+ error_ = ExtensionErrorUtils::FormatErrorMessage(keys::kInvalidUrlError, |
+ url_string); |
+ return false; |
+ } |
+ script_fetcher_.reset(URLFetcher::Create(1, *url, URLFetcher::GET, this)); |
+ script_fetcher_->set_request_context(Profile::GetDefaultRequestContext()); |
+ script_fetcher_->Start(); |
+ |
+ AddRef(); // balanced in OnURLFetchComplete() |
+ return true; |
+} |
+ |
+void ExecuteScriptWithUrlFunction::OnURLFetchComplete( |
+ const URLFetcher* source, const GURL& url, |
+ const URLRequestStatus& status, int response_code, |
+ const ResponseCookies& cookies, const std::string& data) { |
+ result_.reset(Value::CreateStringValue(data.c_str())); |
+ SendResponse(true); |
+ Release(); // balanced in OnURLFetchComplete() |
+} |
+ |
// static helpers |
// if |populate| is true, each window gets a list property |tabs| which contains |