1 // Copyright (c) 2014 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "xwalk/application/common/manifest_handlers/tizen_splash_screen_handler.h"
10 #include "base/file_util.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "xwalk/application/common/application_manifest_constants.h"
16 namespace keys = application_widget_keys;
18 namespace application {
20 TizenSplashScreenInfo::TizenSplashScreenInfo() {}
21 TizenSplashScreenInfo::~TizenSplashScreenInfo() {}
23 TizenSplashScreenHandler::TizenSplashScreenHandler() {}
25 TizenSplashScreenHandler::~TizenSplashScreenHandler() {}
27 bool TizenSplashScreenHandler::Parse(scoped_refptr<ApplicationData> application,
28 base::string16* error) {
29 scoped_ptr<TizenSplashScreenInfo> ss_info(new TizenSplashScreenInfo);
30 const Manifest* manifest = application->GetManifest();
33 base::Value* splash_screen = NULL;
34 manifest->Get(keys::kTizenSplashScreenKey, &splash_screen);
35 if (splash_screen && splash_screen->IsType(base::Value::TYPE_DICTIONARY)) {
36 base::DictionaryValue* ss_dict = NULL;
37 splash_screen->GetAsDictionary(&ss_dict);
39 ss_dict->GetString(keys::kTizenSplashScreenSrcKey, &src);
40 ss_info->set_src(src);
42 application->SetManifestData(keys::kTizenSplashScreenKey, ss_info.release());
46 bool TizenSplashScreenHandler::Validate(
47 scoped_refptr<const ApplicationData> application,
48 std::string* error) const {
49 const Manifest* manifest = application->GetManifest();
51 base::Value* splash_screen = NULL;
52 manifest->Get(keys::kTizenSplashScreenKey, &splash_screen);
53 if (!splash_screen || !splash_screen->IsType(base::Value::TYPE_DICTIONARY)) {
54 *error = std::string("The splash-screen attribute is not set correctly.");
57 base::DictionaryValue* ss_dict = NULL;
58 splash_screen->GetAsDictionary(&ss_dict);
60 ss_dict->GetString(keys::kTizenSplashScreenSrcKey, &ss_src);
61 base::FilePath path = application->Path().Append(FILE_PATH_LITERAL(ss_src));
62 if (!base::PathExists(path)) {
63 *error = std::string("The splash screen image does not exist");
69 std::vector<std::string> TizenSplashScreenHandler::Keys() const {
70 return std::vector<std::string>(1, keys::kTizenSplashScreenKey);
73 } // namespace application