Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3250)

Unified Diff: chrome/browser/chromeos/customization_document.cc

Issue 206673006: Set OEM apps folder name from customization manifest (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/customization_document.cc
diff --git a/chrome/browser/chromeos/customization_document.cc b/chrome/browser/chromeos/customization_document.cc
index e0248d9065bf5417029a013d00bff4ce0c85179c..99d7d82bff3edf4999734377bcece14d89c73016 100644
--- a/chrome/browser/chromeos/customization_document.cc
+++ b/chrome/browser/chromeos/customization_document.cc
@@ -25,6 +25,8 @@
#include "chrome/browser/extensions/external_loader.h"
#include "chrome/browser/extensions/external_provider_impl.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/app_list/app_list_syncable_service.h"
+#include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
@@ -53,6 +55,8 @@ const char kSetupContentAttr[] = "setup_content";
const char kEulaPageAttr[] = "eula_page";
const char kDefaultWallpaperAttr[] = "default_wallpaper";
const char kDefaultAppsAttr[] = "default_apps";
+const char kLocalizedContent[] = "localized_content";
+const char kDefaultAppsFolderName[] = "default_apps_folder_name";
const char kAcceptedManifestVersion[] = "1.0";
@@ -93,6 +97,32 @@ void LogManifestLoadResult(HistogramServicesCustomizationLoadResult result) {
HISTOGRAM_LOAD_RESULT_MAX_VALUE);
}
+std::string GetLocaleSpecificStringImpl(
+ const base::DictionaryValue* root,
+ const std::string& locale,
+ const std::string& dictionary_name,
+ const std::string& entry_name) {
+ const base::DictionaryValue* dictionary_content = NULL;
+ if (!root || !root->GetDictionary(dictionary_name, &dictionary_content))
+ return std::string();
+
+ const base::DictionaryValue* locale_dictionary = NULL;
+ if (dictionary_content->GetDictionary(locale, &locale_dictionary)) {
+ std::string result;
+ if (locale_dictionary->GetString(entry_name, &result))
+ return result;
+ }
+
+ const base::DictionaryValue* default_dictionary = NULL;
+ if (dictionary_content->GetDictionary(kDefaultAttr, &default_dictionary)) {
+ std::string result;
+ if (default_dictionary->GetString(entry_name, &result))
+ return result;
+ }
+
+ return std::string();
+}
+
} // anonymous namespace
namespace chromeos {
@@ -191,26 +221,8 @@ std::string CustomizationDocument::GetLocaleSpecificString(
const std::string& locale,
const std::string& dictionary_name,
const std::string& entry_name) const {
- base::DictionaryValue* dictionary_content = NULL;
- if (!root_.get() ||
- !root_->GetDictionary(dictionary_name, &dictionary_content))
- return std::string();
-
- base::DictionaryValue* locale_dictionary = NULL;
- if (dictionary_content->GetDictionary(locale, &locale_dictionary)) {
- std::string result;
- if (locale_dictionary->GetString(entry_name, &result))
- return result;
- }
-
- base::DictionaryValue* default_dictionary = NULL;
- if (dictionary_content->GetDictionary(kDefaultAttr, &default_dictionary)) {
- std::string result;
- if (default_dictionary->GetString(entry_name, &result))
- return result;
- }
-
- return std::string();
+ return GetLocaleSpecificStringImpl(
+ root_.get(), locale, dictionary_name, entry_name);
}
// StartupCustomizationDocument implementation. --------------------------------
@@ -464,6 +476,7 @@ void ServicesCustomizationDocument::OnManifestLoaded() {
UpdateCachedManifest((*it)->profile());
(*it)->SetCurrentApps(
scoped_ptr<base::DictionaryValue>(prefs->DeepCopy()));
+ SetOemFolderName((*it)->profile(), *root_);
}
}
}
@@ -541,6 +554,14 @@ bool ServicesCustomizationDocument::GetDefaultApps(
return true;
}
+std::string ServicesCustomizationDocument::GetOemAppsFolderName(
+ const std::string& locale) const {
+ if (!IsReady())
+ return std::string();
+
+ return GetOemAppsFolderNameImpl(locale, *root_);
+}
+
scoped_ptr<base::DictionaryValue>
ServicesCustomizationDocument::GetDefaultAppsInProviderFormat(
const base::DictionaryValue& root) {
@@ -578,6 +599,7 @@ extensions::ExternalLoader* ServicesCustomizationDocument::CreateExternalLoader(
if (IsReady()) {
UpdateCachedManifest(profile);
loader->SetCurrentApps(GetDefaultAppsInProviderFormat(*root_));
+ SetOemFolderName(profile, *root_);
} else {
const base::DictionaryValue* root =
profile->GetPrefs()->GetDictionary(kServicesCustomizationKey);
@@ -585,6 +607,7 @@ extensions::ExternalLoader* ServicesCustomizationDocument::CreateExternalLoader(
if (root && root->GetString(kVersionAttr, &version)) {
// If version exists, profile has cached version of customization.
loader->SetCurrentApps(GetDefaultAppsInProviderFormat(*root));
+ SetOemFolderName(profile, *root);
} else {
// StartFetching will be called from ServicesCustomizationExternalLoader
// when StartLoading is called. We can't initiate manifest fetch here
@@ -600,4 +623,28 @@ void ServicesCustomizationDocument::OnCustomizationNotFound() {
LoadManifestFromString(kEmptyServicesCustomizationManifest);
}
+void ServicesCustomizationDocument::SetOemFolderName(
+ Profile* profile,
+ const base::DictionaryValue& root) {
+ app_list::AppListSyncableService* service =
+ app_list::AppListSyncableServiceFactory::GetForProfile(profile);
+ if (!service) {
+ LOG(WARNING) << "AppListSyncableService is not ready for setting OEM "
+ "folder name";
+ return;
+ }
+
+ std::string locale = g_browser_process->GetApplicationLocale();
+ std::string name = GetOemAppsFolderNameImpl(locale, root);
+ if (!name.empty())
+ service->SetOemFolderName(name);
+}
+
+std::string ServicesCustomizationDocument::GetOemAppsFolderNameImpl(
+ const std::string& locale,
+ const base::DictionaryValue& root) const {
+ return GetLocaleSpecificStringImpl(
+ &root, locale, kLocalizedContent, kDefaultAppsFolderName);
+}
+
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/customization_document.h ('k') | chrome/browser/chromeos/customization_document_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698