Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / themes / theme_syncable_service.cc
index 55d3f74..5b8a2d8 100644 (file)
@@ -6,12 +6,13 @@
 
 #include "base/strings/stringprintf.h"
 #include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_system.h"
 #include "chrome/browser/profiles/profile.h"
 #include "chrome/browser/themes/theme_service.h"
-#include "chrome/common/extensions/extension.h"
-#include "chrome/common/extensions/manifest_url_handler.h"
 #include "chrome/common/extensions/sync_helper.h"
+#include "extensions/browser/extension_prefs.h"
+#include "extensions/browser/extension_system.h"
+#include "extensions/common/extension.h"
+#include "extensions/common/manifest_url_handlers.h"
 #include "sync/protocol/sync.pb.h"
 #include "sync/protocol/theme_specifics.pb.h"
 
@@ -23,15 +24,6 @@ bool IsTheme(const extensions::Extension* extension) {
   return extension->is_theme();
 }
 
-// TODO(akalin): Remove this.
-bool IsSystemThemeDistinctFromDefaultTheme() {
-#if defined(TOOLKIT_GTK)
-  return true;
-#else
-  return false;
-#endif
-}
-
 }  // namespace
 
 const char ThemeSyncableService::kCurrentThemeClientTag[] = "current_theme";
@@ -192,8 +184,10 @@ void ThemeSyncableService::MaybeSetTheme(
   const sync_pb::ThemeSpecifics& sync_theme = sync_data.GetSpecifics().theme();
   use_system_theme_by_default_ = sync_theme.use_system_theme_by_default();
   DVLOG(1) << "Set current theme from specifics: " << sync_data.ToString();
-  if (!AreThemeSpecificsEqual(current_specs, sync_theme,
-                              IsSystemThemeDistinctFromDefaultTheme())) {
+  if (!AreThemeSpecificsEqual(
+          current_specs,
+          sync_theme,
+          theme_service_->IsSystemThemeDistinctFromDefaultTheme())) {
     SetCurrentThemeFromThemeSpecifics(sync_theme);
   } else {
     DVLOG(1) << "Skip setting theme because specs are equal";
@@ -219,7 +213,7 @@ void ThemeSyncableService::SetCurrentThemeFromThemeSpecifics(
         return;
       }
       int disabled_reasons =
-          extensions_service->extension_prefs()->GetDisableReasons(id);
+          extensions::ExtensionPrefs::Get(profile_)->GetDisableReasons(id);
       if (!extensions_service->IsExtensionEnabled(id) &&
           disabled_reasons != extensions::Extension::DISABLE_USER_ACTION) {
         DVLOG(1) << "Theme " << id << " is disabled with reason "
@@ -233,17 +227,22 @@ void ThemeSyncableService::SetCurrentThemeFromThemeSpecifics(
       // No extension with this id exists -- we must install it; we do
       // so by adding it as a pending extension and then triggering an
       // auto-update cycle.
-      const bool kInstallSilently = true;
+      const bool kRemoteInstall = false;
+      const bool kInstalledByCustodian = false;
       if (!extensions_service->pending_extension_manager()->AddFromSync(
-              id, update_url, &IsTheme, kInstallSilently)) {
+              id,
+              update_url,
+              &IsTheme,
+              kRemoteInstall,
+              kInstalledByCustodian)) {
         LOG(WARNING) << "Could not add pending extension for " << id;
         return;
       }
       extensions_service->CheckForUpdatesSoon();
     }
   } else if (theme_specifics.use_system_theme_by_default()) {
-    DVLOG(1) << "Switch to use native theme";
-    theme_service_->SetNativeTheme();
+    DVLOG(1) << "Switch to use system theme";
+    theme_service_->UseSystemTheme();
   } else {
     DVLOG(1) << "Switch to use default theme";
     theme_service_->UseDefaultTheme();
@@ -264,11 +263,11 @@ bool ThemeSyncableService::GetThemeSpecificsFromCurrentTheme(
   }
   bool use_custom_theme = (current_theme != NULL);
   theme_specifics->set_use_custom_theme(use_custom_theme);
-  if (IsSystemThemeDistinctFromDefaultTheme()) {
+  if (theme_service_->IsSystemThemeDistinctFromDefaultTheme()) {
     // On platform where system theme is different from default theme, set
     // use_system_theme_by_default to true if system theme is used, false
     // if default system theme is used. Otherwise restore it to value in sync.
-    if (theme_service_->UsingNativeTheme()) {
+    if (theme_service_->UsingSystemTheme()) {
       theme_specifics->set_use_system_theme_by_default(true);
     } else if (theme_service_->UsingDefaultTheme()) {
       theme_specifics->set_use_system_theme_by_default(false);