Chromium Code Reviews| Index: extensions/browser/guest_view/web_view/web_view_guest.cc |
| diff --git a/extensions/browser/guest_view/web_view/web_view_guest.cc b/extensions/browser/guest_view/web_view/web_view_guest.cc |
| index bb24c5db3c99ef51ad23e50ed925d8201a6b2475..66198c1c6e0a92a911cbd43c1c1e6f5852c4d8dd 100644 |
| --- a/extensions/browser/guest_view/web_view/web_view_guest.cc |
| +++ b/extensions/browser/guest_view/web_view/web_view_guest.cc |
| @@ -999,6 +999,50 @@ void WebViewGuest::SetAllowTransparency(bool allow) { |
| web_contents()->GetRenderViewHost()->GetView()->SetBackgroundOpaque(!allow); |
| } |
| +bool WebViewGuest::LoadDataWithBaseURL(const std::string& data_url, |
| + const std::string& base_url, |
| + const std::string& virtual_url, |
| + std::string* error) { |
| + // Make GURLs from URLs. |
| + const GURL data_gurl = GURL(data_url); |
| + const GURL base_gurl = GURL(base_url); |
| + const GURL virtual_gurl = GURL(virtual_url); |
| + |
| + // Check that the provided URLs are valid. |
| + // |data_url| must be a valid data URL. |
| + if (!data_gurl.is_valid() || !data_gurl.SchemeIs(url::kDataScheme)) { |
| + base::SStringPrintf( |
| + error, webview::kAPILoadDataInvalidDataURL, data_url.c_str()); |
| + return false; |
| + } |
| + // |base_url| must be a valid URL. |
| + if (!base_gurl.is_valid()) { |
| + base::SStringPrintf( |
| + error, webview::kAPILoadDataInvalidBaseURL, base_url.c_str()); |
| + return false; |
| + } |
| + // |virtual_url| must be a valid URL. |
| + if (!virtual_gurl.is_valid()) { |
| + base::SStringPrintf( |
| + error, webview::kAPILoadDataInvalidVirtualURL, virtual_url.c_str()); |
| + return false; |
| + } |
| + |
| + // Set up the parameters to load |data_url| with the specified |base_url|. |
| + content::NavigationController::LoadURLParams load_params(data_gurl); |
| + load_params.load_type = content::NavigationController::LOAD_TYPE_DATA; |
| + load_params.base_url_for_data_url = base_gurl; |
| + load_params.virtual_url_for_data_url = virtual_gurl; |
| + load_params.override_user_agent = |
| + content::NavigationController::UA_OVERRIDE_INHERIT; |
| + |
| + // Navigate to the data URL. |
| + web_contents()->GetController().LoadURLWithParams(load_params); |
| + web_contents()->Focus(); |
|
Fady Samuel
2014/09/29 14:59:00
Let's avoid this? Focus should be managed separate
paulmeyer
2014/09/29 15:19:04
Done.
|
| + |
| + return true; |
| +} |
| + |
| void WebViewGuest::AddNewContents(content::WebContents* source, |
| content::WebContents* new_contents, |
| WindowOpenDisposition disposition, |