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 | 10 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 default: | 211 default: |
212 NOTREACHED(); | 212 NOTREACHED(); |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 | 216 |
217 bool ForeignSessionHandler::IsTabSyncEnabled() { | 217 bool ForeignSessionHandler::IsTabSyncEnabled() { |
218 Profile* profile = Profile::FromWebUI(web_ui()); | 218 Profile* profile = Profile::FromWebUI(web_ui()); |
219 ProfileSyncService* service = | 219 ProfileSyncService* service = |
220 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | 220 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
221 return service && service->GetPreferredDataTypes().Has(syncer::PROXY_TABS); | 221 return service && service->GetActiveDataTypes().Has(syncer::PROXY_TABS); |
222 } | 222 } |
223 | 223 |
224 string16 ForeignSessionHandler::FormatSessionTime(const base::Time& time) { | 224 string16 ForeignSessionHandler::FormatSessionTime(const base::Time& time) { |
225 // Return a time like "1 hour ago", "2 days ago", etc. | 225 // Return a time like "1 hour ago", "2 days ago", etc. |
226 base::Time now = base::Time::Now(); | 226 base::Time now = base::Time::Now(); |
227 // TimeElapsed does not support negative TimeDelta values, so then we use 0. | 227 // TimeElapsed does not support negative TimeDelta values, so then we use 0. |
228 return TimeFormat::TimeElapsed(now < time ? base::TimeDelta() : now - time); | 228 return TimeFormat::TimeElapsed(now < time ? base::TimeDelta() : now - time); |
229 } | 229 } |
230 | 230 |
231 void ForeignSessionHandler::HandleGetForeignSessions(const ListValue* args) { | 231 void ForeignSessionHandler::HandleGetForeignSessions(const ListValue* args) { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 dictionary->SetString("userVisibleTimestamp", | 405 dictionary->SetString("userVisibleTimestamp", |
406 last_synced < base::TimeDelta::FromMinutes(1) ? | 406 last_synced < base::TimeDelta::FromMinutes(1) ? |
407 l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW) : | 407 l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW) : |
408 TimeFormat::TimeElapsed(last_synced)); | 408 TimeFormat::TimeElapsed(last_synced)); |
409 dictionary->SetInteger("sessionId", window.window_id.id()); | 409 dictionary->SetInteger("sessionId", window.window_id.id()); |
410 dictionary->Set("tabs", tab_values.release()); | 410 dictionary->Set("tabs", tab_values.release()); |
411 return true; | 411 return true; |
412 } | 412 } |
413 | 413 |
414 } // namespace browser_sync | 414 } // namespace browser_sync |
OLD | NEW |