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/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/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 new base::DictionaryValue()); | 273 new base::DictionaryValue()); |
274 if (SessionWindowToValue(*window, window_data.get())) | 274 if (SessionWindowToValue(*window, window_data.get())) |
275 window_list->Append(window_data.release()); | 275 window_list->Append(window_data.release()); |
276 } | 276 } |
277 | 277 |
278 session_data->Set("windows", window_list.release()); | 278 session_data->Set("windows", window_list.release()); |
279 session_list.Append(session_data.release()); | 279 session_list.Append(session_data.release()); |
280 } | 280 } |
281 } | 281 } |
282 base::FundamentalValue tab_sync_enabled(IsTabSyncEnabled()); | 282 base::FundamentalValue tab_sync_enabled(IsTabSyncEnabled()); |
283 web_ui()->CallJavascriptFunction("ntp.setForeignSessions", | 283 web_ui()->CallJavascriptFunction("setForeignSessions", session_list, |
284 session_list, | |
285 tab_sync_enabled); | 284 tab_sync_enabled); |
286 } | 285 } |
287 | 286 |
288 void ForeignSessionHandler::HandleOpenForeignSession( | 287 void ForeignSessionHandler::HandleOpenForeignSession( |
289 const base::ListValue* args) { | 288 const base::ListValue* args) { |
290 size_t num_args = args->GetSize(); | 289 size_t num_args = args->GetSize(); |
291 // Expect either 1 or 8 args. For restoring an entire session, only | 290 // Expect either 1 or 8 args. For restoring an entire session, only |
292 // one argument is required -- the session tag. To restore a tab, | 291 // one argument is required -- the session tag. To restore a tab, |
293 // the additional args required are the window id, the tab id, | 292 // the additional args required are the window id, the tab id, |
294 // and 4 properties of the event object (button, altKey, ctrlKey, | 293 // and 4 properties of the event object (button, altKey, ctrlKey, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 last_synced < base::TimeDelta::FromMinutes(1) ? | 413 last_synced < base::TimeDelta::FromMinutes(1) ? |
415 l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW) : | 414 l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW) : |
416 ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED, | 415 ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_ELAPSED, |
417 ui::TimeFormat::LENGTH_SHORT, last_synced)); | 416 ui::TimeFormat::LENGTH_SHORT, last_synced)); |
418 dictionary->SetInteger("sessionId", window.window_id.id()); | 417 dictionary->SetInteger("sessionId", window.window_id.id()); |
419 dictionary->Set("tabs", tab_values.release()); | 418 dictionary->Set("tabs", tab_values.release()); |
420 return true; | 419 return true; |
421 } | 420 } |
422 | 421 |
423 } // namespace browser_sync | 422 } // namespace browser_sync |
OLD | NEW |