Commit 7cf1ab9c authored by benwells@chromium.org's avatar benwells@chromium.org

Update app runtime custom bindings to handle no WebIntents launch data.

Launch data for apps no longer includes intents. This removes the custom
bindings code to translate the intent data, and also re-enables some tests
which were disabled.

BUG=175534


Review URL: https://chromiumcodereview.appspot.com/12223086

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182120 0039d316-1c4b-4281-b951-d872f2087c98
parent f5cae0f9
......@@ -397,23 +397,20 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, ExtensionWindowingApis) {
// ChromeOS does not support passing arguments on the command line, so the tests
// that rely on this functionality are disabled.
#if !defined(OS_CHROMEOS)
// TODO(thakis): Figure out what to do here, reenable.
// Tests that command line parameters get passed through to platform apps
// via launchData correctly when launching with a file.
// TODO(benwells/jeremya): tests need a way to specify a handler ID.
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DISABLED_LaunchWithFile) {
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithFile) {
SetCommandLineArg(kTestFilePath);
ASSERT_TRUE(RunPlatformAppTest("platform_apps/launch_file"))
<< message_;
}
// TODO(thakis): Figure out what to do here, reenable.
// Tests that relative paths can be passed through to the platform app.
// This test doesn't use the normal test infrastructure as it needs to open
// the application differently to all other platform app tests, by setting
// the chrome::AppLaunchParams.current_directory field.
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
DISABLED_LaunchWithRelativeFile) {
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithRelativeFile) {
// Setup the command line
ClearCommandLineArgs();
CommandLine* command_line = CommandLine::ForCurrentProcess();
......@@ -487,10 +484,9 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, LaunchWithNothing) {
<< message_;
}
// TODO(thakis): Figure out what to do with this test.
// Test that platform apps can use the chrome.fileSystem.getDisplayPath
// function to get the native file system path of a file they are launched with.
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, DISABLED_GetDisplayPath) {
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, GetDisplayPath) {
SetCommandLineArg(kTestFilePath);
ASSERT_TRUE(RunPlatformAppTest("platform_apps/get_display_path"))
<< message_;
......
......@@ -15,8 +15,6 @@ var CreateBlob = appNatives.CreateBlob;
chromeHidden.Event.registerArgumentMassager('app.runtime.onLaunched',
function(args, dispatch) {
var launchData = args[0];
var intentData = args[1];
var intentId = args[2];
if (launchData && typeof launchData.id !== 'undefined') {
// new-style dispatch.
......@@ -33,14 +31,6 @@ chromeHidden.Event.registerArgumentMassager('app.runtime.onLaunched',
dispatch([]);
} else {
var data = { id: launchData.id, items: items };
// TODO(benwells): remove once we no longer support intents.
data.intent = {
action: "http://webintents.org/view",
type: "chrome-extension://fileentry",
data: items[0].entry,
postResult: function() {},
postFailure: function() {}
};
dispatch([data]);
}
}
......@@ -53,67 +43,9 @@ chromeHidden.Event.registerArgumentMassager('app.runtime.onLaunched',
itemLoaded(fileError);
});
});
} else {
if (launchData) {
if (intentId) {
var fn = function(success, data) {
chrome.app.runtime.postIntentResponse({
'intentId': intentId,
'success': success,
'data': SerializeToString(data)
});
};
launchData.intent.postResult = fn.bind(undefined, true);
launchData.intent.postFailure = fn.bind(undefined, false);
} else {
launchData.intent.postResult = function() {};
launchData.intent.postFailure = function() {};
}
}
if (launchData && intentData) {
switch(intentData.format) {
case('fileEntry'):
var fs = GetIsolatedFileSystem(intentData.fileSystemId);
try {
fs.root.getFile(intentData.baseName, {}, function(fileEntry) {
launchData.intent.data = fileEntry;
dispatch([launchData]);
}, function(fileError) {
console.error('Error getting fileEntry, code: ' + fileError.code);
dispatch([]);
});
} catch (e) {
console.error('Error in event handler for onLaunched: ' + e.stack);
dispatch([]);
}
break;
case('filesystem'):
launchData.intent.data = GetIsolatedFileSystem(
intentData.fileSystemId, intentData.baseName);
launchData.intent.postResult = function() {};
launchData.intent.postFailure = function() {};
dispatch([launchData]);
break;
case('serialized'):
var deserializedData = DeserializeString(intentData.data);
launchData.intent.data = deserializedData;
dispatch([launchData]);
break;
case('blob'):
var blobData = CreateBlob(intentData.blobFilePath,
intentData.blobLength);
launchData.intent.data = blobData;
dispatch([launchData]);
break;
default:
console.error('Unexpected launch data format');
dispatch([]);
}
} else if (launchData) {
dispatch([launchData]);
} else {
dispatch([]);
}
}
});
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/*
This extension is a platform app that provides a Web Intent handler; it accepts
incoming requests and invokes chrome.test.succeed() immediately.
*/
function launchedListener(launchData) {
chrome.test.assertFalse(!launchData, "No launchData");
chrome.test.assertFalse(!launchData.intent, "No launchData.intent");
chrome.test.assertEq(launchData.intent.action,
"http://webintents.org/view");
chrome.test.assertEq(launchData.intent.type,
"chrome-extension://fileentry");
chrome.test.assertFalse(!launchData.intent.data,
"No launchData.intent.data");
launchData.intent.data.file(function(file) {
var reader = new FileReader();
reader.onloadend = function(e) {
chrome.test.assertEq("hello, world!", reader.result);
chrome.test.succeed();
};
reader.onerror = function(e) {
chrome.test.fail("Error reading file contents.");
};
reader.readAsText(file);
});
}
chrome.app.runtime.onLaunched.addListener(launchedListener);
{
"key": "MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQChptAQ0n4R56N03nWQ1ogR7DVRBjGo80Vw6G9KLjzZv44D8rq5Q5IkeQrtKgWyZfXevlsCe3LaLo18rcz8iZx6lK2xhLdUR+ORjsjuBfdEL5a5cWeRTSxf75AcqndQsmpwMBdrMTCZ8jQNusUI+XlrihLNNJuI5TM4vNINI5bYFQIBIw==",
"name": "ChromeOS Web Intent handler extension",
"version": "0.1",
"manifest_version": 2,
"description": "Tests of chrome.fileSystem.* methods for handling Web Intents",
"app": {
"background": {
"scripts": ["background.js"]
}
},
"intents": {
"http://webintents.org/view": [{
"title": "View xul action",
"type": ["application/vnd.mozilla.xul+xml"]
}]
},
"permissions": [
"experimental",
"fileSystem",
"unlimitedStorage"
]
}
......@@ -3,19 +3,15 @@
// found in the LICENSE file.
chrome.app.runtime.onLaunched.addListener(function (launchData) {
// Test that there is a launchData.intent, it is set up proerly, and that the
// FileEntry in launchData.intent.data can be read.
// Test that there is launchData, it is set up properly, and that the
// FileEntry in launchData.items[0].entry can have its display path gotten.
chrome.test.runTests([
function testGetDisplayPath() {
chrome.test.assertFalse(!launchData, "No launchData");
chrome.test.assertFalse(!launchData.intent, "No launchData.intent");
chrome.test.assertEq(launchData.intent.action,
"http://webintents.org/view");
chrome.test.assertEq(launchData.intent.type,
"chrome-extension://fileentry");
chrome.test.assertFalse(!launchData.intent.data,
"No launchData.intent.data");
var entry = launchData.intent.data;
chrome.test.assertFalse(!launchData.items[0], "No launchData.items[0]");
chrome.test.assertFalse(!launchData.items[0].entry,
"No launchData.items[0].entry");
var entry = launchData.items[0].entry;
chrome.fileSystem.getDisplayPath(entry,
chrome.test.callbackPass(function(path) {
chrome.test.assertFalse(path.indexOf('test.txt') == -1);
......
{
"name": "Platform App Launch/Reply Test",
"version": "1",
"file_handlers": {
"text": {
"types": [
"text/*"
],
"title": "Test editor"
}
},
"app": {
"background": {
"scripts": ["test.js"]
}
}
}
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
chrome.app.runtime.onLaunched.addListener(function(launchData) {
// Test that there is a launchData.intent, and it is set up properly. Then
// immediately reply to the intent with a success message.
chrome.test.runTests([
function testIntent() {
chrome.test.assertFalse(!launchData, "No launchData");
chrome.test.assertFalse(!launchData.intent, "No launchData.intent");
launchData.intent.postResult(true);
}
]);
});
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