OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/web_view/web_view_internal_api.h" | 5 #include "extensions/browser/api/web_view/web_view_internal_api.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/public/browser/render_process_host.h" | 8 #include "content/public/browser/render_process_host.h" |
9 #include "content/public/browser/render_view_host.h" | 9 #include "content/public/browser/render_view_host.h" |
10 #include "content/public/browser/storage_partition.h" | 10 #include "content/public/browser/storage_partition.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 action = content::STOP_FIND_ACTION_ACTIVATE_SELECTION; | 293 action = content::STOP_FIND_ACTION_ACTIVATE_SELECTION; |
294 break; | 294 break; |
295 default: | 295 default: |
296 action = content::STOP_FIND_ACTION_KEEP_SELECTION; | 296 action = content::STOP_FIND_ACTION_KEEP_SELECTION; |
297 } | 297 } |
298 | 298 |
299 guest->StopFinding(action); | 299 guest->StopFinding(action); |
300 return true; | 300 return true; |
301 } | 301 } |
302 | 302 |
303 WebViewInternalLoadDataWithBaseUrlFunction:: | |
304 WebViewInternalLoadDataWithBaseUrlFunction() { | |
305 } | |
306 | |
307 WebViewInternalLoadDataWithBaseUrlFunction:: | |
308 ~WebViewInternalLoadDataWithBaseUrlFunction() { | |
309 } | |
310 | |
311 bool WebViewInternalLoadDataWithBaseUrlFunction::RunAsyncSafe( | |
312 WebViewGuest* guest) { | |
313 scoped_ptr<webview::LoadDataWithBaseUrl::Params> params( | |
314 webview::LoadDataWithBaseUrl::Params::Create(*args_)); | |
315 EXTENSION_FUNCTION_VALIDATE(params.get()); | |
Fady Samuel
2014/09/26 18:06:39
Could you please move the code below to WebViewGue
paulmeyer
2014/09/26 19:44:29
Done.
| |
316 | |
317 // If a virtual URL was provided, use it. Otherwise, the user will be shown | |
318 // the data URL. | |
319 std::string virtual_url = | |
320 params->virtual_url ? *params->virtual_url : params->data_url; | |
321 | |
322 // Check that the provided URLs are valid. | |
323 const GURL data_gurl = GURL(params->data_url); | |
324 const GURL base_gurl = GURL(params->base_url); | |
325 const GURL virtual_gurl = GURL(virtual_url); | |
326 // |data_url| must be a valid data URL. | |
327 if (!data_gurl.is_valid() || !data_gurl.SchemeIs(url::kDataScheme)) { | |
328 error_ = "Invalid data URL \"" + params->data_url + "\"."; | |
329 SendResponse(false); | |
330 return false; | |
331 } | |
332 // |base_url| must be a valid URL. | |
333 if (!base_gurl.is_valid()) { | |
334 error_ = "Invalid base URL \"" + params->base_url + "\"."; | |
335 SendResponse(false); | |
336 return false; | |
337 } | |
338 // |virtual_url| must be a valid URL (if provided). | |
339 if (params->virtual_url && !virtual_gurl.is_valid()) { | |
340 error_ = "Invalid virtual URL \"" + *params->virtual_url + "\"."; | |
341 SendResponse(false); | |
342 return false; | |
343 } | |
344 | |
345 // Set up the parameters to load |data_url| with the specified |base_url|. | |
346 content::NavigationController::LoadURLParams load_params(data_gurl); | |
347 load_params.load_type = content::NavigationController::LOAD_TYPE_DATA; | |
348 load_params.base_url_for_data_url = base_gurl; | |
349 load_params.virtual_url_for_data_url = virtual_gurl; | |
350 load_params.override_user_agent = | |
351 content::NavigationController::UA_OVERRIDE_FALSE; | |
Fady Samuel
2014/09/26 18:06:39
What happens if you've selected otherwise?
paulmeyer
2014/09/26 19:44:29
Done.
| |
352 | |
353 // Navigate to the data URL. | |
354 content::WebContents* web_contents = guest->web_contents(); | |
355 web_contents->GetController().LoadURLWithParams(load_params); | |
356 web_contents->Focus(); | |
357 | |
358 SendResponse(true); | |
359 return true; | |
360 } | |
361 | |
303 WebViewInternalGoFunction::WebViewInternalGoFunction() { | 362 WebViewInternalGoFunction::WebViewInternalGoFunction() { |
304 } | 363 } |
305 | 364 |
306 WebViewInternalGoFunction::~WebViewInternalGoFunction() { | 365 WebViewInternalGoFunction::~WebViewInternalGoFunction() { |
307 } | 366 } |
308 | 367 |
309 bool WebViewInternalGoFunction::RunAsyncSafe(WebViewGuest* guest) { | 368 bool WebViewInternalGoFunction::RunAsyncSafe(WebViewGuest* guest) { |
310 scoped_ptr<webview::Go::Params> params(webview::Go::Params::Create(*args_)); | 369 scoped_ptr<webview::Go::Params> params(webview::Go::Params::Create(*args_)); |
311 EXTENSION_FUNCTION_VALIDATE(params.get()); | 370 EXTENSION_FUNCTION_VALIDATE(params.get()); |
312 | 371 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
487 // Will finish asynchronously. | 546 // Will finish asynchronously. |
488 return true; | 547 return true; |
489 } | 548 } |
490 | 549 |
491 void WebViewInternalClearDataFunction::ClearDataDone() { | 550 void WebViewInternalClearDataFunction::ClearDataDone() { |
492 Release(); // Balanced in RunAsync(). | 551 Release(); // Balanced in RunAsync(). |
493 SendResponse(true); | 552 SendResponse(true); |
494 } | 553 } |
495 | 554 |
496 } // namespace extensions | 555 } // namespace extensions |
OLD | NEW |