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 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/i18n/time_formatting.h" | 13 #include "base/i18n/time_formatting.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/browser/prefs/pref_registry_syncable.h" |
18 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
19 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 20 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/sessions/session_restore.h" | 22 #include "chrome/browser/sessions/session_restore.h" |
22 #include "chrome/browser/sync/profile_sync_service.h" | 23 #include "chrome/browser/sync/profile_sync_service.h" |
23 #include "chrome/browser/sync/profile_sync_service_factory.h" | 24 #include "chrome/browser/sync/profile_sync_service_factory.h" |
24 #include "chrome/browser/ui/host_desktop.h" | 25 #include "chrome/browser/ui/host_desktop.h" |
25 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 26 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
26 #include "chrome/browser/ui/webui/session_favicon_source.h" | 27 #include "chrome/browser/ui/webui/session_favicon_source.h" |
27 #include "chrome/common/chrome_notification_types.h" | 28 #include "chrome/common/chrome_notification_types.h" |
(...skipping 25 matching lines...) Expand all Loading... |
53 bool SortSessionsByRecency(const SyncedSession* s1, const SyncedSession* s2) { | 54 bool SortSessionsByRecency(const SyncedSession* s1, const SyncedSession* s2) { |
54 return s1->modified_time > s2->modified_time; | 55 return s1->modified_time > s2->modified_time; |
55 } | 56 } |
56 | 57 |
57 } // namepace | 58 } // namepace |
58 | 59 |
59 ForeignSessionHandler::ForeignSessionHandler() { | 60 ForeignSessionHandler::ForeignSessionHandler() { |
60 } | 61 } |
61 | 62 |
62 // static | 63 // static |
63 void ForeignSessionHandler::RegisterUserPrefs(PrefServiceSyncable* prefs) { | 64 void ForeignSessionHandler::RegisterUserPrefs(PrefRegistrySyncable* registry) { |
64 prefs->RegisterDictionaryPref(prefs::kNtpCollapsedForeignSessions, | 65 registry->RegisterDictionaryPref(prefs::kNtpCollapsedForeignSessions, |
65 PrefServiceSyncable::UNSYNCABLE_PREF); | 66 PrefRegistrySyncable::UNSYNCABLE_PREF); |
66 } | 67 } |
67 | 68 |
68 // static | 69 // static |
69 void ForeignSessionHandler::OpenForeignSessionTab( | 70 void ForeignSessionHandler::OpenForeignSessionTab( |
70 content::WebUI* web_ui, | 71 content::WebUI* web_ui, |
71 const std::string& session_string_value, | 72 const std::string& session_string_value, |
72 SessionID::id_type window_num, | 73 SessionID::id_type window_num, |
73 SessionID::id_type tab_id, | 74 SessionID::id_type tab_id, |
74 const WindowOpenDisposition& disposition) { | 75 const WindowOpenDisposition& disposition) { |
75 SessionModelAssociator* associator = GetModelAssociator(web_ui); | 76 SessionModelAssociator* associator = GetModelAssociator(web_ui); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 dictionary->SetString("userVisibleTimestamp", | 435 dictionary->SetString("userVisibleTimestamp", |
435 last_synced < base::TimeDelta::FromMinutes(1) ? | 436 last_synced < base::TimeDelta::FromMinutes(1) ? |
436 l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW) : | 437 l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW) : |
437 TimeFormat::TimeElapsed(last_synced)); | 438 TimeFormat::TimeElapsed(last_synced)); |
438 dictionary->SetInteger("sessionId", window.window_id.id()); | 439 dictionary->SetInteger("sessionId", window.window_id.id()); |
439 dictionary->Set("tabs", tab_values.release()); | 440 dictionary->Set("tabs", tab_values.release()); |
440 return true; | 441 return true; |
441 } | 442 } |
442 | 443 |
443 } // namespace browser_sync | 444 } // namespace browser_sync |
OLD | NEW |