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 @@ ...@@ -153,6 +153,7 @@
#if !defined(OS_ANDROID) && !defined(OS_IOS) #if !defined(OS_ANDROID) && !defined(OS_IOS)
#include "chrome/browser/signin/signin_promo.h" #include "chrome/browser/signin/signin_promo.h"
#include "chrome/browser/ui/webui/foreign_session_handler.h"
#endif #endif
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
...@@ -511,6 +512,10 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { ...@@ -511,6 +512,10 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
#if defined(USE_ASH) #if defined(USE_ASH)
ash::RegisterChromeLauncherUserPrefs(registry); ash::RegisterChromeLauncherUserPrefs(registry);
#endif #endif
#if !defined(OS_ANDROID) && !defined(OS_IOS)
browser_sync::ForeignSessionHandler::RegisterProfilePrefs(registry);
#endif
} }
void RegisterUserProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { void RegisterUserProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
......
...@@ -158,7 +158,16 @@ OpenTabsUIDelegate* ForeignSessionHandler::GetOpenTabsUIDelegate( ...@@ -158,7 +158,16 @@ OpenTabsUIDelegate* ForeignSessionHandler::GetOpenTabsUIDelegate(
} }
void ForeignSessionHandler::RegisterMessages() { 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", web_ui()->RegisterMessageCallback("deleteForeignSession",
base::Bind(&ForeignSessionHandler::HandleDeleteForeignSession, base::Bind(&ForeignSessionHandler::HandleDeleteForeignSession,
base::Unretained(this))); base::Unretained(this)));
...@@ -173,24 +182,10 @@ void ForeignSessionHandler::RegisterMessages() { ...@@ -173,24 +182,10 @@ void ForeignSessionHandler::RegisterMessages() {
base::Unretained(this))); 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( void ForeignSessionHandler::Observe(
int type, int type,
const content::NotificationSource& source, const content::NotificationSource& source,
const content::NotificationDetails& details) { const content::NotificationDetails& details) {
base::ListValue list_value;
switch (type) { switch (type) {
case chrome::NOTIFICATION_FOREIGN_SESSION_DISABLED: case chrome::NOTIFICATION_FOREIGN_SESSION_DISABLED:
// Tab sync is disabled, so clean up data about collapsed sessions. // Tab sync is disabled, so clean up data about collapsed sessions.
...@@ -199,14 +194,13 @@ void ForeignSessionHandler::Observe( ...@@ -199,14 +194,13 @@ void ForeignSessionHandler::Observe(
// Fall through. // Fall through.
case chrome::NOTIFICATION_SYNC_CONFIGURE_DONE: case chrome::NOTIFICATION_SYNC_CONFIGURE_DONE:
case chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED: case chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED:
HandleGetForeignSessions(&list_value); HandleGetForeignSessions(nullptr);
break; break;
default: default:
NOTREACHED(); NOTREACHED();
} }
} }
bool ForeignSessionHandler::IsTabSyncEnabled() { bool ForeignSessionHandler::IsTabSyncEnabled() {
Profile* profile = Profile::FromWebUI(web_ui()); Profile* profile = Profile::FromWebUI(web_ui());
ProfileSyncService* service = ProfileSyncService* service =
...@@ -225,7 +219,7 @@ base::string16 ForeignSessionHandler::FormatSessionTime( ...@@ -225,7 +219,7 @@ base::string16 ForeignSessionHandler::FormatSessionTime(
} }
void ForeignSessionHandler::HandleGetForeignSessions( void ForeignSessionHandler::HandleGetForeignSessions(
const base::ListValue* args) { const base::ListValue* /*args*/) {
OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(web_ui()); OpenTabsUIDelegate* open_tabs = GetOpenTabsUIDelegate(web_ui());
std::vector<const SyncedSession*> sessions; std::vector<const SyncedSession*> sessions;
......
...@@ -58,9 +58,6 @@ class ForeignSessionHandler : public content::WebUIMessageHandler, ...@@ -58,9 +58,6 @@ class ForeignSessionHandler : public content::WebUIMessageHandler,
static OpenTabsUIDelegate* GetOpenTabsUIDelegate(content::WebUI* web_ui); static OpenTabsUIDelegate* GetOpenTabsUIDelegate(content::WebUI* web_ui);
private: private:
// Used to register ForeignSessionHandler for notifications.
void Init();
// Determines how ForeignSessionHandler will interact with the new tab page. // Determines how ForeignSessionHandler will interact with the new tab page.
void Observe(int type, void Observe(int type,
const content::NotificationSource& source, 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