Commit 0713c994 authored by paulmeyer's avatar paulmeyer Committed by Commit bot

Fix for how webview.executeScript and webivew.insertCSS check for page...

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}
parent b1807a0d
......@@ -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";
......
......@@ -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[];
......
......@@ -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,
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment