Commit 72db076f authored by dbeam's avatar dbeam Committed by Commit bot

Fix crash when logging in with an open uber page.

BUG=490056

Review URL: https://codereview.chromium.org/1148203002

Cr-Commit-Position: refs/heads/master@{#330794}
parent eaf99da8
......@@ -153,6 +153,7 @@
#if !defined(OS_ANDROID) && !defined(OS_IOS)
#include "chrome/browser/signin/signin_promo.h"
#include "chrome/browser/ui/webui/foreign_session_handler.h"
#endif
#if defined(OS_CHROMEOS)
......@@ -511,6 +512,10 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
#if defined(USE_ASH)
ash::RegisterChromeLauncherUserPrefs(registry);
#endif
#if !defined(OS_ANDROID) && !defined(OS_IOS)
browser_sync::ForeignSessionHandler::RegisterProfilePrefs(registry);
#endif
}
void RegisterUserProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
......
......@@ -158,7 +158,16 @@ OpenTabsUIDelegate* ForeignSessionHandler::GetOpenTabsUIDelegate(
}
void ForeignSessionHandler::RegisterMessages() {
Init();
Profile* profile = Profile::FromWebUI(web_ui());
ProfileSyncService* service =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
registrar_.Add(this, chrome::NOTIFICATION_SYNC_CONFIGURE_DONE,
content::Source<ProfileSyncService>(service));
registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED,
content::Source<Profile>(profile));
registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_DISABLED,
content::Source<Profile>(profile));
web_ui()->RegisterMessageCallback("deleteForeignSession",
base::Bind(&ForeignSessionHandler::HandleDeleteForeignSession,
base::Unretained(this)));
......@@ -173,24 +182,10 @@ void ForeignSessionHandler::RegisterMessages() {
base::Unretained(this)));
}
void ForeignSessionHandler::Init() {
Profile* profile = Profile::FromWebUI(web_ui());
ProfileSyncService* service =
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
registrar_.Add(this, chrome::NOTIFICATION_SYNC_CONFIGURE_DONE,
content::Source<ProfileSyncService>(service));
registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED,
content::Source<Profile>(profile));
registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_DISABLED,
content::Source<Profile>(profile));
}
void ForeignSessionHandler::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
base::ListValue list_value;
switch (type) {
case chrome::NOTIFICATION_FOREIGN_SESSION_DISABLED:
// Tab sync is disabled, so clean up data about collapsed sessions.
......@@ -199,14 +194,13 @@ void ForeignSessionHandler::Observe(
// Fall through.
case chrome::NOTIFICATION_SYNC_CONFIGURE_DONE:
case chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED:
HandleGetForeignSessions(&list_value);
HandleGetForeignSessions(nullptr);
break;
default:
NOTREACHED();
}
}
bool ForeignSessionHandler::IsTabSyncEnabled() {
Profile* profile = Profile::FromWebUI(web_ui());
ProfileSyncService* service =
......@@ -225,7 +219,7 @@ base::string16 ForeignSessionHandler::FormatSessionTime(
}
void ForeignSessionHandler::HandleGetForeignSessions(
const base::ListValue* args) {
const base::ListValue* /*args*/) {
OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(web_ui());
std::vector<const SyncedSession*> sessions;
......
......@@ -58,9 +58,6 @@ class ForeignSessionHandler : public content::WebUIMessageHandler,
static OpenTabsUIDelegate* GetOpenTabsUIDelegate(content::WebUI* web_ui);
private:
// Used to register ForeignSessionHandler for notifications.
void Init();
// Determines how ForeignSessionHandler will interact with the new tab page.
void Observe(int type,
const content::NotificationSource& source,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment