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

Unified Diff: chrome/browser/ui/webui/settings/people_handler.cc

Issue 1536593004: Settings People Revamp: Implement Chrome Profile name/icon selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/ui/webui/settings/people_handler.cc
diff --git a/chrome/browser/ui/webui/settings/people_handler.cc b/chrome/browser/ui/webui/settings/people_handler.cc
index f180eb4ab9d2e91f18fe89962ec55cef31bc1190..2cf3fe0ce14761b86577db93de2cd3facb54df8d 100644
--- a/chrome/browser/ui/webui/settings/people_handler.cc
+++ b/chrome/browser/ui/webui/settings/people_handler.cc
@@ -215,10 +215,15 @@ PeopleHandler::PeopleHandler(Profile* profile)
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_));
if (sync_service)
sync_service_observer_.Add(sync_service);
+
+ g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
}
PeopleHandler::~PeopleHandler() {
- // Just exit if running unit tests (no actual WebUI is attached).
+ g_browser_process->profile_manager()->
+ GetProfileInfoCache().RemoveObserver(this);
+
+ // Early exit if running unit tests (no actual WebUI is attached).
if (!web_ui())
return;
@@ -258,6 +263,9 @@ bool PeopleHandler::IsActiveLogin() const {
void PeopleHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
+ "getProfileInfo",
+ base::Bind(&PeopleHandler::HandleGetProfileInfo, base::Unretained(this)));
+ web_ui()->RegisterMessageCallback(
"SyncSetupDidClosePage",
base::Bind(&PeopleHandler::OnDidClosePage, base::Unretained(this)));
web_ui()->RegisterMessageCallback(
@@ -430,6 +438,16 @@ ProfileSyncService* PeopleHandler::GetSyncService() const {
: nullptr;
}
+void PeopleHandler::HandleGetProfileInfo(const base::ListValue* args) {
+ std::string name;
+ std::string icon_url;
+ GetAccountNameAndIcon(*profile_, &name, &icon_url);
+
+ web_ui()->CallJavascriptFunction("settings.SyncPrivateApi.receiveProfileInfo",
+ base::StringValue(name),
+ base::StringValue(icon_url));
+}
+
void PeopleHandler::HandleConfigure(const base::ListValue* args) {
DCHECK(!sync_startup_tracker_);
std::string json;
@@ -765,6 +783,17 @@ void PeopleHandler::OnStateChanged() {
UpdateSyncState();
}
+void PeopleHandler::OnProfileNameChanged(
+ const base::FilePath& /* profile_path */,
+ const base::string16& /* old_profile_name */) {
+ HandleGetProfileInfo(nullptr);
+}
+
+void PeopleHandler::OnProfileAvatarChanged(
+ const base::FilePath& /* profile_path */) {
+ HandleGetProfileInfo(nullptr);
+}
+
scoped_ptr<base::DictionaryValue> PeopleHandler::GetSyncStateDictionary() {
// The items which are to be written into |sync_status| are also described in
// chrome/browser/resources/options/browser_options.js in @typedef
@@ -815,12 +844,6 @@ scoped_ptr<base::DictionaryValue> PeopleHandler::GetSyncStateDictionary() {
sync_status->SetBoolean("hasUnrecoverableError",
service && service->HasUnrecoverableError());
- std::string name;
- std::string icon_url;
- GetAccountNameAndIcon(*profile_, &name, &icon_url);
- sync_status->SetString("name", name);
- sync_status->SetString("iconURL", icon_url);
-
return sync_status;
}
« no previous file with comments | « chrome/browser/ui/webui/settings/people_handler.h ('k') | chrome/browser/ui/webui/settings/people_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698