From eef2abddbd43c41aa5b0f7f619c6305448a8ac64 Mon Sep 17 00:00:00 2001 From: Eurogiciel-BOT Date: Thu, 22 May 2014 17:57:12 +0000 Subject: [PATCH] Upstream version 7.35.141.0 Upstream commit-id c5788f3264fa300c1ec82a465bf8461f88c9fa34 Change-Id: I49c331816dc92ea2b5d743bdb08131e4367af5f4 Signed-off-by: Eurogiciel-BOT --- packaging/crosswalk.spec | 2 +- .../Source/platform/RuntimeEnabledFeatures.in | 2 +- src/xwalk/DEPS.xwalk | 2 +- src/xwalk/VERSION | 2 +- src/xwalk/app/tools/android/customize.py | 2 +- .../app/tools/android/customize_launch_screen.py | 4 +- src/xwalk/application/browser/application.cc | 6 +- .../application/browser/application_protocols.cc | 2 +- .../application/browser/application_service.cc | 5 +- src/xwalk/application/browser/application_tizen.cc | 2 +- src/xwalk/application/browser/installer/package.h | 8 +++ .../application/browser/installer/wgt_package.cc | 1 + .../application/browser/installer/xpk_package.cc | 1 + src/xwalk/application/common/application_data.cc | 18 +++--- src/xwalk/application/common/application_data.h | 5 +- .../application/common/application_file_util.cc | 42 +++++++++++--- .../application/common/application_file_util.h | 3 + .../common/application_manifest_constants.cc | 28 +++++----- .../common/application_manifest_constants.h | 14 ++--- src/xwalk/application/common/manifest.cc | 5 -- src/xwalk/application/common/manifest.h | 13 +---- src/xwalk/application/common/manifest_handler.cc | 12 ++-- src/xwalk/application/common/manifest_handler.h | 4 +- .../common/manifest_handler_unittest.cc | 6 +- .../common/manifest_handlers/csp_handler.cc | 4 +- .../common/manifest_handlers/csp_handler.h | 4 +- .../manifest_handlers/warp_handler_unittest.cc | 4 +- .../common/manifest_handlers/widget_handler.cc | 29 ++++++---- .../manifest_handlers/widget_handler_unittest.cc | 4 +- .../extension/application_widget_api.js | 65 +++++++++++++++------- src/xwalk/packaging/crosswalk.spec | 2 +- .../runtime/browser/xwalk_browser_main_parts.cc | 7 ++- 32 files changed, 188 insertions(+), 120 deletions(-) diff --git a/packaging/crosswalk.spec b/packaging/crosswalk.spec index 0175610..95cab71 100644 --- a/packaging/crosswalk.spec +++ b/packaging/crosswalk.spec @@ -12,7 +12,7 @@ %endif Name: crosswalk -Version: 7.35.139.0 +Version: 7.35.141.0 Release: 0 Summary: Crosswalk is an app runtime based on Chromium License: (BSD-3-Clause and LGPL-2.1+) diff --git a/src/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in b/src/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in index 422f5ab..42f853c 100644 --- a/src/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in +++ b/src/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in @@ -108,7 +108,7 @@ SpeechSynthesis status=stable Srcset status=stable Stream status=experimental StyleScoped status=experimental -SubpixelFontScaling status=experimental +SubpixelFontScaling status=stable SubresourceIntegrity status=test SVGPaintOrder status=stable diff --git a/src/xwalk/DEPS.xwalk b/src/xwalk/DEPS.xwalk index f050240..a7eca55 100644 --- a/src/xwalk/DEPS.xwalk +++ b/src/xwalk/DEPS.xwalk @@ -8,7 +8,7 @@ # If using trunk, will use '.DEPS.git' for gclient. chromium_version = '35.0.1916.114' chromium_crosswalk_point = 'e76fa1eeaea6745b72a693cf746e5d3d8ece1bef' -blink_crosswalk_point = 'daeb6d961b90b90572c916653e86ce91a59daa0b' +blink_crosswalk_point = '3cf743afc1a77a1141f08897c4f2c3b805124f25' v8_crosswalk_point = '64b8b78dee87a9d465f9d095e2021bdb9d45d37d' ozone_wayland_point = 'f4faec532d7d2f482b3ffe1e52be6fa3e6fc8629' diff --git a/src/xwalk/VERSION b/src/xwalk/VERSION index 85a3369..7068d33 100644 --- a/src/xwalk/VERSION +++ b/src/xwalk/VERSION @@ -1,4 +1,4 @@ MAJOR=7 MINOR=35 -BUILD=139 +BUILD=141 PATCH=0 diff --git a/src/xwalk/app/tools/android/customize.py b/src/xwalk/app/tools/android/customize.py index 416378c..d2cc6de 100755 --- a/src/xwalk/app/tools/android/customize.py +++ b/src/xwalk/app/tools/android/customize.py @@ -161,7 +161,7 @@ def CustomizeThemeXML(name, fullscreen, app_manifest): EditElementValueByNodeName(theme_xmldoc, 'item', 'android:windowBackground', '@drawable/launchscreen_bg') - theme_file = open(theme_path, 'wb') + theme_file = open(theme_path, 'w') theme_xmldoc.writexml(theme_file, encoding='utf-8') theme_file.close() diff --git a/src/xwalk/app/tools/android/customize_launch_screen.py b/src/xwalk/app/tools/android/customize_launch_screen.py index b44f180..4626b77 100755 --- a/src/xwalk/app/tools/android/customize_launch_screen.py +++ b/src/xwalk/app/tools/android/customize_launch_screen.py @@ -64,11 +64,11 @@ def CopyDrawables(image_dict, orientation, sanitized_name, name, app_root): # If no supported images found, find the closest one as 1x. if not has_image: closest = '' - delta = sys.maxint + delta = sys.maxsize for(k, v) in image_dict.items(): items = k.split('x') if len(items) == 2: - float_value = sys.maxint + float_value = sys.maxsize try: float_value = float(items[0]) except ValueError: diff --git a/src/xwalk/application/browser/application.cc b/src/xwalk/application/browser/application.cc index f6c4b6f..ead1f35 100644 --- a/src/xwalk/application/browser/application.cc +++ b/src/xwalk/application/browser/application.cc @@ -156,7 +156,7 @@ GURL Application::GetURLFromRelativePathKey(const std::string& key) { std::string entry_page; if (!manifest->GetString(key, &entry_page) || entry_page.empty()) { - if (data_->GetPackageType() == Manifest::TYPE_XPK) + if (data_->GetPackageType() == Package::XPK) return GURL(); base::FileEnumerator iter(data_->Path(), true, @@ -322,7 +322,7 @@ bool Application::SetPermission(PermissionType type, } void Application::InitSecurityPolicy() { - if (data_->GetPackageType() != Manifest::TYPE_WGT) + if (data_->GetPackageType() != Package::WGT) return; const WARPInfo* info = static_cast( @@ -375,7 +375,7 @@ bool Application::CanRequestURL(const GURL& url) const { return true; // Only WGT package need to check the url request permission. - if (data_->GetPackageType() != Manifest::TYPE_WGT) + if (data_->GetPackageType() != Package::WGT) return true; // Always can request itself resources. diff --git a/src/xwalk/application/browser/application_protocols.cc b/src/xwalk/application/browser/application_protocols.cc index 6302a3d..be917ca 100644 --- a/src/xwalk/application/browser/application_protocols.cc +++ b/src/xwalk/application/browser/application_protocols.cc @@ -260,7 +260,7 @@ ApplicationProtocolHandler::MaybeCreateJob( const std::string& path = request->url().path(); std::list locales; - if (application && application->GetPackageType() == Manifest::TYPE_WGT) { + if (application && application->GetPackageType() == Package::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 f4cdcb8..c0395c5 100644 --- a/src/xwalk/application/browser/application_service.cc +++ b/src/xwalk/application/browser/application_service.cc @@ -107,7 +107,8 @@ bool ApplicationService::Install(const base::FilePath& path, std::string* id) { std::string error; scoped_refptr application_data = LoadApplication( - unpacked_dir, app_id, Manifest::COMMAND_LINE, &error); + unpacked_dir, app_id, Manifest::COMMAND_LINE, + package->type(), &error); if (!application_data) { LOG(ERROR) << "Error during application installation: " << error; return false; @@ -208,6 +209,7 @@ bool ApplicationService::Update(const std::string& id, LoadApplication(unpacked_dir, app_id, Manifest::COMMAND_LINE, + package->type(), &error); if (!new_application) { LOG(ERROR) << "An error occurred during application updating: " << error; @@ -245,6 +247,7 @@ bool ApplicationService::Update(const std::string& id, new_application = LoadApplication(app_dir, app_id, Manifest::COMMAND_LINE, + package->type(), &error); if (!new_application) { LOG(ERROR) << "Error during loading new package: " << error; diff --git a/src/xwalk/application/browser/application_tizen.cc b/src/xwalk/application/browser/application_tizen.cc index c77f894..5c14fe6 100644 --- a/src/xwalk/application/browser/application_tizen.cc +++ b/src/xwalk/application/browser/application_tizen.cc @@ -70,7 +70,7 @@ void ApplicationTizen::InitSecurityPolicy() { return; } - if (data_->GetPackageType() != Manifest::TYPE_WGT) + if (data_->GetPackageType() != Package::WGT) return; // Always enable security mode when under CSP mode. diff --git a/src/xwalk/application/browser/installer/package.h b/src/xwalk/application/browser/installer/package.h index c946844..d78aa82 100644 --- a/src/xwalk/application/browser/installer/package.h +++ b/src/xwalk/application/browser/installer/package.h @@ -22,14 +22,21 @@ namespace application { // XPKPackage::Validate() class Package { public: + enum Type { + WGT, + XPK + }; + virtual ~Package(); bool IsValid() const { return is_valid_; } const std::string& Id() const { return id_; } + Type type() const { return type_; } // Factory method for creating a package static scoped_ptr Create(const base::FilePath& path); // The function will unzip the XPK/WGT file and return the target path where // to decompress by the parameter |target_path|. virtual bool Extract(base::FilePath* target_path); + protected: explicit Package(const base::FilePath& source_path); scoped_ptr file_; @@ -42,6 +49,7 @@ class Package { base::ScopedTempDir temp_dir_; // Represent if the package has been extracted. bool is_extracted_; + Type type_; }; } // namespace application diff --git a/src/xwalk/application/browser/installer/wgt_package.cc b/src/xwalk/application/browser/installer/wgt_package.cc index 9ce643d..729bd3b 100644 --- a/src/xwalk/application/browser/installer/wgt_package.cc +++ b/src/xwalk/application/browser/installer/wgt_package.cc @@ -25,6 +25,7 @@ WGTPackage::WGTPackage(const base::FilePath& path) : Package(path) { if (!base::PathExists(path)) return; + type_ = WGT; base::FilePath extracted_path; if (!Extract(&extracted_path)) return; diff --git a/src/xwalk/application/browser/installer/xpk_package.cc b/src/xwalk/application/browser/installer/xpk_package.cc index 7c084ac..b95aaeb 100644 --- a/src/xwalk/application/browser/installer/xpk_package.cc +++ b/src/xwalk/application/browser/installer/xpk_package.cc @@ -25,6 +25,7 @@ XPKPackage::XPKPackage(const base::FilePath& path) : Package(path) { if (!base::PathExists(path)) return; + type_ = XPK; scoped_ptr file( new ScopedStdioHandle(base::OpenFile(path, "rb"))); file_ = file.Pass(); diff --git a/src/xwalk/application/common/application_data.cc b/src/xwalk/application/common/application_data.cc index 4f8f289..fbe69fb 100644 --- a/src/xwalk/application/common/application_data.cc +++ b/src/xwalk/application/common/application_data.cc @@ -151,10 +151,6 @@ bool ApplicationData::IsHostedApp() const { return GetManifest()->IsHosted(); } -Manifest::PackageType ApplicationData::GetPackageType() const { - return manifest_->GetPackageType(); -} - // static bool ApplicationData::InitApplicationID(xwalk::application::Manifest* manifest, const base::FilePath& path, @@ -197,6 +193,10 @@ ApplicationData::ApplicationData(const base::FilePath& path, finished_parsing_manifest_(false) { DCHECK(path.empty() || path.IsAbsolute()); path_ = path; + if (manifest_->HasPath(widget_keys::kWidgetKey)) + package_type_ = Package::WGT; + else + package_type_ = Package::XPK; } ApplicationData::~ApplicationData() { @@ -255,7 +255,7 @@ bool ApplicationData::LoadName(base::string16* error) { std::string name_key(GetNameKey(GetPackageType())); if (!manifest_->GetString(name_key, &localized_name) && - manifest_->IsXPKPackaged()) { + package_type_ == Package::XPK) { *error = base::ASCIIToUTF16(errors::kInvalidName); return false; } @@ -271,12 +271,12 @@ bool ApplicationData::LoadVersion(base::string16* error) { std::string version_key(GetVersionKey(GetPackageType())); if (!manifest_->GetString(version_key, &version_str) && - manifest_->IsXPKPackaged()) { + package_type_ == Package::XPK) { *error = base::ASCIIToUTF16(errors::kInvalidVersion); return false; } version_.reset(new base::Version(version_str)); - if (manifest_->IsXPKPackaged() && + if (package_type_ == Package::XPK && (!version_->IsValid() || version_->components().size() > 4)) { *error = base::ASCIIToUTF16(errors::kInvalidVersion); return false; @@ -288,7 +288,7 @@ bool ApplicationData::LoadDescription(base::string16* error) { DCHECK(error); if (manifest_->HasKey(keys::kDescriptionKey) && !manifest_->GetString(keys::kDescriptionKey, &description_) && - manifest_->IsXPKPackaged()) { + package_type_ == Package::XPK) { *error = base::ASCIIToUTF16(errors::kInvalidDescription); return false; } @@ -303,7 +303,7 @@ bool ApplicationData::LoadManifestVersion(base::string16* error) { int manifest_version = 1; if (!manifest_->GetInteger(keys::kManifestVersionKey, &manifest_version) || manifest_version < 1) { - if (manifest_->IsXPKPackaged()) { + if (package_type_ == Package::XPK) { *error = base::ASCIIToUTF16(errors::kInvalidManifestVersion); return false; } diff --git a/src/xwalk/application/common/application_data.h b/src/xwalk/application/common/application_data.h index 1f1fd00..e00216a 100644 --- a/src/xwalk/application/common/application_data.h +++ b/src/xwalk/application/common/application_data.h @@ -131,7 +131,7 @@ class ApplicationData : public base::RefCountedThreadSafe { void ClearPermissions(); PermissionSet GetManifestPermissions() const; - Manifest::PackageType GetPackageType() const; + Package::Type GetPackageType() const { return package_type_; } #if defined(OS_TIZEN) bool HasCSPDefined() const; @@ -223,6 +223,9 @@ class ApplicationData : public base::RefCountedThreadSafe { // Application's persistent permissions. StoredPermissionMap permission_map_; + // The package type, wgt or xpk. + Package::Type package_type_; + DISALLOW_COPY_AND_ASSIGN(ApplicationData); }; diff --git a/src/xwalk/application/common/application_file_util.cc b/src/xwalk/application/common/application_file_util.cc index 798c911..9b8b00f 100644 --- a/src/xwalk/application/common/application_file_util.cc +++ b/src/xwalk/application/common/application_file_util.cc @@ -25,6 +25,7 @@ #include "net/base/file_stream.h" #include "third_party/libxml/src/include/libxml/tree.h" #include "ui/base/l10n/l10n_util.h" +#include "xwalk/application/browser/installer/package.h" #include "xwalk/application/common/application_data.h" #include "xwalk/application/common/application_manifest_constants.h" #include "xwalk/application/common/constants.h" @@ -151,6 +152,27 @@ inline bool IsElementSupportSpanAndDir(xmlNode* root) { return false; } +bool GetPackageType(const base::FilePath& path, + xwalk::application::Package::Type* package_type, + std::string* error) { + base::FilePath manifest_path; + + manifest_path = path.Append(xwalk::application::kManifestXpkFilename); + if (base::PathExists(manifest_path)) { + *package_type = xwalk::application::Package::XPK; + return true; + } + + manifest_path = path.Append(xwalk::application::kManifestWgtFilename); + if (base::PathExists(manifest_path)) { + *package_type = xwalk::application::Package::WGT; + return true; + } + + *error = base::StringPrintf("%s", errors::kManifestUnreadable); + return false; +} + } // namespace namespace xwalk { @@ -273,17 +295,22 @@ scoped_refptr LoadApplication( const base::FilePath& application_path, Manifest::SourceType source_type, std::string* error) { + Package::Type package_type; + if (!GetPackageType(application_path, &package_type, error)) + return NULL; + return LoadApplication(application_path, std::string(), - source_type, error); + source_type, package_type, error); } scoped_refptr LoadApplication( const base::FilePath& application_path, const std::string& application_id, Manifest::SourceType source_type, + Package::Type package_type, std::string* error) { scoped_ptr manifest( - LoadManifest(application_path, error)); + LoadManifest(application_path, package_type, error)); if (!manifest.get()) return NULL; @@ -299,8 +326,8 @@ scoped_refptr LoadApplication( std::vector warnings; ManifestHandlerRegistry* registry = manifest->HasKey(widget_keys::kWidgetKey) - ? ManifestHandlerRegistry::GetInstance(Manifest::TYPE_WGT) - : ManifestHandlerRegistry::GetInstance(Manifest::TYPE_XPK); + ? ManifestHandlerRegistry::GetInstance(Package::WGT) + : ManifestHandlerRegistry::GetInstance(Package::XPK); if (!registry->ValidateAppManifest(application, error, &warnings)) return NULL; @@ -368,15 +395,16 @@ static base::DictionaryValue* LoadManifestWgt( } base::DictionaryValue* LoadManifest(const base::FilePath& application_path, - std::string* error) { + Package::Type package_type, + std::string* error) { base::FilePath manifest_path; manifest_path = application_path.Append(kManifestXpkFilename); - if (base::PathExists(manifest_path)) + if (package_type == Package::XPK) return LoadManifestXpk(manifest_path, error); manifest_path = application_path.Append(kManifestWgtFilename); - if (base::PathExists(manifest_path)) + if (package_type == Package::WGT) return LoadManifestWgt(manifest_path, error); *error = base::StringPrintf("%s", errors::kManifestUnreadable); diff --git a/src/xwalk/application/common/application_file_util.h b/src/xwalk/application/common/application_file_util.h index 23bcf10..cb22f50 100644 --- a/src/xwalk/application/common/application_file_util.h +++ b/src/xwalk/application/common/application_file_util.h @@ -9,6 +9,7 @@ #include #include "base/memory/ref_counted.h" +#include "xwalk/application/browser/installer/package.h" #include "xwalk/application/common/manifest.h" @@ -37,11 +38,13 @@ scoped_refptr LoadApplication( const base::FilePath& application_root, const std::string& application_id, Manifest::SourceType source_type, + Package::Type package_type, std::string* error); // Loads an application manifest from the specified directory. Returns NULL // on failure, with a description of the error in |error|. base::DictionaryValue* LoadManifest(const base::FilePath& application_root, + Package::Type package_type, std::string* error); // Get a relative file path from an app:// URL. diff --git a/src/xwalk/application/common/application_manifest_constants.cc b/src/xwalk/application/common/application_manifest_constants.cc index fccddfc..5419345 100644 --- a/src/xwalk/application/common/application_manifest_constants.cc +++ b/src/xwalk/application/common/application_manifest_constants.cc @@ -119,51 +119,51 @@ const char kPlatformAppNeedsManifestVersion2[] = namespace application { -const char* GetNameKey(Manifest::PackageType package_type) { - if (package_type == Manifest::TYPE_WGT) +const char* GetNameKey(Package::Type package_type) { + if (package_type == Package::WGT) return application_widget_keys::kNameKey; return application_manifest_keys::kNameKey; } -const char* GetVersionKey(Manifest::PackageType package_type) { - if (package_type == Manifest::TYPE_WGT) +const char* GetVersionKey(Package::Type package_type) { + if (package_type == Package::WGT) return application_widget_keys::kVersionKey; return application_manifest_keys::kVersionKey; } -const char* GetWebURLsKey(Manifest::PackageType package_type) { - if (package_type == Manifest::TYPE_WGT) +const char* GetWebURLsKey(Package::Type package_type) { + if (package_type == Package::WGT) return application_widget_keys::kWebURLsKey; return application_manifest_keys::kWebURLsKey; } -const char* GetLaunchLocalPathKey(Manifest::PackageType package_type) { - if (package_type == Manifest::TYPE_WGT) +const char* GetLaunchLocalPathKey(Package::Type package_type) { + if (package_type == Package::WGT) return application_widget_keys::kLaunchLocalPathKey; return application_manifest_keys::kLaunchLocalPathKey; } -const char* GetCSPKey(Manifest::PackageType package_type) { - if (package_type == Manifest::TYPE_WGT) +const char* GetCSPKey(Package::Type package_type) { + if (package_type == Package::WGT) return application_widget_keys::kCSPKey; return application_manifest_keys::kCSPKey; } #if defined(OS_TIZEN) -const char* GetTizenAppIdKey(Manifest::PackageType package_type) { - if (package_type == Manifest::TYPE_WGT) +const char* GetTizenAppIdKey(Package::Type package_type) { + if (package_type == Package::WGT) return application_widget_keys::kTizenAppIdKey; return application_manifest_keys::kTizenAppIdKey; } -const char* GetIcon128Key(Manifest::PackageType package_type) { - if (package_type == Manifest::TYPE_WGT) +const char* GetIcon128Key(Package::Type package_type) { + if (package_type == Package::WGT) return application_widget_keys::kIcon128Key; return application_manifest_keys::kIcon128Key; diff --git a/src/xwalk/application/common/application_manifest_constants.h b/src/xwalk/application/common/application_manifest_constants.h index 4fcb394..839e2c2 100644 --- a/src/xwalk/application/common/application_manifest_constants.h +++ b/src/xwalk/application/common/application_manifest_constants.h @@ -98,14 +98,14 @@ namespace application_manifest_errors { namespace application { typedef application::Manifest Manifest; -const char* GetNameKey(Manifest::PackageType type); -const char* GetVersionKey(Manifest::PackageType type); -const char* GetWebURLsKey(Manifest::PackageType type); -const char* GetLaunchLocalPathKey(Manifest::PackageType type); -const char* GetCSPKey(Manifest::PackageType type); +const char* GetNameKey(Package::Type type); +const char* GetVersionKey(Package::Type type); +const char* GetWebURLsKey(Package::Type type); +const char* GetLaunchLocalPathKey(Package::Type type); +const char* GetCSPKey(Package::Type type); #if defined(OS_TIZEN) -const char* GetTizenAppIdKey(Manifest::PackageType type); -const char* GetIcon128Key(Manifest::PackageType type); +const char* GetTizenAppIdKey(Package::Type type); +const char* GetIcon128Key(Package::Type type); #endif } // namespace application } // namespace xwalk diff --git a/src/xwalk/application/common/manifest.cc b/src/xwalk/application/common/manifest.cc index 36c816c..43d225f 100644 --- a/src/xwalk/application/common/manifest.cc +++ b/src/xwalk/application/common/manifest.cc @@ -82,11 +82,6 @@ Manifest::Manifest(SourceType source_type, if (data_->HasKey(widget_keys::kWidgetKey) && data_->Get(widget_keys::kWidgetKey, NULL)) - package_type_ = TYPE_WGT; - else - package_type_ = TYPE_XPK; - - if (IsWGTPackaged()) ParseWGTI18n(); // Unittest may not have an xwalkrunner, so we should check here. diff --git a/src/xwalk/application/common/manifest.h b/src/xwalk/application/common/manifest.h index d484404..cbe6eb6 100644 --- a/src/xwalk/application/common/manifest.h +++ b/src/xwalk/application/common/manifest.h @@ -14,6 +14,7 @@ #include "base/memory/scoped_ptr.h" #include "base/strings/string16.h" #include "base/values.h" +#include "xwalk/application/browser/installer/package.h" #include "xwalk/application/common/install_warning.h" namespace xwalk { @@ -39,12 +40,6 @@ class Manifest { TYPE_PACKAGED_APP }; - enum PackageType { - TYPE_WGT = 0, - TYPE_XPK - }; - - Manifest(SourceType source_type, scoped_ptr value); virtual ~Manifest(); @@ -71,10 +66,6 @@ class Manifest { bool IsPackaged() const { return type_ == TYPE_PACKAGED_APP; } bool IsHosted() const { return type_ == TYPE_HOSTED_APP; } - PackageType GetPackageType() const { return package_type_; } - bool IsXPKPackaged() const { return package_type_ == TYPE_XPK; } - bool IsWGTPackaged() const { return package_type_ == TYPE_WGT; } - // These access the wrapped manifest value, returning false when the property // does not exist or if the manifest type can't access it. bool HasKey(const std::string& key) const; @@ -146,8 +137,6 @@ class Manifest { Type type_; - PackageType package_type_; - DISALLOW_COPY_AND_ASSIGN(Manifest); }; diff --git a/src/xwalk/application/common/manifest_handler.cc b/src/xwalk/application/common/manifest_handler.cc index 7b364d4..7a2e32c 100644 --- a/src/xwalk/application/common/manifest_handler.cc +++ b/src/xwalk/application/common/manifest_handler.cc @@ -59,8 +59,8 @@ ManifestHandlerRegistry::~ManifestHandlerRegistry() { } ManifestHandlerRegistry* -ManifestHandlerRegistry::GetInstance(Manifest::PackageType package_type) { - if (package_type == Manifest::TYPE_WGT) +ManifestHandlerRegistry::GetInstance(Package::Type package_type) { + if (package_type == Package::WGT) return GetInstanceForWGT(); return GetInstanceForXPK(); } @@ -75,7 +75,7 @@ ManifestHandlerRegistry::GetInstanceForWGT() { handlers.push_back(new WidgetHandler); handlers.push_back(new WARPHandler); #if defined(OS_TIZEN) - handlers.push_back(new CSPHandler(Manifest::TYPE_WGT)); + handlers.push_back(new CSPHandler(Package::WGT)); handlers.push_back(new NavigationHandler); handlers.push_back(new TizenApplicationHandler); handlers.push_back(new TizenSettingHandler); @@ -93,7 +93,7 @@ ManifestHandlerRegistry::GetInstanceForXPK() { std::vector handlers; // FIXME: Add manifest handlers here like this: // handlers.push_back(new xxxHandler); - handlers.push_back(new CSPHandler(Manifest::TYPE_XPK)); + handlers.push_back(new CSPHandler(Package::XPK)); handlers.push_back(new PermissionsHandler); xpk_registry_ = new ManifestHandlerRegistry(handlers); return xpk_registry_; @@ -143,8 +143,8 @@ bool ManifestHandlerRegistry::ValidateAppManifest( // static void ManifestHandlerRegistry::SetInstanceForTesting( - ManifestHandlerRegistry* registry, Manifest::PackageType package_type) { - if (package_type == Manifest::TYPE_WGT) { + ManifestHandlerRegistry* registry, Package::Type package_type) { + if (package_type == Package::WGT) { widget_registry_ = registry; return; } diff --git a/src/xwalk/application/common/manifest_handler.h b/src/xwalk/application/common/manifest_handler.h index 9091cba..5176589 100644 --- a/src/xwalk/application/common/manifest_handler.h +++ b/src/xwalk/application/common/manifest_handler.h @@ -56,7 +56,7 @@ class ManifestHandlerRegistry { ~ManifestHandlerRegistry(); static ManifestHandlerRegistry* GetInstance( - Manifest::PackageType package_type); + Package::Type package_type); bool ParseAppManifest( scoped_refptr application, base::string16* error); @@ -77,7 +77,7 @@ class ManifestHandlerRegistry { // Sets a new global registry, for testing purposes. static void SetInstanceForTesting(ManifestHandlerRegistry* registry, - Manifest::PackageType package_type); + Package::Type package_type); static ManifestHandlerRegistry* GetInstanceForWGT(); static ManifestHandlerRegistry* GetInstanceForXPK(); diff --git a/src/xwalk/application/common/manifest_handler_unittest.cc b/src/xwalk/application/common/manifest_handler_unittest.cc index 55755f3..a6c3f7e 100644 --- a/src/xwalk/application/common/manifest_handler_unittest.cc +++ b/src/xwalk/application/common/manifest_handler_unittest.cc @@ -32,14 +32,14 @@ class ScopedTestingManifestHandlerRegistry { : registry_( new ManifestHandlerRegistry(handlers)), prev_registry_( - ManifestHandlerRegistry::GetInstance(Manifest::TYPE_XPK)) { + ManifestHandlerRegistry::GetInstance(Package::XPK)) { ManifestHandlerRegistry::SetInstanceForTesting( - registry_.get(), Manifest::TYPE_XPK); + registry_.get(), Package::XPK); } ~ScopedTestingManifestHandlerRegistry() { ManifestHandlerRegistry::SetInstanceForTesting( - prev_registry_, Manifest::TYPE_XPK); + prev_registry_, Package::XPK); } scoped_ptr registry_; diff --git a/src/xwalk/application/common/manifest_handlers/csp_handler.cc b/src/xwalk/application/common/manifest_handlers/csp_handler.cc index 0317936..48863e0 100644 --- a/src/xwalk/application/common/manifest_handlers/csp_handler.cc +++ b/src/xwalk/application/common/manifest_handlers/csp_handler.cc @@ -21,7 +21,7 @@ CSPInfo::CSPInfo() { CSPInfo::~CSPInfo() { } -CSPHandler::CSPHandler(Manifest::PackageType type) +CSPHandler::CSPHandler(Package::Type type) : package_type_(type) { } @@ -62,7 +62,7 @@ bool CSPHandler::Parse(scoped_refptr application, } bool CSPHandler::AlwaysParseForType(Manifest::Type type) const { - return package_type_ == Manifest::TYPE_XPK; + return package_type_ == Package::XPK; } std::vector CSPHandler::Keys() const { diff --git a/src/xwalk/application/common/manifest_handlers/csp_handler.h b/src/xwalk/application/common/manifest_handlers/csp_handler.h index 6861d74..071520d 100644 --- a/src/xwalk/application/common/manifest_handlers/csp_handler.h +++ b/src/xwalk/application/common/manifest_handlers/csp_handler.h @@ -32,7 +32,7 @@ class CSPInfo : public ApplicationData::ManifestData { class CSPHandler : public ManifestHandler { public: - explicit CSPHandler(Manifest::PackageType type); + explicit CSPHandler(Package::Type type); virtual ~CSPHandler(); virtual bool Parse(scoped_refptr application, @@ -41,7 +41,7 @@ class CSPHandler : public ManifestHandler { virtual std::vector Keys() const OVERRIDE; private: - Manifest::PackageType package_type_; + Package::Type package_type_; DISALLOW_COPY_AND_ASSIGN(CSPHandler); }; diff --git a/src/xwalk/application/common/manifest_handlers/warp_handler_unittest.cc b/src/xwalk/application/common/manifest_handlers/warp_handler_unittest.cc index 494102d..cc6c2dd 100644 --- a/src/xwalk/application/common/manifest_handlers/warp_handler_unittest.cc +++ b/src/xwalk/application/common/manifest_handlers/warp_handler_unittest.cc @@ -52,7 +52,7 @@ TEST_F(WARPHandlerTest, OneWARP) { manifest.Set(keys::kAccessKey, warp); scoped_refptr application = CreateApplication(); EXPECT_TRUE(application.get()); - EXPECT_EQ(application->GetPackageType(), Manifest::TYPE_WGT); + EXPECT_EQ(application->GetPackageType(), Package::WGT); const WARPInfo* info = GetWARPInfo(application); EXPECT_TRUE(info); scoped_ptr list(info->GetWARP()->DeepCopy()); @@ -76,7 +76,7 @@ TEST_F(WARPHandlerTest, WARPs) { scoped_refptr application = CreateApplication(); EXPECT_TRUE(application.get()); - EXPECT_EQ(application->GetPackageType(), Manifest::TYPE_WGT); + EXPECT_EQ(application->GetPackageType(), Package::WGT); const WARPInfo* info = GetWARPInfo(application); EXPECT_TRUE(info); diff --git a/src/xwalk/application/common/manifest_handlers/widget_handler.cc b/src/xwalk/application/common/manifest_handlers/widget_handler.cc index ec29744..084a353 100644 --- a/src/xwalk/application/common/manifest_handlers/widget_handler.cc +++ b/src/xwalk/application/common/manifest_handlers/widget_handler.cc @@ -6,7 +6,7 @@ #include #include -#include +#include #include "base/strings/utf_string_conversions.h" #include "base/strings/stringprintf.h" @@ -58,22 +58,28 @@ const KeyMap& GetWidgetKeyPairs() { return map; } -void ParsePreferenceItem(const base::DictionaryValue* in_value, - base::DictionaryValue* out_value) { +bool ParsePreferenceItem(const base::DictionaryValue* in_value, + base::DictionaryValue* out_value, + std::set* used) { DCHECK(in_value && in_value->IsType(base::Value::TYPE_DICTIONARY)); std::string pref_name; std::string pref_value; std::string pref_readonly; - if (in_value->GetString(keys::kPreferencesNameKey, &pref_name)) + if (in_value->GetString(keys::kPreferencesNameKey, &pref_name) + && used->find(pref_name) == used->end()) { out_value->SetString(kPreferencesName, pref_name); + used->insert(pref_name); + } else { + return false; + } if (in_value->GetString(keys::kPreferencesValueKey, &pref_value)) out_value->SetString(kPreferencesValue, pref_value); - if (in_value->GetString(keys::kPreferencesReadonlyKey, &pref_readonly)) { - out_value->SetBoolean(kPreferencesReadonly, pref_readonly == "true"); - } + if (in_value->GetString(keys::kPreferencesReadonlyKey, &pref_readonly)) + out_value->SetBoolean(kPreferencesReadonly, pref_readonly == "true"); + return true; } } // namespace @@ -126,12 +132,13 @@ bool WidgetHandler::Parse(scoped_refptr application, base::Value* pref_value = NULL; manifest->Get(keys::kPreferencesKey, &pref_value); + std::set preference_names_used; if (pref_value && pref_value->IsType(base::Value::TYPE_DICTIONARY)) { base::DictionaryValue* preferences = new base::DictionaryValue; base::DictionaryValue* dict; pref_value->GetAsDictionary(&dict); - ParsePreferenceItem(dict, preferences); - widget_info->Set(kPreferences, preferences); + if (ParsePreferenceItem(dict, preferences, &preference_names_used)) + widget_info->Set(kPreferences, preferences); } else if (pref_value && pref_value->IsType(base::Value::TYPE_LIST)) { base::ListValue* preferences = new base::ListValue; base::ListValue* list; @@ -142,8 +149,8 @@ bool WidgetHandler::Parse(scoped_refptr application, base::DictionaryValue* pref = new base::DictionaryValue; base::DictionaryValue* dict; (*it)->GetAsDictionary(&dict); - ParsePreferenceItem(dict, pref); - preferences->Append(pref); + if (ParsePreferenceItem(dict, pref, &preference_names_used)) + preferences->Append(pref); } widget_info->Set(kPreferences, preferences); } diff --git a/src/xwalk/application/common/manifest_handlers/widget_handler_unittest.cc b/src/xwalk/application/common/manifest_handlers/widget_handler_unittest.cc index 6fecbdd..17ab4aa 100644 --- a/src/xwalk/application/common/manifest_handlers/widget_handler_unittest.cc +++ b/src/xwalk/application/common/manifest_handlers/widget_handler_unittest.cc @@ -161,7 +161,7 @@ TEST_F(WidgetHandlerTest, scoped_refptr application; application = CreateApplication(*(manifest.get())); EXPECT_TRUE(application); - EXPECT_EQ(application->GetPackageType(), Manifest::TYPE_WGT); + EXPECT_EQ(application->GetPackageType(), Package::WGT); // Get widget info from this application. WidgetInfo* info = GetWidgetInfo(application); EXPECT_TRUE(info); @@ -193,7 +193,7 @@ TEST_F(WidgetHandlerTest, scoped_refptr application; application = CreateApplication(*(manifest.get())); EXPECT_TRUE(application); - EXPECT_EQ(application->GetPackageType(), Manifest::TYPE_WGT); + EXPECT_EQ(application->GetPackageType(), Package::WGT); // Get widget info from this application. WidgetInfo* info = GetWidgetInfo(application); EXPECT_TRUE(info); diff --git a/src/xwalk/application/extension/application_widget_api.js b/src/xwalk/application/extension/application_widget_api.js index 2c64ad0..7bd9005 100644 --- a/src/xwalk/application/extension/application_widget_api.js +++ b/src/xwalk/application/extension/application_widget_api.js @@ -46,14 +46,49 @@ for (var key in widgetStringInfo) { var WidgetStorage = function() { var _keyList = new Array(); + var _itemStorage = new Object(); + + var _SetItem = function(itemKey, itemValue) { + var result = extension.internal.sendSyncMessage({ + cmd: 'SetPreferencesItem', + preferencesItemKey: String(itemKey), + preferencesItemValue: String(itemValue) }); + + if (result) { + if (_itemStorage[String(itemKey)] == undefined) + _keyList.push(String(itemKey)); + _itemStorage[String(itemKey)] = String(itemValue); + return itemValue; + } else { + throw new common.CustomDOMException( + common.CustomDOMException.NO_MODIFICATION_ALLOWED_ERR, + 'The object can not be modified.'); + } + } + + var _GetSetter = function(itemKey) { + var _itemKey = itemKey; + return function(itemValue) { + return _SetItem(_itemKey, itemValue); + } + } + + var _GetGetter = function(itemKey) { + var _itemKey = itemKey; + return function() { + return _itemStorage[String(_itemKey)]; + } + } this.init = function() { var result = extension.internal.sendSyncMessage( { cmd: 'GetAllItems' }); for (var itemKey in result) { - var itemValue = result[itemKey]; - this[itemKey] = itemValue; - _keyList.push(itemKey); + var itemValue = result[String(itemKey)]; + _itemStorage[String(itemKey)] = itemValue; + this.__defineSetter__(String(itemKey), _GetSetter(itemKey)); + this.__defineGetter__(String(itemKey), _GetGetter(itemKey)); + _keyList.push(String(itemKey)); } } @@ -66,25 +101,13 @@ var WidgetStorage = function() { } this.getItem = function(itemKey) { - return this[String(itemKey)]; - } + return _itemStorage[String(_itemKey)]; + } this.setItem = function(itemKey, itemValue) { - var result = extension.internal.sendSyncMessage({ - cmd: 'SetPreferencesItem', - preferencesItemKey: String(itemKey), - preferencesItemValue: String(itemValue) }); + return _SetItem(_itemKey, itemValue); + } - if (result) { - this[String(itemKey)] = String(itemValue); - _keyList.push(String(itemKey)); - } else { - throw new common.CustomDOMException( - common.CustomDOMException.NO_MODIFICATION_ALLOWED_ERR, - 'The object can not be modified.'); - } - }; - this.removeItem = function(itemKey) { var result = extension.internal.sendSyncMessage({ cmd: 'RemovePreferencesItem', @@ -92,7 +115,8 @@ var WidgetStorage = function() { if (result) { delete this[itemKey]; - delete _keyList[_keyList.indexOf(String(itemKey))]; + delete _itemStorage[itemKey]; + _keyList.splice(_keyList.indexOf(String(itemKey)), 1); } else { throw new common.CustomDOMException( common.CustomDOMException.NO_MODIFICATION_ALLOWED_ERR, @@ -117,6 +141,7 @@ var WidgetStorage = function() { if (!exists) { delete this[_keyList[i]]; + delete _itemStorage[_keyList[i]]; _keyList.splice(i, 1); } } diff --git a/src/xwalk/packaging/crosswalk.spec b/src/xwalk/packaging/crosswalk.spec index 0175610..95cab71 100644 --- a/src/xwalk/packaging/crosswalk.spec +++ b/src/xwalk/packaging/crosswalk.spec @@ -12,7 +12,7 @@ %endif Name: crosswalk -Version: 7.35.139.0 +Version: 7.35.141.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/xwalk_browser_main_parts.cc b/src/xwalk/runtime/browser/xwalk_browser_main_parts.cc index 62ffc55..9e11b8e 100644 --- a/src/xwalk/runtime/browser/xwalk_browser_main_parts.cc +++ b/src/xwalk/runtime/browser/xwalk_browser_main_parts.cc @@ -139,10 +139,15 @@ void XWalkBrowserMainParts::RegisterExternalExtensions() { CommandLine* cmd_line = CommandLine::ForCurrentProcess(); #if defined(OS_TIZEN) - static const std::string tec_path = "/usr/lib/tizen-extensions-crosswalk"; std::string value = cmd_line->GetSwitchValueASCII( switches::kXWalkExternalExtensionsPath); +#if defined(ARCH_CPU_64_BITS) + const char tec_path[] = "/usr/lib64/tizen-extensions-crosswalk"; +#else + const char tec_path[] = "/usr/lib/tizen-extensions-crosswalk"; +#endif + if (value.empty()) cmd_line->AppendSwitchASCII(switches::kXWalkExternalExtensionsPath, tec_path); -- 2.7.4