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 std::string src; | |
267 if (!args_->GetString(1, &src)) | |
268 return false; | |
269 | |
270 guest_src_ = GURL(src); | |
271 | |
272 if (!guest_src_.is_valid()) | |
273 return false; | |
274 | |
266 base::DictionaryValue* details_value = NULL; | 275 base::DictionaryValue* details_value = NULL; |
267 if (!args_->GetDictionary(1, &details_value)) | 276 if (!args_->GetDictionary(2, &details_value)) |
268 return false; | 277 return false; |
269 scoped_ptr<InjectDetails> details(new InjectDetails()); | 278 scoped_ptr<InjectDetails> details(new InjectDetails()); |
270 if (!InjectDetails::Populate(*details_value, details.get())) | 279 if (!InjectDetails::Populate(*details_value, details.get())) |
271 return false; | 280 return false; |
272 | 281 |
273 details_ = details.Pass(); | 282 details_ = details.Pass(); |
274 return true; | 283 return true; |
275 } | 284 } |
276 | 285 |
277 bool WebviewExecuteCodeFunction::ShouldInsertCSS() const { | 286 bool WebviewExecuteCodeFunction::ShouldInsertCSS() const { |
(...skipping 10 matching lines...) Expand all Loading... | |
288 if (!guest) | 297 if (!guest) |
289 return NULL; | 298 return NULL; |
290 | 299 |
291 return guest->script_executor(); | 300 return guest->script_executor(); |
292 } | 301 } |
293 | 302 |
294 bool WebviewExecuteCodeFunction::IsWebView() const { | 303 bool WebviewExecuteCodeFunction::IsWebView() const { |
295 return true; | 304 return true; |
296 } | 305 } |
297 | 306 |
307 GURL WebviewExecuteCodeFunction::GetWebViewSrc() const { return guest_src_; } | |
Fady Samuel
2014/04/07 21:10:45
You can probably return const GURL&
Xi Han
2014/04/07 21:42:15
Done.
| |
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 Loading... | |
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 |
OLD | NEW |