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

Unified Diff: chrome/browser/ui/webui/options2/browser_options_handler2.cc

Issue 10139019: [webui settings] send user profiles info earlier during load (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make return type scoped_ptr Created 8 years, 8 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
« no previous file with comments | « chrome/browser/ui/webui/options2/browser_options_handler2.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/options2/browser_options_handler2.cc
diff --git a/chrome/browser/ui/webui/options2/browser_options_handler2.cc b/chrome/browser/ui/webui/options2/browser_options_handler2.cc
index 83de954fe9add760909b0cabd7c9db69b882f69e..2be94c464edd0f33e863e360238c69714d57327d 100644
--- a/chrome/browser/ui/webui/options2/browser_options_handler2.cc
+++ b/chrome/browser/ui/webui/options2/browser_options_handler2.cc
@@ -364,7 +364,7 @@ void BrowserOptionsHandler::GetLocalizedValues(DictionaryValue* values) {
#endif
// Pass along sync status early so it will be available during page init.
- values->Set("syncData", GetSyncStateDictionary());
+ values->Set("syncData", GetSyncStateDictionary().release());
values->SetString("privacyLearnMoreURL", chrome::kPrivacyLearnMoreURL);
@@ -390,6 +390,9 @@ void BrowserOptionsHandler::GetLocalizedValues(DictionaryValue* values) {
values->SetBoolean("multiple_profiles",
g_browser_process->profile_manager()->GetNumberOfProfiles() > 1);
#endif
+
+ if (multiprofile_)
+ values->Set("profilesInfo", GetProfilesInfoList().release());
}
void BrowserOptionsHandler::RegisterCloudPrintValues(DictionaryValue* values) {
@@ -530,8 +533,8 @@ void BrowserOptionsHandler::RegisterMessages() {
}
void BrowserOptionsHandler::OnStateChanged() {
- scoped_ptr<DictionaryValue> value(GetSyncStateDictionary());
- web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", *value);
+ web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState",
+ *GetSyncStateDictionary());
SendProfilesInfo();
}
@@ -609,9 +612,6 @@ void BrowserOptionsHandler::InitializePage() {
OnTemplateURLServiceChanged();
ObserveThemeChanged();
- if (multiprofile_)
- SendProfilesInfo();
-
SetupMetricsReportingCheckbox();
SetupMetricsReportingSettingVisibility();
SetupFontSizeSelector();
@@ -903,20 +903,13 @@ void BrowserOptionsHandler::GetInstantFieldTrialStatus(const ListValue* args) {
enabled);
}
-void BrowserOptionsHandler::SendProfilesInfo() {
- // Set profile creation text and button if multi-profiles switch is on.
- scoped_ptr<Value> visible(Value::CreateBooleanValue(multiprofile_));
- web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesSectionVisible",
- *visible);
-
- if (!multiprofile_)
- return;
-
+scoped_ptr<ListValue> BrowserOptionsHandler::GetProfilesInfoList() {
ProfileInfoCache& cache =
g_browser_process->profile_manager()->GetProfileInfoCache();
- ListValue profile_info_list;
+ scoped_ptr<ListValue> profile_info_list(new ListValue);
FilePath current_profile_path =
web_ui()->GetWebContents()->GetBrowserContext()->GetPath();
+
for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) {
DictionaryValue* profile_value = new DictionaryValue();
FilePath profile_path = cache.GetPathOfProfileAtIndex(i);
@@ -939,11 +932,15 @@ void BrowserOptionsHandler::SendProfilesInfo() {
cache.GetDefaultAvatarIconUrl(icon_index));
}
- profile_info_list.Append(profile_value);
+ profile_info_list->Append(profile_value);
}
+ return profile_info_list.Pass();
+}
+
+void BrowserOptionsHandler::SendProfilesInfo() {
web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesInfo",
- profile_info_list);
+ *GetProfilesInfoList());
}
void BrowserOptionsHandler::CreateProfile(const ListValue* args) {
@@ -999,13 +996,13 @@ void BrowserOptionsHandler::UpdateAccountPicture() {
}
#endif
-DictionaryValue* BrowserOptionsHandler::GetSyncStateDictionary() {
- DictionaryValue* sync_status = new DictionaryValue;
+scoped_ptr<DictionaryValue> BrowserOptionsHandler::GetSyncStateDictionary() {
+ scoped_ptr<DictionaryValue> sync_status(new DictionaryValue);
ProfileSyncService* service(ProfileSyncServiceFactory::
GetInstance()->GetForProfile(Profile::FromWebUI(web_ui())));
sync_status->SetBoolean("syncSystemEnabled", !!service);
if (!service)
- return sync_status;
+ return sync_status.Pass();
sync_status->SetBoolean("setupCompleted",
service->HasSyncSetupCompleted());
@@ -1030,7 +1027,7 @@ DictionaryValue* BrowserOptionsHandler::GetSyncStateDictionary() {
CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAutologin) &&
service->AreCredentialsAvailable());
- return sync_status;
+ return sync_status.Pass();
}
void BrowserOptionsHandler::HandleSelectDownloadLocation(
« no previous file with comments | « chrome/browser/ui/webui/options2/browser_options_handler2.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698