Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1161)

Unified Diff: chrome/browser/extensions/extension_tabs_module.cc

Issue 159067: Add API: getBackgroundPageView and getToolstripViews (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « chrome/browser/extensions/extension_tabs_module.h ('k') | chrome/browser/extensions/extension_tabs_module_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698