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

Side by Side Diff: chrome/browser/extensions/api/webview/webview_api.cc

Issue 226043005: Fix webview.executeScript API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Small changes are made. Created 6 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/browser/extensions/api/webview/webview_api.h" 5 #include "chrome/browser/extensions/api/webview/webview_api.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h" 8 #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h"
9 #include "chrome/browser/extensions/api/context_menus/context_menus_api.h" 9 #include "chrome/browser/extensions/api/context_menus/context_menus_api.h"
10 #include "chrome/browser/extensions/api/context_menus/context_menus_api_helpers. h" 10 #include "chrome/browser/extensions/api/context_menus/context_menus_api_helpers. h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 bool WebviewExecuteCodeFunction::Init() { 256 bool WebviewExecuteCodeFunction::Init() {
257 if (details_.get()) 257 if (details_.get())
258 return true; 258 return true;
259 259
260 if (!args_->GetInteger(0, &guest_instance_id_)) 260 if (!args_->GetInteger(0, &guest_instance_id_))
261 return false; 261 return false;
262 262
263 if (!guest_instance_id_) 263 if (!guest_instance_id_)
264 return false; 264 return false;
265 265
266 if (!args_->GetString(1, &guest_src_))
267 return false;
268
269 if (guest_src_.empty()) {
270 return false;
271 }
not at google - send to devlin 2014/04/07 17:43:00 make braces consistent i.e. here leave them out.
Xi Han 2014/04/07 21:03:37 Done.
272
266 base::DictionaryValue* details_value = NULL; 273 base::DictionaryValue* details_value = NULL;
267 if (!args_->GetDictionary(1, &details_value)) 274 if (!args_->GetDictionary(2, &details_value))
268 return false; 275 return false;
269 scoped_ptr<InjectDetails> details(new InjectDetails()); 276 scoped_ptr<InjectDetails> details(new InjectDetails());
270 if (!InjectDetails::Populate(*details_value, details.get())) 277 if (!InjectDetails::Populate(*details_value, details.get()))
271 return false; 278 return false;
272 279
273 details_ = details.Pass(); 280 details_ = details.Pass();
274 return true; 281 return true;
275 } 282 }
276 283
277 bool WebviewExecuteCodeFunction::ShouldInsertCSS() const { 284 bool WebviewExecuteCodeFunction::ShouldInsertCSS() const {
(...skipping 10 matching lines...) Expand all
288 if (!guest) 295 if (!guest)
289 return NULL; 296 return NULL;
290 297
291 return guest->script_executor(); 298 return guest->script_executor();
292 } 299 }
293 300
294 bool WebviewExecuteCodeFunction::IsWebView() const { 301 bool WebviewExecuteCodeFunction::IsWebView() const {
295 return true; 302 return true;
296 } 303 }
297 304
305 std::string WebviewExecuteCodeFunction::GetWebViewSrc() const {
306 return guest_src_;
307 }
308
298 WebviewExecuteScriptFunction::WebviewExecuteScriptFunction() { 309 WebviewExecuteScriptFunction::WebviewExecuteScriptFunction() {
299 } 310 }
300 311
301 void WebviewExecuteScriptFunction::OnExecuteCodeFinished( 312 void WebviewExecuteScriptFunction::OnExecuteCodeFinished(
302 const std::string& error, 313 const std::string& error,
303 int32 on_page_id, 314 int32 on_page_id,
304 const GURL& on_url, 315 const GURL& on_url,
305 const base::ListValue& result) { 316 const base::ListValue& result) {
306 if (error.empty()) 317 if (error.empty())
307 SetResult(result.DeepCopy()); 318 SetResult(result.DeepCopy());
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 539
529 WebviewTerminateFunction::~WebviewTerminateFunction() { 540 WebviewTerminateFunction::~WebviewTerminateFunction() {
530 } 541 }
531 542
532 bool WebviewTerminateFunction::RunImplSafe(WebViewGuest* guest) { 543 bool WebviewTerminateFunction::RunImplSafe(WebViewGuest* guest) {
533 guest->Terminate(); 544 guest->Terminate();
534 return true; 545 return true;
535 } 546 }
536 547
537 } // namespace extensions 548 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698