Fix injected bundle crash error
authorSeungkeun Lee <sngn.lee@samsung.com>
Tue, 19 May 2015 10:33:21 +0000 (19:33 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Tue, 19 May 2015 23:55:56 +0000 (08:55 +0900)
Change-Id: I2736ebd5e4b362e335318f9dcffb73e74ea9ee20

src/bundle/injected_bundle.cc
src/common/resource_manager.cc

index d7fdcab..5409445 100755 (executable)
@@ -25,6 +25,7 @@ class BundleGlobalData {
   }
   void Initialize(const std::string& app_id) {
     app_data_.reset(new ApplicationData(app_id));
+    app_data_->LoadManifestData();
     locale_manager_.reset(new LocaleManager);
     locale_manager_->EnableAutoUpdate(true);
     if (app_data_->widget_info() != NULL &&
@@ -34,9 +35,13 @@ class BundleGlobalData {
     }
     resource_manager_.reset(new ResourceManager(app_data_.get(),
                                                 locale_manager_.get()));
+    resource_manager_->set_base_resource_path(
+        app_data_->application_path());
   }
 
-  ResourceManager* resource_manager();
+  ResourceManager* resource_manager() {
+    return resource_manager_.get();
+  }
 
  private:
   BundleGlobalData() {}
@@ -97,8 +102,8 @@ extern "C" void DynamicUrlParsing(
   *new_url = res_manager->GetLocalizedPath(*old_url);
 }
 
-extern "C" void DynamicDatabaseAttach(const char* tizen_id) {
-  LOGGER(DEBUG) << "InjectedBundle::DynamicDatabaseAttach !!" << tizen_id;
+extern "C" void DynamicDatabaseAttach(int /*attach*/) {
+  LOGGER(DEBUG) << "InjectedBundle::DynamicDatabaseAttach !!";
 }
 
 extern "C" void DynamicOnIPCMessage(const Ewk_IPC_Wrt_Message_Data& data) {
index ad07474..8ad5383 100755 (executable)
@@ -306,19 +306,19 @@ std::string ResourceManager::GetLocalizedPath(const std::string& origin) {
     url.resize(pos);
   }
 
-  if (url.compare(app_scheme) == 0) {
+  if (utils::StartsWith(url, app_scheme)) {
     // remove "app://"
     url.erase(0, app_scheme.length());
 
     // remove app id + /
     std::string check = appid_ + "/";
-    if (url.compare(0, check.length(), check) == 0) {
+    if (utils::StartsWith(url, check)) {
       url.erase(0, check.length());
     } else {
       LOGGER(ERROR) << "Invalid appid";
       return result;
     }
-  } else if (url.compare(file_scheme) == 0) {
+  } else if (utils::StartsWith(url, file_scheme)) {
     // remove "file:///"
     url.erase(0, file_scheme.length());
   }
@@ -332,23 +332,22 @@ std::string ResourceManager::GetLocalizedPath(const std::string& origin) {
     return result;
   }
 
-  auto locales = locale_manager_->system_locales().begin();
-  for ( ; locales != locale_manager_->system_locales().end(); ++locales) {
+  for (auto& locales : locale_manager_->system_locales()) {
     // check ../locales/
     std::string app_locale_path = resource_base_path_ + locale_path;
     if (!Exists(app_locale_path)) {
       break;
     }
-    std::string resource_path = app_locale_path + (*locales) + "/" + url;
+    std::string resource_path = app_locale_path + locales + "/" + url;
     if (Exists(resource_path)) {
-      result = resource_path + suffix;
+      result = "file://" + resource_path + suffix;
       return result;
     }
   }
 
   std::string default_locale = resource_base_path_ + url;
   if (Exists(default_locale)) {
-    result = default_locale + suffix;
+    result = "file://" + default_locale + suffix;
     return result;
   }
   result = url + suffix;