OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h" | 5 #include "chrome/browser/ui/webui/ntp/foreign_session_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 base::Unretained(this))); | 67 base::Unretained(this))); |
68 web_ui()->RegisterMessageCallback("openForeignSession", | 68 web_ui()->RegisterMessageCallback("openForeignSession", |
69 base::Bind(&ForeignSessionHandler::HandleOpenForeignSession, | 69 base::Bind(&ForeignSessionHandler::HandleOpenForeignSession, |
70 base::Unretained(this))); | 70 base::Unretained(this))); |
71 web_ui()->RegisterMessageCallback("setForeignSessionCollapsed", | 71 web_ui()->RegisterMessageCallback("setForeignSessionCollapsed", |
72 base::Bind(&ForeignSessionHandler::HandleSetForeignSessionCollapsed, | 72 base::Bind(&ForeignSessionHandler::HandleSetForeignSessionCollapsed, |
73 base::Unretained(this))); | 73 base::Unretained(this))); |
74 } | 74 } |
75 | 75 |
76 void ForeignSessionHandler::Init() { | 76 void ForeignSessionHandler::Init() { |
77 // TODO(dubroy): Change this to only observe this notification on the current | 77 Profile* profile = Profile::FromWebUI(web_ui()); |
78 // profile, rather than all sources (crbug.com/124717). | 78 ProfileSyncService* service = |
| 79 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
79 registrar_.Add(this, chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, | 80 registrar_.Add(this, chrome::NOTIFICATION_SYNC_CONFIGURE_DONE, |
80 content::NotificationService::AllSources()); | 81 content::Source<ProfileSyncService>(service)); |
81 | |
82 Profile* profile = Profile::FromWebUI(web_ui()); | |
83 registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED, | 82 registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_UPDATED, |
84 content::Source<Profile>(profile)); | 83 content::Source<Profile>(profile)); |
85 registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_DISABLED, | 84 registrar_.Add(this, chrome::NOTIFICATION_FOREIGN_SESSION_DISABLED, |
86 content::Source<Profile>(profile)); | 85 content::Source<Profile>(profile)); |
87 | 86 |
88 // Add the data source for synced favicons. | 87 // Add the data source for synced favicons. |
89 ChromeURLDataManager::AddDataSource(profile, | 88 ChromeURLDataManager::AddDataSource(profile, |
90 new SessionFaviconSource(profile)); | 89 new SessionFaviconSource(profile)); |
91 } | 90 } |
92 | 91 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 dictionary->SetString("userVisibleTimestamp", | 343 dictionary->SetString("userVisibleTimestamp", |
345 last_synced < base::TimeDelta::FromMinutes(1) ? | 344 last_synced < base::TimeDelta::FromMinutes(1) ? |
346 l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW) : | 345 l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW) : |
347 TimeFormat::TimeElapsed(last_synced)); | 346 TimeFormat::TimeElapsed(last_synced)); |
348 dictionary->SetInteger("sessionId", window.window_id.id()); | 347 dictionary->SetInteger("sessionId", window.window_id.id()); |
349 dictionary->Set("tabs", tab_values.release()); | 348 dictionary->Set("tabs", tab_values.release()); |
350 return true; | 349 return true; |
351 } | 350 } |
352 | 351 |
353 } // namespace browser_sync | 352 } // namespace browser_sync |
OLD | NEW |