From: Eurogiciel-BOT Date: Thu, 15 May 2014 09:06:45 +0000 (+0000) Subject: Upstream version 7.35.138.0 X-Git-Tag: submit/trunk/20140515.094940^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fframework%2Fweb%2Fcrosswalk.git;a=commitdiff_plain;h=3cb1527a1d0111fd75188ac2c34c117944473076 Upstream version 7.35.138.0 Upstream commit-id dac34b59e193c01a8afbd8ac6263e619e374880d Change-Id: I3bb40be610b6472a0fa792d1207a8ca82372484a Signed-off-by: Eurogiciel-BOT --- diff --git a/packaging/crosswalk.spec b/packaging/crosswalk.spec index 113af1c..dfa8db1 100644 --- a/packaging/crosswalk.spec +++ b/packaging/crosswalk.spec @@ -2,7 +2,7 @@ %bcond_with wayland Name: crosswalk -Version: 7.35.136.0 +Version: 7.35.138.0 Release: 0 Summary: Crosswalk is an app runtime based on Chromium License: (BSD-3-Clause and LGPL-2.1+) diff --git a/src/xwalk/VERSION b/src/xwalk/VERSION index cde4ae0..350b1f9 100644 --- a/src/xwalk/VERSION +++ b/src/xwalk/VERSION @@ -1,4 +1,4 @@ MAJOR=7 MINOR=35 -BUILD=136 +BUILD=138 PATCH=0 diff --git a/src/xwalk/app/tools/android/compress_js_and_css.py b/src/xwalk/app/tools/android/compress_js_and_css.py index f46a9ec..4f70cd4 100755 --- a/src/xwalk/app/tools/android/compress_js_and_css.py +++ b/src/xwalk/app/tools/android/compress_js_and_css.py @@ -7,6 +7,7 @@ import os import subprocess + def GetJARFilename(): # Version of YUI Compressor. version = "2.4.8" @@ -20,7 +21,7 @@ def ExecuteCmd(file_list, ext): for file_full_path in file_list: if os.path.exists(file_full_path): cmd_args = ["java", "-jar", GetJARFilename(), "--type=" + ext, - file_full_path, "-o", file_full_path] + file_full_path, "-o", file_full_path] subprocess.call(cmd_args) diff --git a/src/xwalk/app/tools/android/customize.py b/src/xwalk/app/tools/android/customize.py index c11ad04..416378c 100755 --- a/src/xwalk/app/tools/android/customize.py +++ b/src/xwalk/app/tools/android/customize.py @@ -22,12 +22,13 @@ from handle_xml import EditElementValueByNodeName from handle_permissions import HandlePermissions from xml.dom import minidom + def VerifyAppName(value, mode='default'): descrpt = 'The app' sample = 'helloworld, hello_world, hello_world1' regex = r'^([a-zA-Z](\w)*)+$' - if len(value) >= 128 : + if len(value) >= 128: print('To be safe, the length of package name or app name ' 'should be less than 128.') sys.exit(6) @@ -57,11 +58,11 @@ def ReplaceInvalidChars(value, mode='default'): for c in invalid_chars: if mode == 'apkname' and c in value: print("Illegal character: '%s' is replaced with '_'" % c) - value = value.replace(c,'_') + value = value.replace(c, '_') return value -def GetFilesByExt(path, ext, sub_dir = True): +def GetFilesByExt(path, ext, sub_dir=True): if os.path.exists(path): file_list = [] for name in os.listdir(path): @@ -114,7 +115,7 @@ def Prepare(name, package, app_root, compressor): print ('Please make sure that the java file' ' of activity does exist.') sys.exit(7) - root_path = os.path.join(name, 'src', package.replace('.', os.path.sep)) + root_path = os.path.join(name, 'src', package.replace('.', os.path.sep)) if not os.path.exists(root_path): os.makedirs(root_path) dest_activity = name + 'Activity.java' @@ -231,7 +232,7 @@ def SetVariable(file_path, string_line, variable, value): def CustomizeJava(name, package, app_url, app_local_path, enable_remote_debugging, display_as_fullscreen, keep_screen_on): - root_path = os.path.join(name, 'src', package.replace('.', os.path.sep)) + root_path = os.path.join(name, 'src', package.replace('.', os.path.sep)) dest_activity = os.path.join(root_path, name + 'Activity.java') ReplaceString(dest_activity, 'org.xwalk.app.template', package) ReplaceString(dest_activity, 'AppTemplate', name) @@ -267,7 +268,7 @@ def CustomizeJava(name, package, app_url, app_local_path, ReplaceString( dest_activity, 'super.onCreate(savedInstanceState);', - 'super.onCreate(savedInstanceState);\n '+ + 'super.onCreate(savedInstanceState);\n ' + 'getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);') @@ -351,8 +352,9 @@ def CustomizeExtensions(name, extensions): json_output = json.JSONDecoder().decode(src_file_content) # Below 3 properties are used by runtime. See extension manager. # And 'permissions' will be merged. - if ((not 'name' in json_output) or (not 'class' in json_output) - or (not 'jsapi' in json_output)): + if not ('name' in json_output and + 'class' in json_output and + 'jsapi' in json_output): print ('Error: properties \'name\', \'class\' and \'jsapi\' in a json ' 'file are mandatory.') sys.exit(9) @@ -402,8 +404,9 @@ def GenerateCommandLineFile(name, xwalk_command_line): def CustomizeIconByDict(name, app_root, icon_dict): icon_name = None - drawable_dict = {'ldpi':[1, 37], 'mdpi':[37, 72], 'hdpi':[72, 96], - 'xhdpi':[96, 120], 'xxhdpi':[120, 144], 'xxxhdpi':[144, 168]} + drawable_dict = {'ldpi': [1, 37], 'mdpi': [37, 72], 'hdpi': [72, 96], + 'xhdpi': [96, 120], 'xxhdpi': [120, 144], + 'xxxhdpi': [144, 168]} if not icon_dict: return icon_name @@ -413,7 +416,7 @@ def CustomizeIconByDict(name, app_root, icon_dict): print('The key of icon in the manifest file should be a number.') if len(icon_dict) > 0: - icon_list = sorted(icon_dict.iteritems(), key = lambda d:d[0]) + icon_list = sorted(icon_dict.iteritems(), key=lambda d: d[0]) for kd, vd in drawable_dict.iteritems(): for item in icon_list: if item[0] >= vd[0] and item[0] < vd[1]: @@ -512,7 +515,7 @@ def main(): parser.add_option('--app-local-path', help=info) parser.add_option('--enable-remote-debugging', action='store_true', dest='enable_remote_debugging', default=False, - help = 'Enable remote debugging.') + help='Enable remote debugging.') parser.add_option('-f', '--fullscreen', action='store_true', dest='fullscreen', default=False, help='Make application fullscreen.') @@ -547,22 +550,23 @@ def main(): 72: 'icons/icon_72.png', 96: 'icons/icon_96.png', 48: 'icons/icon_48.png'} - if options.name == None: + if options.name is None: options.name = 'Example' - if options.app_root == None: + if options.app_root is None: options.app_root = os.path.join('test_data', 'manifest') - if options.package == None: + if options.package is None: options.package = 'org.xwalk.app.template' - if options.orientation == None: + if options.orientation is None: options.orientation = 'unspecified' - if options.app_version == None: + if options.app_version is None: options.app_version = '1.0.0' icon = os.path.join('test_data', 'manifest', 'icons', 'icon_96.png') CustomizeAll(options.app_versionCode, options.description, icon_dict, options.permissions, options.app_url, options.app_root, options.app_local_path, options.enable_remote_debugging, - options.fullscreen, options.keep_screen_on, options.extensions, - options.manifest, icon, options.package, options.name, + options.fullscreen, options.keep_screen_on, + options.extensions, options.manifest, + icon, options.package, options.name, options.app_version, options.orientation, options.xwalk_command_line, options.compressor) except SystemExit as ec: diff --git a/src/xwalk/app/tools/android/customize_launch_screen.py b/src/xwalk/app/tools/android/customize_launch_screen.py index f6f1bf8..b44f180 100755 --- a/src/xwalk/app/tools/android/customize_launch_screen.py +++ b/src/xwalk/app/tools/android/customize_launch_screen.py @@ -10,12 +10,13 @@ import sys from manifest_json_parser import ManifestJsonParser + def CopyToPathWithName(root, name, final_path, rename): if name == '': return False origin_path = os.path.join(root, name) if not os.path.exists(origin_path): - print ('Error: \'' + origin_path + '\' not found.' ) + print('Error: \'' + origin_path + '\' not found.') sys.exit(6) if not os.path.exists(final_path): os.makedirs(final_path) @@ -64,7 +65,7 @@ def CopyDrawables(image_dict, orientation, sanitized_name, name, app_root): if not has_image: closest = '' delta = sys.maxint - for (k , v) in image_dict.items(): + for(k, v) in image_dict.items(): items = k.split('x') if len(items) == 2: float_value = sys.maxint @@ -97,7 +98,7 @@ def CustomizeDrawable(image, orientation, sanitized_name, app_root, name): for image_pair in image_list: items = image_pair.strip().split(' ') if len(items) >= 2: - x = items[len(items)-1] + x = items[len(items) - 1] image_item = items[0] image_dict[x] = image_item @@ -141,7 +142,7 @@ def CustomizeBackground(background_color, content = content.replace('', tmp, 1) has_background = True if has_background: - background_file = file(background_path,'w') + background_file = file(background_path, 'w') background_file.write(content) background_file.close() return has_background diff --git a/src/xwalk/app/tools/android/handle_permissions.py b/src/xwalk/app/tools/android/handle_permissions.py index d8f91b4..c1d3bbf 100755 --- a/src/xwalk/app/tools/android/handle_permissions.py +++ b/src/xwalk/app/tools/android/handle_permissions.py @@ -27,20 +27,20 @@ from xml.parsers.expat import ExpatError # The global permission mapping table. # TODO: update the permission mapping table for added permission. permission_mapping_table = { - 'contacts' : ['android.permission.READ_CONTACTS', - 'android.permission.WRITE_CONTACTS'], - 'geolocation' : ['android.permission.ACCESS_FINE_LOCATION'], - 'messaging' : ['android.permission.READ_SMS', - 'android.permission.READ_PHONE_STATE', - 'android.permission.RECEIVE_SMS', - 'android.permission.SEND_SMS', - 'android.permission.WRITE_SMS'], - 'devicecapabilities' : [], - 'fullscreen' : [], - 'presentation' : [], - 'rawsockets' : [], - 'screenorientation' : [], - 'vibration' : ['android.permission.VIBRATE'] + 'contacts': ['android.permission.READ_CONTACTS', + 'android.permission.WRITE_CONTACTS'], + 'geolocation': ['android.permission.ACCESS_FINE_LOCATION'], + 'messaging': ['android.permission.READ_SMS', + 'android.permission.READ_PHONE_STATE', + 'android.permission.RECEIVE_SMS', + 'android.permission.SEND_SMS', + 'android.permission.WRITE_SMS'], + 'devicecapabilities': [], + 'fullscreen': [], + 'presentation': [], + 'rawsockets': [], + 'screenorientation': [], + 'vibration': ['android.permission.VIBRATE'] } diff --git a/src/xwalk/app/tools/android/make_apk.py b/src/xwalk/app/tools/android/make_apk.py index e56533f..0acbe03 100755 --- a/src/xwalk/app/tools/android/make_apk.py +++ b/src/xwalk/app/tools/android/make_apk.py @@ -22,6 +22,7 @@ from handle_permissions import permission_mapping_table from manifest_json_parser import HandlePermissionList from manifest_json_parser import ManifestJsonParser + def CleanDir(path): if os.path.exists(path): shutil.rmtree(path) @@ -228,7 +229,8 @@ def Execution(options, name): sdk_root_path = os.path.dirname(os.path.dirname(android_path_array[0])) try: - sdk_jar_path = Find('android.jar', os.path.join(sdk_root_path, 'platforms')) + sdk_jar_path = Find('android.jar', + os.path.join(sdk_root_path, 'platforms')) except Exception: print('Your Android SDK may be ruined, please reinstall it.') sys.exit(2) @@ -268,7 +270,7 @@ def Execution(options, name): 'tools', 'lib', 'ant-tasks.jar') if not os.path.exists(ant_tasks_jar_path): ant_tasks_jar_path = os.path.join(sdk_root_path, - 'tools', 'lib' ,'anttasks.jar') + 'tools', 'lib', 'anttasks.jar') aapt_path = '' for aapt_str in AddExeExtensions('aapt'): @@ -487,7 +489,7 @@ def Execution(options, name): def PrintPackageInfo(target_dir, app_name, app_version, - arch = '', multi_arch = False): + arch='', multi_arch=False): package_name_version = os.path.join(target_dir, app_name) if app_version != '': package_name_version += ('_' + app_version) @@ -501,7 +503,7 @@ def PrintPackageInfo(target_dir, app_name, app_version, 'Runtime built for %s was generated successfully, which can be ' 'found at\n%s_%s.apk.' % (app_name, arch, package_name_version, arch)) - if multi_arch == False: + if multi_arch is False: if arch == 'x86': print ('WARNING: This APK will only work on x86 based Android devices. ' 'Consider building for ARM as well.') @@ -548,7 +550,7 @@ def MakeApk(options): sys.exit(13) multi_arch = False - if len(packaged_archs) >=2: + if len(packaged_archs) >= 2: multi_arch = True for arch in packaged_archs: PrintPackageInfo(options.target_dir, name, app_version, arch, @@ -576,7 +578,7 @@ def main(argv): info = ('The target architecture of the embedded runtime. Supported values ' 'are \'x86\' and \'arm\'. Note, if undefined, APKs for all possible ' 'architestures will be generated.') - parser.add_option('--arch', help=info) + parser.add_option('--arch', choices=("x86", "arm"), help=info) group = optparse.OptionGroup(parser, 'Application Source Options', 'This packaging tool supports 3 kinds of web application source: ' '1) XPK package; 2) manifest.json; 3) various command line options, ' @@ -631,8 +633,8 @@ def main(argv): '--description=YourApplicationDescription') group.add_option('--description', help=info) group.add_option('--enable-remote-debugging', action='store_true', - dest='enable_remote_debugging', default=False, - help = 'Enable remote debugging.') + dest='enable_remote_debugging', default=False, + help='Enable remote debugging.') info = ('The list of external extension paths splitted by OS separators. ' 'The separators are \':\' , \';\' and \':\' on Linux, Windows and ' 'Mac OS respectively. For example, ' @@ -673,8 +675,8 @@ def main(argv): '--compressor=js: compress javascript.' '--compressor=css: compress css.') group.add_option('--compressor', dest='compressor', action='callback', - callback=ParseParameterForCompressor, type='string', nargs=0, - help=info) + callback=ParseParameterForCompressor, type='string', + nargs=0, help=info) parser.add_option_group(group) options, _ = parser.parse_args() if len(argv) == 1: @@ -710,9 +712,12 @@ def main(argv): VerifyAppName(options.name) else: parser.error('The APK name is required! Please use "--name" option.') - if not ((options.app_url and not options.app_root - and not options.app_local_path) or ((not options.app_url) - and options.app_root and options.app_local_path)): + if not ((options.app_url and + not options.app_root and + not options.app_local_path) or + (not options.app_url and + options.app_root and + options.app_local_path)): parser.error('The entry is required. If the entry is a remote url, ' 'please use "--app-url" option; If the entry is local, ' 'please use "--app-root" and ' @@ -732,8 +737,9 @@ def main(argv): except SystemExit as ec: return ec.code - if (options.app_root and options.app_local_path and not - os.path.isfile(os.path.join(options.app_root, options.app_local_path))): + if (options.app_root and options.app_local_path and + not os.path.isfile(os.path.join(options.app_root, + options.app_local_path))): print('Please make sure that the local path file of launching app ' 'does exist.') sys.exit(7) diff --git a/src/xwalk/app/tools/android/make_apk_test.py b/src/xwalk/app/tools/android/make_apk_test.py index 0b2c62d..9f54354 100755 --- a/src/xwalk/app/tools/android/make_apk_test.py +++ b/src/xwalk/app/tools/android/make_apk_test.py @@ -12,6 +12,7 @@ import sys import unittest import warnings + def Clean(name, app_version): if os.path.exists(name): shutil.rmtree(name) @@ -60,13 +61,13 @@ def RunCommand(command): def GetResultWithOption(mode, manifest=None, name=None, package=None): app_url = None - if manifest != None: + if manifest is not None: manifest = '--manifest=' + manifest else: app_url = '--app-url=http://www.intel.com' - if name != None: + if name is not None: name = '--name=' + name - if package != None: + if package is not None: package = '--package=' + package cmd = ['python', 'make_apk.py', '--app-version=1.0.0', @@ -391,9 +392,11 @@ class TestMakeApk(unittest.TestCase): manifest_path = os.path.join('test_data', 'manifest', 'manifest_app_launch_local_path.json') - cmd = ['python', 'make_apk.py', '--manifest=%s' % manifest_path, self._mode] + cmd = ['python', 'make_apk.py', '--manifest=%s' % manifest_path, + self._mode] out = RunCommand(cmd) - self.assertTrue(out.find('Please make sure that the local path file') != -1) + self.assertTrue( + out.find('Please make sure that the local path file') != -1) self.assertFalse(os.path.exists('Example.apk')) def testIconByOption(self): @@ -462,7 +465,8 @@ class TestMakeApk(unittest.TestCase): self.checkApks('Example', '1.0.0') def testKeystore(self): - keystore_path = os.path.join('test_data', 'keystore', 'xwalk-test.keystore') + keystore_path = os.path.join('test_data', 'keystore', + 'xwalk-test.keystore') cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0', '--package=org.xwalk.example', '--app-url=http://www.intel.com', '--keystore-path=%s' % keystore_path, '--keystore-alias=xwalk-test', @@ -481,7 +485,8 @@ class TestMakeApk(unittest.TestCase): def testManifest(self): manifest_path = os.path.join('test_data', 'manifest', 'manifest.json') - cmd = ['python', 'make_apk.py', '--manifest=%s' % manifest_path, self._mode] + cmd = ['python', 'make_apk.py', '--manifest=%s' % manifest_path, + self._mode] RunCommand(cmd) self.addCleanup(Clean, 'Example', '1.0.0') manifest = 'Example/AndroidManifest.xml' @@ -509,7 +514,8 @@ class TestMakeApk(unittest.TestCase): def testManifestWithSpecificValue(self): manifest_path = os.path.join('test_data', 'manifest', 'manifest_app_launch_local_path.json') - cmd = ['python', 'make_apk.py', '--manifest=%s' % manifest_path, self._mode] + cmd = ['python', 'make_apk.py', '--manifest=%s' % manifest_path, + self._mode] out = RunCommand(cmd) self.addCleanup(Clean, 'Example', '1.0.0') self.assertTrue(out.find('no app launch path') == -1) @@ -567,7 +573,8 @@ class TestMakeApk(unittest.TestCase): self.assertTrue(os.path.exists(extensions_config_json)) with open(extensions_config_json, 'r') as content_file: content = content_file.read() - self.assertTrue(content.find('xwalk-extensions/myextension/myextension.js')) + self.assertTrue( + content.find('xwalk-extensions/myextension/myextension.js')) self.assertTrue(content.find('com.example.extension.MyExtension')) extension_js = 'Example/assets/xwalk-extensions/myextension/myextension.js' self.assertTrue(os.path.exists(extension_js)) @@ -661,6 +668,28 @@ class TestMakeApk(unittest.TestCase): else: self.assertFalse(os.path.isfile('Example_1.0.0._arm.apk')) self.assertFalse(os.path.isfile('Example_1.0.0_x86.apk')) + Clean('Example', '1.0.0') + cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0', + '--package=org.xwalk.example', '--app-url=http://www.intel.com', + self._mode] + RunCommand(cmd) + if 'arm' in self.archs(): + self.assertTrue(os.path.isfile('Example_1.0.0_arm.apk')) + self.checkApk('Example_1.0.0_arm.apk', 'arm') + else: + self.assertFalse(os.path.isfile('Example_1.0.0._arm.apk')) + if 'x86' in self.archs(): + self.assertTrue(os.path.isfile('Example_1.0.0_x86.apk')) + self.checkApk('Example_1.0.0_x86.apk', 'x86') + else: + self.assertFalse(os.path.isfile('Example_1.0.0._x86.apk')) + Clean('Example', '1.0.0') + cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0', + '--package=org.xwalk.example', '--app-url=http://www.intel.com', + '--arch=undefined', self._mode] + out = RunCommand(cmd) + error_msg = 'invalid choice: \'undefined\'' + self.assertTrue(out.find(error_msg) != -1) def testVerbose(self): cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0', diff --git a/src/xwalk/app/tools/android/manifest_json_parser.py b/src/xwalk/app/tools/android/manifest_json_parser.py index 4f073ad..a38eaf3 100755 --- a/src/xwalk/app/tools/android/manifest_json_parser.py +++ b/src/xwalk/app/tools/android/manifest_json_parser.py @@ -19,6 +19,7 @@ import os import re import sys + def HandlePermissionList(permission_list): """This function is used to handle the permission list and return the string of permissions. @@ -41,8 +42,8 @@ def HandlePermissionList(permission_list): class ManifestJsonParser(object): - """ The class is used to parse json-format manifest file, recompose the fields - and provide the field interfaces required by the packaging tool. + """ The class is used to parse json-format manifest file, recompose the + fields and provide the field interfaces required by the packaging tool. Args: input_path: the full path of the json-format manifest file. @@ -98,8 +99,8 @@ class ManifestJsonParser(object): if 'launch_path' in self.data_src: app_url = self.data_src['launch_path'] elif ('app' in self.data_src and - 'launch' in self.data_src['app'] and - 'local_path' in self.data_src['app']['launch']): + 'launch' in self.data_src['app'] and + 'local_path' in self.data_src['app']['launch']): app_url = self.data_src['app']['launch']['local_path'] else: app_url = '' @@ -199,7 +200,6 @@ class ManifestJsonParser(object): print('launch_screen.landscape.image_border: %s' % self.GetLaunchScreenImageBorder('landscape')) - def GetAppName(self): """Return the application name.""" return self.ret_dict['app_name'] diff --git a/src/xwalk/app/tools/android/parse_xpk.py b/src/xwalk/app/tools/android/parse_xpk.py index 193c364..c67bd13 100755 --- a/src/xwalk/app/tools/android/parse_xpk.py +++ b/src/xwalk/app/tools/android/parse_xpk.py @@ -33,14 +33,14 @@ EXIT_CODE_XPK_FILE_IO_ERROR = 6 XPK_MAGIC_HEAD = 'CrWk' errorMessageMap = { - EXIT_CODE_CRYPTO_NOT_FOUND: 'Python module Crypto('\ - 'https://www.dlitz.net/software/pycrypto/) is needed', - EXIT_CODE_NO_XPK_FILE: 'Please specify XPK file by --file', - EXIT_CODE_XPK_FILE_NOT_EXIST: 'The XPK file you specified does not exist', - EXIT_CODE_MAGIC_FAILED: 'The file you specified is not in XPK format', - EXIT_CODE_VERIFICATION_FAILED: - 'Signature verification failed for the XPK file', - EXIT_CODE_XPK_FILE_IO_ERROR: 'Error happened when reading the XPK file', + EXIT_CODE_CRYPTO_NOT_FOUND: 'Python module Crypto('\ + 'https://www.dlitz.net/software/pycrypto/) is needed', + EXIT_CODE_NO_XPK_FILE: 'Please specify XPK file by --file', + EXIT_CODE_XPK_FILE_NOT_EXIST: 'The XPK file you specified does not exist', + EXIT_CODE_MAGIC_FAILED: 'The file you specified is not in XPK format', + EXIT_CODE_VERIFICATION_FAILED: + 'Signature verification failed for the XPK file', + EXIT_CODE_XPK_FILE_IO_ERROR: 'Error happened when reading the XPK file', } @@ -92,12 +92,12 @@ def main(): opts, _ = option_parser.parse_args() - if opts.file == None: + if opts.file is None: HandleError(EXIT_CODE_NO_XPK_FILE) app_name = os.path.splitext(os.path.basename(opts.file))[0] - if opts.out == None: + if opts.out is None: opts.out = app_name if os.path.isfile(opts.file): diff --git a/src/xwalk/application/browser/application.cc b/src/xwalk/application/browser/application.cc index 002f58d..a1023f8 100644 --- a/src/xwalk/application/browser/application.cc +++ b/src/xwalk/application/browser/application.cc @@ -115,10 +115,10 @@ bool Application::Launch(const LaunchParams& launch_params) { GURL Application::GetStartURL(const LaunchParams& params, LaunchEntryPoint* used) { - if (params.entry_points & URLKey) { - GURL url = GetURLFromURLKey(); + if (params.entry_points & StartURLKey) { + GURL url = GetURLFromRelativePathKey(keys::kStartURLKey); if (url.is_valid()) { - *used = URLKey; + *used = StartURLKey; return url; } } @@ -132,13 +132,22 @@ GURL Application::GetStartURL(const LaunchParams& params, } if (params.entry_points & LaunchLocalPathKey) { - GURL url = GetURLFromLocalPathKey(); + GURL url = GetURLFromRelativePathKey( + GetLaunchLocalPathKey(application_data_->GetPackageType())); if (url.is_valid()) { *used = LaunchLocalPathKey; return url; } } + if (params.entry_points & URLKey) { + GURL url = GetURLFromURLKey(); + if (url.is_valid()) { + *used = URLKey; + return url; + } + } + LOG(WARNING) << "Failed to find a valid launch URL for the app."; return GURL(); } @@ -170,12 +179,18 @@ ui::WindowShowState Application::GetWindowShowState( return ui::SHOW_STATE_DEFAULT; } -GURL Application::GetURLFromLocalPathKey() { +GURL Application::GetURLFromURLKey() { const Manifest* manifest = application_data_->GetManifest(); - std::string entry_page; - std::string key(GetLaunchLocalPathKey( - application_data_->GetPackageType())); + std::string url_string; + if (!manifest->GetString(keys::kURLKey, &url_string)) + return GURL(); + + return GURL(url_string); +} +GURL Application::GetURLFromRelativePathKey(const std::string& key) { + const Manifest* manifest = application_data_->GetManifest(); + std::string entry_page; if (!manifest->GetString(key, &entry_page) || entry_page.empty()) { if (application_data_->GetPackageType() == Manifest::TYPE_XPK) @@ -203,15 +218,6 @@ GURL Application::GetURLFromLocalPathKey() { return application_data_->GetResourceURL(entry_page); } -GURL Application::GetURLFromURLKey() { - const Manifest* manifest = application_data_->GetManifest(); - std::string url_string; - if (!manifest->GetString(keys::kURLKey, &url_string)) - return GURL(); - - return GURL(url_string); -} - void Application::Terminate(TerminationMode mode) { termination_mode_used_ = mode; if (IsTerminating()) { diff --git a/src/xwalk/application/browser/application.h b/src/xwalk/application/browser/application.h index fc0fb98..ff49ad8 100644 --- a/src/xwalk/application/browser/application.h +++ b/src/xwalk/application/browser/application.h @@ -53,10 +53,11 @@ class Application : public Runtime::Observer { // Manifest keys that can be used as application entry points. enum LaunchEntryPoint { - AppMainKey = 1 << 0, // app.main - LaunchLocalPathKey = 1 << 1, // app.launch.local_path - URLKey = 1 << 2, // url - Default = AppMainKey | LaunchLocalPathKey | URLKey + StartURLKey = 1 << 0, // start_url + AppMainKey = 1 << 1, // app.main + LaunchLocalPathKey = 1 << 2, // app.launch.local_path + URLKey = 1 << 3, // url + Default = StartURLKey | AppMainKey | LaunchLocalPathKey }; typedef unsigned LaunchEntryPoints; @@ -156,9 +157,10 @@ class Application : public Runtime::Observer { ui::WindowShowState GetWindowShowState(const LaunchParams& params); GURL GetURLFromAppMainKey(); - GURL GetURLFromLocalPathKey(); GURL GetURLFromURLKey(); + GURL GetURLFromRelativePathKey(const std::string& key); + friend class FinishEventObserver; void CloseMainDocument(); void NotifyTermination(); diff --git a/src/xwalk/application/browser/application_protocols.cc b/src/xwalk/application/browser/application_protocols.cc index d81fcd2..f96f844 100644 --- a/src/xwalk/application/browser/application_protocols.cc +++ b/src/xwalk/application/browser/application_protocols.cc @@ -320,7 +320,7 @@ ApplicationProtocolHandler::MaybeCreateJob( } std::list locales; - if (application->GetPackageType() == Manifest::TYPE_WGT) { + if (application && application->GetPackageType() == Manifest::TYPE_WGT) { GetUserAgentLocales( xwalk::XWalkRunner::GetInstance()->GetLocale(), locales); GetUserAgentLocales(application->GetManifest()->default_locale(), locales); diff --git a/src/xwalk/application/browser/application_service.cc b/src/xwalk/application/browser/application_service.cc index a99d8a3..628263d 100644 --- a/src/xwalk/application/browser/application_service.cc +++ b/src/xwalk/application/browser/application_service.cc @@ -31,7 +31,7 @@ #if defined(OS_TIZEN) #include "xwalk/application/browser/application_tizen.h" -#include "xwalk/application/browser/installer/tizen/service_package_installer.h" +#include "xwalk/application/browser/installer/tizen/package_installer.h" #endif namespace xwalk { @@ -159,30 +159,6 @@ void SaveSystemEventsInfo( } } -#if defined(OS_TIZEN) -bool InstallPackageOnTizen(ApplicationData* application_data, - const base::FilePath& data_dir) { - if (!XWalkRunner::GetInstance()->is_running_as_service()) { - LOG(ERROR) << "Installation on Tizen is only possible in" - << "service mode via 'xwalkctl' utility."; - return false; - } - - return InstallApplicationForTizen(application_data, data_dir); -} - -bool UninstallPackageOnTizen(ApplicationData* application_data, - const base::FilePath& data_dir) { - if (!XWalkRunner::GetInstance()->is_running_as_service()) { - LOG(ERROR) << "Uninstallation on Tizen is only possible in" - << "service mode using 'xwalkctl' utility."; - return false; - } - - return UninstallApplicationForTizen(application_data, data_dir); -} -#endif // OS_TIZEN - bool CopyDirectoryContents(const base::FilePath& from, const base::FilePath& to) { base::FileEnumerator iter(from, false, @@ -297,8 +273,8 @@ bool ApplicationService::Install(const base::FilePath& path, std::string* id) { } #if defined(OS_TIZEN) - if (!InstallPackageOnTizen(application_data, - runtime_context_->GetPath())) { + if (!PackageInstaller::InstallApplication( + application_data, runtime_context_->GetPath())) { application_storage_->RemoveApplication(application_data->ID()); return false; } @@ -404,30 +380,29 @@ bool ApplicationService::Update(const std::string& id, return false; } -#if defined(OS_TIZEN) - if (!UninstallPackageOnTizen(old_application, - runtime_context_->GetPath())) { + if (!application_storage_->UpdateApplication(new_application)) { + LOG(ERROR) << "Fail to update application, roll back to the old one."; base::DeleteFile(app_dir, true); base::Move(tmp_dir, app_dir); return false; } -#endif - if (!application_storage_->UpdateApplication(new_application)) { - LOG(ERROR) << "An Error occurred when updating the application."; +#if defined(OS_TIZEN) + if (!PackageInstaller::UpdateApplication( + new_application, runtime_context_->GetPath())) { + LOG(ERROR) << "Fail to update package on Tizen, roll back to the old one."; base::DeleteFile(app_dir, true); + if (!application_storage_->UpdateApplication(old_application)) { + LOG(ERROR) << "Fail to revert old application info, " + << "remove the application as a last resort."; + application_storage_->RemoveApplication(old_application->ID()); + return false; + } base::Move(tmp_dir, app_dir); -#if defined(OS_TIZEN) - InstallPackageOnTizen(old_application, - runtime_context_->GetPath()); -#endif return false; } -#if defined(OS_TIZEN) - if (!InstallPackageOnTizen(new_application, - runtime_context_->GetPath())) - return false; #endif + base::DeleteFile(tmp_dir, true); SaveSystemEventsInfo(new_application, this, event_manager_); @@ -455,8 +430,8 @@ bool ApplicationService::Uninstall(const std::string& id) { } #if defined(OS_TIZEN) - if (!UninstallPackageOnTizen(application, - runtime_context_->GetPath())) + if (!PackageInstaller::UninstallApplication( + application, runtime_context_->GetPath())) result = false; #endif diff --git a/src/xwalk/application/browser/installer/tizen/service_package_installer.cc b/src/xwalk/application/browser/installer/tizen/package_installer.cc similarity index 73% rename from src/xwalk/application/browser/installer/tizen/service_package_installer.cc rename to src/xwalk/application/browser/installer/tizen/package_installer.cc index 735bb67..26b2e7a 100644 --- a/src/xwalk/application/browser/installer/tizen/service_package_installer.cc +++ b/src/xwalk/application/browser/installer/tizen/package_installer.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "xwalk/application/browser/installer/tizen/service_package_installer.h" +#include "xwalk/application/browser/installer/tizen/package_installer.h" #include #include @@ -23,6 +23,7 @@ #include "xwalk/application/common/manifest_handlers/tizen_metadata_handler.h" #include "xwalk/application/browser/application_storage.h" #include "xwalk/application/browser/installer/tizen/packageinfo_constants.h" +#include "xwalk/runtime/browser/xwalk_runner.h" namespace info = xwalk::application_packageinfo_constants; @@ -63,7 +64,7 @@ class FileDeleter { }; void WriteMetaDataElement( - XmlWriter& writer, + XmlWriter& writer, // NOLINT xwalk::application::TizenMetaDataInfo* info) { if (!info) return; @@ -135,13 +136,24 @@ bool GeneratePkgInfoXml(xwalk::application::ApplicationData* application, return true; } +bool CheckRunningMode() { + if (xwalk::XWalkRunner::GetInstance()->is_running_as_service()) + return true; + LOG(ERROR) << "Package manipulation on Tizen is only possible in" + << "service mode using 'xwalkctl' utility."; + return false; +} + } // namespace namespace xwalk { namespace application { -bool InstallApplicationForTizen( +bool PackageInstaller::InstallApplication( ApplicationData* application, const base::FilePath& data_dir) { + if (!CheckRunningMode()) + return false; + std::string package_id = application->ID(); std::string tizen_app_id = kAppIdPrefix + package_id; base::FilePath app_dir = @@ -177,11 +189,8 @@ bool InstallApplicationForTizen( return false; } - base::FilePath icon; - if (icon_name.empty()) - icon = kDefaultIcon; - else - icon = app_dir.AppendASCII(icon_name); + base::FilePath icon = + icon_name.empty() ? kDefaultIcon : app_dir.AppendASCII(icon_name); CommandLine cmdline(kPkgHelper); cmdline.AppendSwitch("--install"); @@ -208,8 +217,11 @@ bool InstallApplicationForTizen( return true; } -bool UninstallApplicationForTizen(ApplicationData* application, - const base::FilePath& data_dir) { +bool PackageInstaller::UninstallApplication( + ApplicationData* application, const base::FilePath& data_dir) { + if (!CheckRunningMode()) + return false; + std::string package_id = application->ID(); bool result = true; @@ -248,5 +260,61 @@ bool UninstallApplicationForTizen(ApplicationData* application, return result; } +bool PackageInstaller::UpdateApplication( + ApplicationData* new_application, const base::FilePath& data_dir) { + if (!CheckRunningMode()) + return false; + + std::string package_id = new_application->ID(); + std::string tizen_app_id = kAppIdPrefix + package_id; + base::FilePath app_dir = + data_dir.AppendASCII(info::kAppDir).AppendASCII(package_id); + base::FilePath new_xml_path = data_dir.AppendASCII(info::kAppDir).AppendASCII( + package_id + ".new" + std::string(info::kXmlExtension)); + + std::string icon_name; + if (!new_application->GetManifest()->GetString(info::kIconKey, &icon_name)) { + LOG(WARNING) << "'icon' not included in manifest"; + } + // This will clean everything inside '/' and the new XML. + FileDeleter app_dir_cleaner(app_dir, true); + FileDeleter new_xml_cleaner(new_xml_path, true); + + if (!GeneratePkgInfoXml(new_application, icon_name, app_dir, new_xml_path)) { + LOG(ERROR) << "Could not create new XML metadata file '" + << new_xml_path.value() << "'."; + return false; + } + + base::FilePath icon = + icon_name.empty() ? kDefaultIcon : app_dir.AppendASCII(icon_name); + + CommandLine cmdline(kPkgHelper); + cmdline.AppendSwitch("--update"); + cmdline.AppendArg(package_id); + cmdline.AppendArgPath(new_xml_path); + cmdline.AppendArgPath(icon); + + int exit_code; + std::string output; + + if (!base::GetAppOutputWithExitCode(cmdline, &output, &exit_code)) { + LOG(ERROR) << "Could not launch installer helper"; + return false; + } + + if (exit_code != 0) { + LOG(ERROR) << "Could not update application: " + << output << " (" << exit_code << ")"; + return false; + } + + base::FilePath old_xml_path = data_dir.AppendASCII(info::kAppDir).AppendASCII( + package_id + std::string(info::kXmlExtension)); + base::Move(new_xml_path, old_xml_path); + app_dir_cleaner.Dismiss(); + return true; +} + } // namespace application } // namespace xwalk diff --git a/src/xwalk/application/browser/installer/tizen/package_installer.h b/src/xwalk/application/browser/installer/tizen/package_installer.h new file mode 100644 index 0000000..3ec6c71 --- /dev/null +++ b/src/xwalk/application/browser/installer/tizen/package_installer.h @@ -0,0 +1,29 @@ +// Copyright (c) 2014 Intel Corporation. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef XWALK_APPLICATION_BROWSER_INSTALLER_TIZEN_PACKAGE_INSTALLER_H_ +#define XWALK_APPLICATION_BROWSER_INSTALLER_TIZEN_PACKAGE_INSTALLER_H_ + +#include +#include "base/files/file_path.h" + +namespace xwalk { +namespace application { + +class ApplicationData; + +class PackageInstaller { + public: + static bool InstallApplication(ApplicationData* application, + const base::FilePath& data_dir); + static bool UninstallApplication(ApplicationData* application, + const base::FilePath& data_dir); + static bool UpdateApplication(ApplicationData* application, + const base::FilePath& data_dir); +}; + +} // namespace application +} // namespace xwalk + +#endif // XWALK_APPLICATION_BROWSER_INSTALLER_TIZEN_PACKAGE_INSTALLER_H_ diff --git a/src/xwalk/application/browser/installer/tizen/service_package_installer.h b/src/xwalk/application/browser/installer/tizen/service_package_installer.h deleted file mode 100644 index 431a12f..0000000 --- a/src/xwalk/application/browser/installer/tizen/service_package_installer.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2014 Intel Corporation. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef XWALK_APPLICATION_BROWSER_INSTALLER_TIZEN_SERVICE_PACKAGE_INSTALLER_H_ -#define XWALK_APPLICATION_BROWSER_INSTALLER_TIZEN_SERVICE_PACKAGE_INSTALLER_H_ - -#include -#include "base/files/file_path.h" - -namespace xwalk { -namespace application { - -class ApplicationData; - -bool InstallApplicationForTizen(ApplicationData* application, - const base::FilePath& data_dir); - -bool UninstallApplicationForTizen(ApplicationData* application, - const base::FilePath& data_dir); - -} // namespace application -} // namespace xwalk - -#endif // XWALK_APPLICATION_BROWSER_INSTALLER_TIZEN_SERVICE_PACKAGE_INSTALLER_H_ diff --git a/src/xwalk/application/browser/linux/installed_applications_manager.cc b/src/xwalk/application/browser/linux/installed_applications_manager.cc index 0e0a7ad..dd6e476 100644 --- a/src/xwalk/application/browser/linux/installed_applications_manager.cc +++ b/src/xwalk/application/browser/linux/installed_applications_manager.cc @@ -72,6 +72,13 @@ void InstalledApplicationsManager::OnApplicationUninstalled( adaptor_.RemoveManagedObject(GetInstalledPathForAppID(app_id)); } +void InstalledApplicationsManager::OnApplicationUpdated( + const std::string& app_id) { + if (scoped_refptr app = + app_storage_->GetApplicationData(app_id)) + OnApplicationNameChanged(app_id, app->Name()); +} + void InstalledApplicationsManager::OnApplicationNameChanged( const std::string& app_id, const std::string& app_name) { InstalledApplicationObject* object = diff --git a/src/xwalk/application/browser/linux/installed_applications_manager.h b/src/xwalk/application/browser/linux/installed_applications_manager.h index b294e43..35c0c75 100644 --- a/src/xwalk/application/browser/linux/installed_applications_manager.h +++ b/src/xwalk/application/browser/linux/installed_applications_manager.h @@ -34,6 +34,7 @@ class InstalledApplicationsManager : public ApplicationService::Observer { // ApplicationService::Observer implementation. void virtual OnApplicationInstalled(const std::string& app_id) OVERRIDE; void virtual OnApplicationUninstalled(const std::string& app_id) OVERRIDE; + void virtual OnApplicationUpdated(const std::string& app_id) OVERRIDE; void virtual OnApplicationNameChanged(const std::string& app_id, const std::string& app_name) OVERRIDE; diff --git a/src/xwalk/application/browser/linux/running_application_object.cc b/src/xwalk/application/browser/linux/running_application_object.cc index efba653..8c49e1a 100644 --- a/src/xwalk/application/browser/linux/running_application_object.cc +++ b/src/xwalk/application/browser/linux/running_application_object.cc @@ -134,11 +134,9 @@ void RunningApplicationObject::OnTerminate( void RunningApplicationObject::OnGetExtensionProcessChannel( dbus::MethodCall* method_call, dbus::ExportedObject::ResponseSender response_sender) { - content::BrowserThread::PostTaskAndReplyWithResult( + content::BrowserThread::PostTask( content::BrowserThread::FILE, FROM_HERE, - base::Bind(&RunningApplicationObject::CreateClientFileDescriptor, - base::Unretained(this)), base::Bind(&RunningApplicationObject::SendChannel, base::Unretained(this), method_call, @@ -194,24 +192,26 @@ void RunningApplicationObject::OnLauncherDisappeared() { TerminateApplication(Application::Immediate); } -scoped_ptr -RunningApplicationObject::CreateClientFileDescriptor() { - scoped_ptr client_fd( - new dbus::FileDescriptor(ep_bp_channel_.socket.fd)); - client_fd->CheckValidity(); - return client_fd.Pass(); -} - void RunningApplicationObject::SendChannel( dbus::MethodCall* method_call, - dbus::ExportedObject::ResponseSender response_sender, - scoped_ptr client_fd) { + dbus::ExportedObject::ResponseSender response_sender) { scoped_ptr response = dbus::Response::FromMethodCall(method_call); - dbus::MessageWriter writer(response.get()); + int fd = ep_bp_channel_.socket.fd; + if (fd == -1) { // EP was not yet created, return empty response. + response_sender.Run(response.Pass()); + return; + } + + dbus::MessageWriter writer(response.get()); writer.AppendString(ep_bp_channel_.name); + + scoped_ptr client_fd(new dbus::FileDescriptor(fd)); + client_fd->CheckValidity(); + CHECK(client_fd->is_valid()); writer.AppendFileDescriptor(*client_fd); + response_sender.Run(response.Pass()); } diff --git a/src/xwalk/application/browser/linux/running_application_object.h b/src/xwalk/application/browser/linux/running_application_object.h index 3dc2ad1..a1cf6ed 100644 --- a/src/xwalk/application/browser/linux/running_application_object.h +++ b/src/xwalk/application/browser/linux/running_application_object.h @@ -62,10 +62,8 @@ class RunningApplicationObject : public dbus::ManagedObject { void OnLauncherDisappeared(); - scoped_ptr CreateClientFileDescriptor(); void SendChannel(dbus::MethodCall* method_call, - dbus::ExportedObject::ResponseSender response_sender, - scoped_ptr client_fd); + dbus::ExportedObject::ResponseSender response_sender); scoped_refptr bus_; std::string launcher_name_; diff --git a/src/xwalk/application/common/application_manifest_constants.cc b/src/xwalk/application/common/application_manifest_constants.cc index 345e9a1..d48827f 100644 --- a/src/xwalk/application/common/application_manifest_constants.cc +++ b/src/xwalk/application/common/application_manifest_constants.cc @@ -30,6 +30,7 @@ const char kLaunchWebURLKey[] = "app.launch.web_url"; const char kManifestVersionKey[] = "manifest_version"; const char kNameKey[] = "name"; const char kPermissionsKey[] = "permissions"; +const char kStartURLKey[] = "start_url"; const char kURLKey[] = "url"; const char kVersionKey[] = "version"; const char kWebURLsKey[] = "app.urls"; diff --git a/src/xwalk/application/common/application_manifest_constants.h b/src/xwalk/application/common/application_manifest_constants.h index d7aee52..76c31d6 100644 --- a/src/xwalk/application/common/application_manifest_constants.h +++ b/src/xwalk/application/common/application_manifest_constants.h @@ -29,6 +29,7 @@ namespace application_manifest_keys { extern const char kManifestVersionKey[]; extern const char kNameKey[]; extern const char kPermissionsKey[]; + extern const char kStartURLKey[]; extern const char kURLKey[]; extern const char kVersionKey[]; extern const char kWebURLsKey[]; diff --git a/src/xwalk/application/test/application_multi_app_test.cc b/src/xwalk/application/test/application_multi_app_test.cc index 6ef78c9..cbbe34e 100644 --- a/src/xwalk/application/test/application_multi_app_test.cc +++ b/src/xwalk/application/test/application_multi_app_test.cc @@ -29,8 +29,7 @@ IN_PROC_BROWSER_TEST_F(ApplicationMultiAppTest, TestMultiApp) { test_runner_->WaitForTestNotification(); EXPECT_EQ(test_runner_->GetTestsResult(), ApiTestRunner::PASS); // The App1 has 2 pages: main doc page and "main.html" page. - EXPECT_EQ(app1->runtimes().size(), 2); - ASSERT_TRUE(app1->GetMainDocumentRuntime()); + EXPECT_EQ(app1->runtimes().size(), 1); EXPECT_EQ(service->active_applications().size(), currently_running_count + 1); EXPECT_EQ(service->GetApplicationByID(app1->id()), app1); @@ -51,8 +50,7 @@ IN_PROC_BROWSER_TEST_F(ApplicationMultiAppTest, TestMultiApp) { EXPECT_EQ(test_runner_->GetTestsResult(), ApiTestRunner::PASS); // The App2 also has 2 pages: main doc page and "main.html" page. - EXPECT_EQ(app2->runtimes().size(), 2); - ASSERT_TRUE(app2->GetMainDocumentRuntime()); + EXPECT_EQ(app2->runtimes().size(), 1); // Check that the apps have different IDs and RPH IDs. EXPECT_NE(app1->id(), app2->id()); diff --git a/src/xwalk/application/test/data/dummy_app1/main.js b/src/xwalk/application/test/data/dummy_app1/main.js deleted file mode 100644 index 1c81d3b..0000000 --- a/src/xwalk/application/test/data/dummy_app1/main.js +++ /dev/null @@ -1,4 +0,0 @@ -setTimeout( - function(){ - window.open("main.html"); - }, 100); diff --git a/src/xwalk/application/test/data/dummy_app1/manifest.json b/src/xwalk/application/test/data/dummy_app1/manifest.json index 7d9bcca..eee623c 100644 --- a/src/xwalk/application/test/data/dummy_app1/manifest.json +++ b/src/xwalk/application/test/data/dummy_app1/manifest.json @@ -2,9 +2,5 @@ "name": "dummy_app_1", "manifest_version": 1, "version": "1.0", - "app": { - "main": { - "scripts": ["main.js"] - } - } + "start_url": "main.html" } diff --git a/src/xwalk/application/test/data/dummy_app2/main.js b/src/xwalk/application/test/data/dummy_app2/main.js deleted file mode 100644 index 1c81d3b..0000000 --- a/src/xwalk/application/test/data/dummy_app2/main.js +++ /dev/null @@ -1,4 +0,0 @@ -setTimeout( - function(){ - window.open("main.html"); - }, 100); diff --git a/src/xwalk/application/test/data/dummy_app2/manifest.json b/src/xwalk/application/test/data/dummy_app2/manifest.json index f3f7da2..230e609 100644 --- a/src/xwalk/application/test/data/dummy_app2/manifest.json +++ b/src/xwalk/application/test/data/dummy_app2/manifest.json @@ -2,9 +2,5 @@ "name": "dummy_app_2", "manifest_version": 1, "version": "1.0", - "app": { - "main": { - "scripts": ["main.js"] - } - } + "start_url": "main.html" } diff --git a/src/xwalk/application/tools/linux/xwalk_launcher_main.cc b/src/xwalk/application/tools/linux/xwalk_launcher_main.cc index 2982c59..420e1a4 100644 --- a/src/xwalk/application/tools/linux/xwalk_launcher_main.cc +++ b/src/xwalk/application/tools/linux/xwalk_launcher_main.cc @@ -92,27 +92,30 @@ static void on_app_properties_changed(GDBusProxy* proxy, } } -static gboolean init_extension_process_channel(gpointer data) { - GDBusProxy* app_proxy = static_cast(data); +static gboolean init_extension_process_channel(GDBusProxy* app_proxy) { if (ep_launcher->is_started()) return FALSE; + // Get the client socket file descriptor from fd_list. The reply will // contains an index to the list. GUnixFDList* fd_list; GVariant* res = g_dbus_proxy_call_with_unix_fd_list_sync( app_proxy, "GetEPChannel", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &fd_list, NULL, NULL); + if (!res || g_variant_n_children(res) != 2) + return FALSE; + const gchar* channel_id = g_variant_get_string(g_variant_get_child_value(res, 0), NULL); - if (!strlen(channel_id)) - return TRUE; + if (!channel_id || !strlen(channel_id)) + return FALSE; gint32 client_fd_idx = g_variant_get_handle(g_variant_get_child_value(res, 1)); int client_fd = g_unix_fd_list_get(fd_list, client_fd_idx, NULL); ep_launcher->Launch(channel_id, client_fd); - return FALSE; + return TRUE; } static void on_app_signal(GDBusProxy* proxy, @@ -224,7 +227,7 @@ static void launch_application(GDBusObjectManager* running_apps_manager, } #endif - g_idle_add(init_extension_process_channel, app_proxy); + init_extension_process_channel(app_proxy); g_main_loop_run(mainloop); } diff --git a/src/xwalk/application/tools/linux/xwalkctl_main.cc b/src/xwalk/application/tools/linux/xwalkctl_main.cc index 261cdef..a3ae744 100644 --- a/src/xwalk/application/tools/linux/xwalkctl_main.cc +++ b/src/xwalk/application/tools/linux/xwalkctl_main.cc @@ -8,6 +8,7 @@ #include #include +#include #include "xwalk/application/tools/linux/dbus_connection.h" #include "xwalk/application/tools/linux/xwalk_tizen_user.h" @@ -172,6 +173,7 @@ static void list_applications(GDBusObjectManager* installed) { } int main(int argc, char* argv[]) { + setlocale(LC_ALL, ""); GError* error = NULL; GOptionContext* context; bool success; diff --git a/src/xwalk/application/tools/tizen/xwalk_pkg_helper.cc b/src/xwalk/application/tools/tizen/xwalk_package_helper.cc similarity index 79% rename from src/xwalk/application/tools/tizen/xwalk_pkg_helper.cc rename to src/xwalk/application/tools/tizen/xwalk_package_helper.cc index 10babd0..968b17f 100644 --- a/src/xwalk/application/tools/tizen/xwalk_pkg_helper.cc +++ b/src/xwalk/application/tools/tizen/xwalk_package_helper.cc @@ -10,7 +10,7 @@ #include "base/files/file_path.h" #include "base/file_util.h" -#include "xwalk/application/tools/tizen/xwalk_pkg_installer.h" +#include "xwalk/application/tools/tizen/xwalk_package_installer_helper.h" namespace { @@ -20,6 +20,7 @@ int usage(const char* program) { fprintf(stdout, "Usage: \n" "\t%s --install \n" "\t%s --uninstall \n", + "\t%s --update \n", program, program); return 1; } @@ -40,17 +41,22 @@ int main(int argc, char *argv[]) { return 1;; } - PkgInstaller installer(argv[2]); + PackageInstallerHelper helper(argv[2]); if (!strcmp(argv[1], "--install")) { if (argc != 5) return usage(argv[0]); - result = installer.InstallApplication(argv[3], argv[4]); + result = helper.InstallApplication(argv[3], argv[4]); } else if (!strcmp(argv[1], "--uninstall")) { if (argc != 3) return usage(argv[0]); - result = installer.UninstallApplication(); + result = helper.UninstallApplication(); + } else if (!strcmp(argv[1], "--update")) { + if (argc != 5) + return usage(argv[0]); + + result = helper.UpdateApplication(argv[3], argv[4]); } else { return usage(argv[0]); } diff --git a/src/xwalk/application/tools/tizen/xwalk_pkg_installer.cc b/src/xwalk/application/tools/tizen/xwalk_package_installer_helper.cc similarity index 68% rename from src/xwalk/application/tools/tizen/xwalk_pkg_installer.cc rename to src/xwalk/application/tools/tizen/xwalk_package_installer_helper.cc index f1144aa..f39d6ce 100644 --- a/src/xwalk/application/tools/tizen/xwalk_pkg_installer.cc +++ b/src/xwalk/application/tools/tizen/xwalk_package_installer_helper.cc @@ -2,13 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "xwalk/application/tools/tizen/xwalk_pkg_installer.h" +#include "xwalk/application/tools/tizen/xwalk_package_installer_helper.h" #include #include -#if defined(OS_TIZEN) #include -#endif #undef LOG #include @@ -36,6 +34,9 @@ const char PKGMGR_START_INSTALL[] = "install"; // Value for uninstallation. const char PKGMGR_START_UNINSTALL[] = "uninstall"; +// Value for update. +const char PKGMGR_START_UPDATE[] = "update"; + // Notification about end of installation with status. const char PKGMGR_END_KEY[] = "end"; @@ -69,29 +70,57 @@ class FileDeleter { bool recursive_; }; +const char* ToEndStatus(bool result) { + return result ? PKGMGR_END_SUCCESS : PKGMGR_END_FAILURE; +} + } // namespace -PkgInstaller::PkgInstaller(const std::string& appid) +PackageInstallerHelper::PackageInstallerHelper(const std::string& appid) : appid_(appid) { if (appid_.empty()) fprintf(stdout, "Invalid app id is provided for pkg installer.\n"); -#if defined(OS_TIZEN) handle_ = pkgmgr_installer_new(); if (!handle_) fprintf(stdout, "Fail to get package manager installer handle.\n"); -#endif } -PkgInstaller::~PkgInstaller() { -#if defined(OS_TIZEN) +PackageInstallerHelper::~PackageInstallerHelper() { if (handle_) pkgmgr_installer_free(handle_); -#endif } -bool PkgInstaller::InstallApplication(const std::string& xmlpath, - const std::string& iconpath) { +bool PackageInstallerHelper::InstallApplication( + const std::string& xmlpath, + const std::string& iconpath) { + SendSignal(PKGMGR_START_KEY, PKGMGR_START_INSTALL); + bool ret = InstallApplicationInternal(xmlpath, iconpath); + SendSignal(PKGMGR_END_KEY, ToEndStatus(ret)); + return ret; +} + +bool PackageInstallerHelper::UninstallApplication() { + SendSignal(PKGMGR_START_KEY, PKGMGR_START_UNINSTALL); + bool ret = UninstallApplicationInternal(); + SendSignal(PKGMGR_END_KEY, ToEndStatus(ret)); + return ret; +} + +bool PackageInstallerHelper::UpdateApplication( + const std::string& xmlpath, + const std::string& iconpath) { + SendSignal(PKGMGR_START_KEY, PKGMGR_START_UPDATE); + bool ret = UninstallApplicationInternal(); + if (ret) + ret = InstallApplicationInternal(xmlpath, iconpath); + SendSignal(PKGMGR_END_KEY, ToEndStatus(ret)); + return ret; +} + +bool PackageInstallerHelper::InstallApplicationInternal( + const std::string& xmlpath, + const std::string& iconpath) { if (xmlpath.empty() || iconpath.empty()) { fprintf(stdout, "Invalid xml path or icon path for installation\n"); } @@ -118,12 +147,10 @@ bool PkgInstaller::InstallApplication(const std::string& xmlpath, return false; } -#if defined(OS_TIZEN) - if (!ParseManifest(PkgInstaller::INSTALL, xmlpath)) { - fprintf(stdout, "Couldn't install %s'\n", appid_.c_str()); + if (pkgmgr_parser_parse_manifest_for_installation(xmlpath.c_str(), NULL)) { + fprintf(stdout, "Couldn't parse manifest XML '%s'\n", xmlpath.c_str()); return false; } -#endif FileDeleter xml_cleaner(xml_dst, false); icon_cleaner.Dismiss(); @@ -132,7 +159,7 @@ bool PkgInstaller::InstallApplication(const std::string& xmlpath, return true; } -bool PkgInstaller::UninstallApplication() { +bool PackageInstallerHelper::UninstallApplicationInternal() { bool result = true; // FIXME(vcgomes): Add support for more icon types @@ -146,59 +173,23 @@ bool PkgInstaller::UninstallApplication() { base::FilePath xmlpath(kXmlDir); xmlpath = xmlpath.Append(kServicePrefix + std::string(appid_) + ".xml"); -#if defined(OS_TIZEN) - if (!ParseManifest(PkgInstaller::UNINSTALL, xmlpath.MaybeAsASCII())) { - fprintf(stdout, "Couldn't uninstall %s'\n", appid_.c_str()); + std::string xmlpath_str = xmlpath.MaybeAsASCII(); + assert(!xmlpath_str.empty()); + if (pkgmgr_parser_parse_manifest_for_uninstallation( + xmlpath_str.c_str(), NULL)) { + fprintf(stdout, "Couldn't parse manifest XML '%s'\n", xmlpath_str.c_str()); result = false; } -#endif if (!base::DeleteFile(xmlpath, false)) { - fprintf(stdout, "Couldn't delete '%s'\n", xmlpath.value().c_str()); + fprintf(stdout, "Couldn't delete '%s'\n", xmlpath_str.c_str()); result = false; } return result; } -#if defined(OS_TIZEN) -bool PkgInstaller::ParseManifest(PkgInstaller::RequestType type, - const std::string& xmlpath) { - std::string pkgmgr_cmd; - PkgParser parser; - switch (type) { - case PkgInstaller::INSTALL: - pkgmgr_cmd = PKGMGR_START_INSTALL; - parser = pkgmgr_parser_parse_manifest_for_installation; - break; - - case PkgInstaller::UNINSTALL: - pkgmgr_cmd = PKGMGR_START_UNINSTALL; - parser = pkgmgr_parser_parse_manifest_for_uninstallation; - break; - - default: - assert(false); - fprintf(stdout, "Setting unknown command for package manager."); - return false; - } - - SendSignal(PKGMGR_START_KEY, pkgmgr_cmd); - - bool result = parser(xmlpath.c_str(), NULL); - - if (result) { - fprintf(stdout, "Couldn't parse manifest XML '%s'\n", xmlpath.c_str()); - SendSignal(PKGMGR_END_KEY, PKGMGR_END_FAILURE); - return false; - } else { - SendSignal(PKGMGR_END_KEY, PKGMGR_END_SUCCESS); - } - - return true; -} - -bool PkgInstaller::SendSignal( +bool PackageInstallerHelper::SendSignal( const std::string& key, const std::string& value) { if (!handle_) { @@ -219,4 +210,3 @@ bool PkgInstaller::SendSignal( return true; } -#endif diff --git a/src/xwalk/application/tools/tizen/xwalk_package_installer_helper.h b/src/xwalk/application/tools/tizen/xwalk_package_installer_helper.h new file mode 100644 index 0000000..e61571f --- /dev/null +++ b/src/xwalk/application/tools/tizen/xwalk_package_installer_helper.h @@ -0,0 +1,34 @@ +// Copyright (c) 2014 Intel Corporation. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef XWALK_APPLICATION_TOOLS_TIZEN_XWALK_PACKAGE_INSTALLER_HELPER_H_ +#define XWALK_APPLICATION_TOOLS_TIZEN_XWALK_PACKAGE_INSTALLER_HELPER_H_ + +#include + +#include + +class PackageInstallerHelper { + public: + explicit PackageInstallerHelper(const std::string& appid); + ~PackageInstallerHelper(); + bool InstallApplication(const std::string& xmlpath, + const std::string& iconpath); + bool UninstallApplication(); + bool UpdateApplication(const std::string& xmlpath, + const std::string& iconpath); + + private: + bool InstallApplicationInternal(const std::string& xmlpath, + const std::string& iconpath); + bool UninstallApplicationInternal(); + + bool SendSignal(const std::string& key, const std::string& value); + + pkgmgr_installer* handle_; + + std::string appid_; +}; + +#endif // XWALK_APPLICATION_TOOLS_TIZEN_XWALK_PACKAGE_INSTALLER_HELPER_H_ diff --git a/src/xwalk/application/tools/tizen/xwalk_pkg_installer.h b/src/xwalk/application/tools/tizen/xwalk_pkg_installer.h deleted file mode 100644 index 3e59eea..0000000 --- a/src/xwalk/application/tools/tizen/xwalk_pkg_installer.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2014 Intel Corporation. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef XWALK_APPLICATION_TOOLS_TIZEN_XWALK_PKG_INSTALLER_H_ -#define XWALK_APPLICATION_TOOLS_TIZEN_XWALK_PKG_INSTALLER_H_ - -#if defined(OS_TIZEN) -#include -#endif - -#include - -class PkgInstaller { - public: - explicit PkgInstaller(const std::string& appid); - ~PkgInstaller(); - bool InstallApplication(const std::string& xmlpath, - const std::string& iconpath); - bool UninstallApplication(); - - private: -#if defined(OS_TIZEN) - enum RequestType { - INSTALL, - UNINSTALL - }; - bool ParseManifest(RequestType type, const std::string& xmlpath); - bool SendSignal(const std::string& key, const std::string& value); - - pkgmgr_installer* handle_; -#endif - - std::string appid_; -}; - -#endif // XWALK_APPLICATION_TOOLS_TIZEN_XWALK_PKG_INSTALLER_H_ diff --git a/src/xwalk/application/tools/tizen/xwalk_tizen_helper.gyp b/src/xwalk/application/tools/tizen/xwalk_tizen_helper.gyp index 415ef01..061f6ca 100644 --- a/src/xwalk/application/tools/tizen/xwalk_tizen_helper.gyp +++ b/src/xwalk/application/tools/tizen/xwalk_tizen_helper.gyp @@ -4,26 +4,17 @@ 'target_name': 'xwalk-pkg-helper', 'type': 'executable', 'product_name': 'xwalk-pkg-helper', - 'conditions': [ - ['tizen==1', { - 'dependencies': [ - '../../../build/system.gyp:tizen', - '../../../../base/base.gyp:base', - ], - }], - ['OS=="linux"', { - 'dependencies': [ - '../../../../base/base.gyp:base', - ], - }], + 'dependencies': [ + '../../../build/system.gyp:tizen', + '../../../../base/base.gyp:base', ], 'include_dirs': [ '../../../..', ], 'sources': [ - 'xwalk_pkg_helper.cc', - 'xwalk_pkg_installer.cc', - 'xwalk_pkg_installer.h', + 'xwalk_package_helper.cc', + 'xwalk_package_installer_helper.cc', + 'xwalk_package_installer_helper.h', ], }, ], diff --git a/src/xwalk/application/xwalk_application.gypi b/src/xwalk/application/xwalk_application.gypi index d114e2d..a744d32 100644 --- a/src/xwalk/application/xwalk_application.gypi +++ b/src/xwalk/application/xwalk_application.gypi @@ -124,8 +124,8 @@ 'browser/application_tizen.h', 'browser/installer/tizen/packageinfo_constants.cc', 'browser/installer/tizen/packageinfo_constants.h', - 'browser/installer/tizen/service_package_installer.cc', - 'browser/installer/tizen/service_package_installer.h', + 'browser/installer/tizen/package_installer.cc', + 'browser/installer/tizen/package_installer.h', 'common/manifest_handlers/navigation_handler.cc', 'common/manifest_handlers/navigation_handler.h', 'common/manifest_handlers/tizen_application_handler.cc', @@ -188,6 +188,10 @@ 'dependencies': [ 'application/tools/linux/xwalk_application_tools.gyp:xwalkctl', 'application/tools/linux/xwalk_application_tools.gyp:xwalk_launcher', + ], + }], + ['tizen == 1', { + 'dependencies': [ 'application/tools/tizen/xwalk_tizen_helper.gyp:xwalk-pkg-helper', ], }], diff --git a/src/xwalk/packaging/crosswalk.spec b/src/xwalk/packaging/crosswalk.spec index 113af1c..dfa8db1 100644 --- a/src/xwalk/packaging/crosswalk.spec +++ b/src/xwalk/packaging/crosswalk.spec @@ -2,7 +2,7 @@ %bcond_with wayland Name: crosswalk -Version: 7.35.136.0 +Version: 7.35.138.0 Release: 0 Summary: Crosswalk is an app runtime based on Chromium License: (BSD-3-Clause and LGPL-2.1+) diff --git a/src/xwalk/runtime/browser/android/xwalk_content.h b/src/xwalk/runtime/browser/android/xwalk_content.h index ca6b799..06dcec0 100644 --- a/src/xwalk/runtime/browser/android/xwalk_content.h +++ b/src/xwalk/runtime/browser/android/xwalk_content.h @@ -48,11 +48,11 @@ class XWalkContent { XWalkRenderViewHostExt* render_view_host_ext() { return render_view_host_ext_.get(); - }; + } XWalkContentsClientBridge* GetContentsClientBridge() { return contents_client_bridge_.get(); - }; + } void SetJsOnlineProperty(JNIEnv* env, jobject obj, jboolean network_up); jboolean SetManifest(JNIEnv* env, @@ -74,10 +74,15 @@ class XWalkContent { jobject delegate); JavaObjectWeakGlobalRef java_ref_; - scoped_ptr web_contents_; + // TODO(guangzhen): The WebContentsDelegate need to take ownership of + // WebContents as chrome content design. For xwalk, XWalkContent owns + // these two, we need to redesign XWalkContent in the future. + // Currently as a workaround, below declaration order makes sure + // the WebContents destructed before WebContentsDelegate. scoped_ptr web_contents_delegate_; scoped_ptr render_view_host_ext_; scoped_ptr contents_client_bridge_; + scoped_ptr web_contents_; // GURL is supplied by the content layer as requesting frame. // Callback is supplied by the content layer, and is invoked with the result diff --git a/src/xwalk/test/android/core/javatests/src/org/xwalk/core/xwview/test/GetTitleTest.java b/src/xwalk/test/android/core/javatests/src/org/xwalk/core/xwview/test/GetTitleTest.java new file mode 100644 index 0000000..4ddfc4f --- /dev/null +++ b/src/xwalk/test/android/core/javatests/src/org/xwalk/core/xwview/test/GetTitleTest.java @@ -0,0 +1,43 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Copyright (c) 2014 Intel Corporation. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +package org.xwalk.core.xwview.test; + +import android.test.suitebuilder.annotation.SmallTest; + +import org.chromium.base.test.util.Feature; + +/** + * Test suite for getTitle(). + */ +public class GetTitleTest extends XWalkViewTestBase { + final String mTitle = "Crosswalk Sample Application"; + + @Override + public void setUp() throws Exception { + super.setUp(); + + setXWalkClient(new XWalkViewTestBase.TestXWalkClient()); + } + + @SmallTest + @Feature({"GetTitle"}) + public void testGetTitle() throws Throwable { + final String url = "file:///android_asset/www/index.html"; + + loadUrlSync(url); + assertEquals(mTitle, getTitleOnUiThread()); + } + + @SmallTest + @Feature({"GetTitle"}) + public void testGetTitleWithData() throws Throwable { + final String name = "index.html"; + final String fileContent = getFileContent(name); + + loadDataSync(name, fileContent, "text/html", false); + assertEquals(mTitle, getTitleOnUiThread()); + } +} diff --git a/src/xwalk/xwalk.gyp b/src/xwalk/xwalk.gyp index e5c01b1..629f1dc 100644 --- a/src/xwalk/xwalk.gyp +++ b/src/xwalk/xwalk.gyp @@ -44,7 +44,6 @@ '../content/content.gyp:content_renderer', '../content/content.gyp:content_utility', '../content/content.gyp:content_worker', - '../content/content_resources.gyp:content_resources', '../ipc/ipc.gyp:ipc', '../media/media.gyp:media', '../net/net.gyp:net', @@ -460,7 +459,6 @@ '<(SHARED_INTERMEDIATE_DIR)/xwalk/xwalk_application_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/xwalk/xwalk_extensions_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/xwalk/xwalk_sysapps_resources.pak', - '<(SHARED_INTERMEDIATE_DIR)/content/content_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak', '<(SHARED_INTERMEDIATE_DIR)/ui/app_locale_settings/app_locale_settings_en-US.pak', '<(SHARED_INTERMEDIATE_DIR)/ui/ui_strings/ui_strings_en-US.pak', diff --git a/src/xwalk/xwalk_core_library_android.gypi b/src/xwalk/xwalk_core_library_android.gypi index f6e9927..1c3cda4 100644 --- a/src/xwalk/xwalk_core_library_android.gypi +++ b/src/xwalk/xwalk_core_library_android.gypi @@ -65,6 +65,11 @@ '*org/xwalk/*', ], }, + 'all_dependent_settings': { + 'variables': { + 'input_jars_paths': ['<(jar_final_path)'], + }, + }, 'actions': [ { 'action_name': 'jar_<(_target_name)', @@ -98,15 +103,6 @@ 'classes_dir': '<(PRODUCT_DIR)/<(_target_name)/classes', 'jar_name': '<(_target_name).jar', 'jar_final_path': '<(PRODUCT_DIR)/lib.java/<(jar_name)', - #TODO(wang16): figure out why the 'jar_final_path' defined in chromium_generated_java - # not added into following all_dependent_settings setting chain. - # BUG=https://crosswalk-project.org/jira/browse/XWALK-1575 - 'input_jars_paths': ['<(PRODUCT_DIR)/lib.java/chromium_generated_java.jar'], - }, - 'all_dependent_settings': { - 'variables': { - 'input_jars_paths': ['<(jar_final_path)'], - }, }, 'actions': [ {