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