diff options
author | paulmeyer <paulmeyer@chromium.org> | 2014-09-26 08:00:31 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-26 15:01:03 +0000 |
commit | 0713c99452dfbfad3b72e7d17c132b78f1c6b9ec (patch) | |
tree | 32d56cea349ba12ba687f019c7fbbe3bf8eb2e21 | |
parent | b1807a0d15c889d7fb8645d72d34f01648e5faa0 (diff) | |
download | chromium_src-0713c99452dfbfad3b72e7d17c132b78f1c6b9ec.zip chromium_src-0713c99452dfbfad3b72e7d17c132b78f1c6b9ec.tar.gz chromium_src-0713c99452dfbfad3b72e7d17c132b78f1c6b9ec.tar.bz2 |
Fix for how webview.executeScript and webivew.insertCSS check for page navigtation when loading data URLs via NavigationController::LoadURLWithParams.
Tests will follow shortly in the patch that adds webview.loadDataWithBaseURL.
BUG=417816
TBR=rockot@chromium.org
Review URL: https://codereview.chromium.org/602193002
Cr-Commit-Position: refs/heads/master@{#296938}
5 files changed, 23 insertions, 4 deletions
diff --git a/extensions/browser/guest_view/web_view/web_view_constants.cc b/extensions/browser/guest_view/web_view/web_view_constants.cc index 9d61ec6..83e428f 100644 --- a/extensions/browser/guest_view/web_view/web_view_constants.cc +++ b/extensions/browser/guest_view/web_view/web_view_constants.cc @@ -87,6 +87,7 @@ const char kOldZoomFactor[] = "oldZoomFactor"; const char kNewZoomFactor[] = "newZoomFactor"; // Internal parameters/properties on events. +const char kInternalBaseURLForDataURL[] = "baseUrlForDataUrl"; const char kInternalCurrentEntryIndex[] = "currentEntryIndex"; const char kInternalEntryCount[] = "entryCount"; const char kInternalProcessId[] = "processId"; diff --git a/extensions/browser/guest_view/web_view/web_view_constants.h b/extensions/browser/guest_view/web_view/web_view_constants.h index b186edb..1278394 100644 --- a/extensions/browser/guest_view/web_view/web_view_constants.h +++ b/extensions/browser/guest_view/web_view/web_view_constants.h @@ -91,6 +91,7 @@ extern const char kOldZoomFactor[]; extern const char kNewZoomFactor[]; // Internal parameters/properties on events. +extern const char kInternalBaseURLForDataURL[]; extern const char kInternalCurrentEntryIndex[]; extern const char kInternalEntryCount[]; extern const char kInternalProcessId[]; 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 b68e37f..bb24c5d 100644 --- a/extensions/browser/guest_view/web_view/web_view_guest.cc +++ b/extensions/browser/guest_view/web_view/web_view_guest.cc @@ -661,6 +661,12 @@ void WebViewGuest::DidCommitProvisionalLoadForFrame( scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); args->SetString(guestview::kUrl, url.spec()); args->SetBoolean(guestview::kIsTopLevel, !render_frame_host->GetParent()); + args->SetString(webview::kInternalBaseURLForDataURL, + web_contents() + ->GetController() + .GetLastCommittedEntry() + ->GetBaseURLForDataURL() + .spec()); args->SetInteger(webview::kInternalCurrentEntryIndex, web_contents()->GetController().GetCurrentEntryIndex()); args->SetInteger(webview::kInternalEntryCount, diff --git a/extensions/renderer/resources/web_view.js b/extensions/renderer/resources/web_view.js index 9829bd9..98c80b9 100644 --- a/extensions/renderer/resources/web_view.js +++ b/extensions/renderer/resources/web_view.js @@ -292,7 +292,11 @@ WebViewInternal.prototype.validateExecuteCodeCall = function() { */ WebViewInternal.prototype.executeScript = function(var_args) { this.validateExecuteCodeCall(); - var args = $Array.concat([this.guestInstanceId, this.src], + var webview_src = this.src; + if (this.baseUrlForDataUrl != '') { + webview_src = this.baseUrlForDataUrl; + } + var args = $Array.concat([this.guestInstanceId, webview_src], $Array.slice(arguments)); $Function.apply(WebView.executeScript, null, args); }; @@ -302,7 +306,11 @@ WebViewInternal.prototype.executeScript = function(var_args) { */ WebViewInternal.prototype.insertCSS = function(var_args) { this.validateExecuteCodeCall(); - var args = $Array.concat([this.guestInstanceId, this.src], + var webview_src = this.src; + if (this.baseUrlForDataUrl != '') { + webview_src = this.baseUrlForDataUrl; + } + var args = $Array.concat([this.guestInstanceId, webview_src], $Array.slice(arguments)); $Function.apply(WebView.insertCSS, null, args); }; @@ -726,7 +734,9 @@ WebViewInternal.prototype.setupEventProperty = function(eventName) { // Updates state upon loadcommit. WebViewInternal.prototype.onLoadCommit = function( - currentEntryIndex, entryCount, processId, url, isTopLevel) { + baseUrlForDataUrl, currentEntryIndex, entryCount, + processId, url, isTopLevel) { + this.baseUrlForDataUrl = baseUrlForDataUrl; this.currentEntryIndex = currentEntryIndex; this.entryCount = entryCount; this.processId = processId; diff --git a/extensions/renderer/resources/web_view_events.js b/extensions/renderer/resources/web_view_events.js index 137baa2e..13af04c 100644 --- a/extensions/renderer/resources/web_view_events.js +++ b/extensions/renderer/resources/web_view_events.js @@ -302,7 +302,8 @@ WebViewEvents.prototype.handleLoadAbortEvent = function(event, webViewEvent) { }; WebViewEvents.prototype.handleLoadCommitEvent = function(event, webViewEvent) { - this.webViewInternal.onLoadCommit(event.currentEntryIndex, event.entryCount, + this.webViewInternal.onLoadCommit(event.baseUrlForDataUrl, + event.currentEntryIndex, event.entryCount, event.processId, event.url, event.isTopLevel); this.webViewInternal.dispatchEvent(webViewEvent); |