OLD | NEW |
---|---|
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 Loading... | |
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 } | |
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 { |
278 return false; | 285 return false; |
279 } | 286 } |
280 | 287 |
281 bool WebviewExecuteCodeFunction::CanExecuteScriptOnPage() { | 288 bool WebviewExecuteCodeFunction::CanExecuteScriptOnPage() { |
282 return true; | 289 return true; |
283 } | 290 } |
284 | 291 |
285 extensions::ScriptExecutor* WebviewExecuteCodeFunction::GetScriptExecutor() { | 292 extensions::ScriptExecutor* WebviewExecuteCodeFunction::GetScriptExecutor() { |
286 WebViewGuest* guest = WebViewGuest::From( | 293 WebViewGuest* guest = WebViewGuest::From( |
287 render_view_host()->GetProcess()->GetID(), guest_instance_id_); | 294 render_view_host()->GetProcess()->GetID(), guest_instance_id_); |
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 } |
304 std::string WebviewExecuteCodeFunction::GetWebViewSrc() const { | |
Fady Samuel
2014/04/04 19:35:05
Move down one line.
Xi Han
2014/04/06 20:14:03
Done.
| |
305 return guest_src_; | |
306 } | |
297 | 307 |
298 WebviewExecuteScriptFunction::WebviewExecuteScriptFunction() { | 308 WebviewExecuteScriptFunction::WebviewExecuteScriptFunction() { |
299 } | 309 } |
300 | 310 |
301 void WebviewExecuteScriptFunction::OnExecuteCodeFinished( | 311 void WebviewExecuteScriptFunction::OnExecuteCodeFinished( |
302 const std::string& error, | 312 const std::string& error, |
303 int32 on_page_id, | 313 int32 on_page_id, |
304 const GURL& on_url, | 314 const GURL& on_url, |
305 const base::ListValue& result) { | 315 const base::ListValue& result) { |
306 if (error.empty()) | 316 if (error.empty()) |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
528 | 538 |
529 WebviewTerminateFunction::~WebviewTerminateFunction() { | 539 WebviewTerminateFunction::~WebviewTerminateFunction() { |
530 } | 540 } |
531 | 541 |
532 bool WebviewTerminateFunction::RunImplSafe(WebViewGuest* guest) { | 542 bool WebviewTerminateFunction::RunImplSafe(WebViewGuest* guest) { |
533 guest->Terminate(); | 543 guest->Terminate(); |
534 return true; | 544 return true; |
535 } | 545 } |
536 | 546 |
537 } // namespace extensions | 547 } // namespace extensions |
OLD | NEW |