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

Side by Side Diff: chrome/browser/ui/webui/foreign_session_handler.cc

Issue 2657673004: Add shutdown notification and service refs to SyncServiceObserver. (Closed)
Patch Set: Use parameter Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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/foreign_session_handler.h" 5 #include "chrome/browser/ui/webui/foreign_session_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 base::Bind(&ForeignSessionHandler::HandleGetForeignSessions, 222 base::Bind(&ForeignSessionHandler::HandleGetForeignSessions,
223 base::Unretained(this))); 223 base::Unretained(this)));
224 web_ui()->RegisterMessageCallback("openForeignSession", 224 web_ui()->RegisterMessageCallback("openForeignSession",
225 base::Bind(&ForeignSessionHandler::HandleOpenForeignSession, 225 base::Bind(&ForeignSessionHandler::HandleOpenForeignSession,
226 base::Unretained(this))); 226 base::Unretained(this)));
227 web_ui()->RegisterMessageCallback("setForeignSessionCollapsed", 227 web_ui()->RegisterMessageCallback("setForeignSessionCollapsed",
228 base::Bind(&ForeignSessionHandler::HandleSetForeignSessionCollapsed, 228 base::Bind(&ForeignSessionHandler::HandleSetForeignSessionCollapsed,
229 base::Unretained(this))); 229 base::Unretained(this)));
230 } 230 }
231 231
232 void ForeignSessionHandler::OnSyncConfigurationCompleted() { 232 void ForeignSessionHandler::OnSyncConfigurationCompleted(
233 syncer::SyncService* sync) {
233 HandleGetForeignSessions(nullptr); 234 HandleGetForeignSessions(nullptr);
234 } 235 }
235 236
236 void ForeignSessionHandler::OnForeignSessionUpdated() { 237 void ForeignSessionHandler::OnForeignSessionUpdated(syncer::SyncService* sync) {
237 HandleGetForeignSessions(nullptr); 238 HandleGetForeignSessions(nullptr);
238 } 239 }
239 240
240 base::string16 ForeignSessionHandler::FormatSessionTime( 241 base::string16 ForeignSessionHandler::FormatSessionTime(
241 const base::Time& time) { 242 const base::Time& time) {
242 // Return a time like "1 hour ago", "2 days ago", etc. 243 // Return a time like "1 hour ago", "2 days ago", etc.
243 base::Time now = base::Time::Now(); 244 base::Time now = base::Time::Now();
244 // TimeFormat does not support negative TimeDelta values, so then we use 0. 245 // TimeFormat does not support negative TimeDelta values, so then we use 0.
245 return ui::TimeFormat::Simple( 246 return ui::TimeFormat::Simple(
246 ui::TimeFormat::FORMAT_ELAPSED, ui::TimeFormat::LENGTH_SHORT, 247 ui::TimeFormat::FORMAT_ELAPSED, ui::TimeFormat::LENGTH_SHORT,
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 // collapsed state persists. 427 // collapsed state persists.
427 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); 428 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
428 DictionaryPrefUpdate update(prefs, prefs::kNtpCollapsedForeignSessions); 429 DictionaryPrefUpdate update(prefs, prefs::kNtpCollapsedForeignSessions);
429 if (is_collapsed) 430 if (is_collapsed)
430 update.Get()->SetBoolean(session_tag, true); 431 update.Get()->SetBoolean(session_tag, true);
431 else 432 else
432 update.Get()->Remove(session_tag, NULL); 433 update.Get()->Remove(session_tag, NULL);
433 } 434 }
434 435
435 } // namespace browser_sync 436 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698