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 15 matching lines...) Expand all Loading... |
26 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 26 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
27 #include "chrome/browser/ui/webui/session_favicon_source.h" | 27 #include "chrome/browser/ui/webui/session_favicon_source.h" |
28 #include "chrome/common/chrome_notification_types.h" | 28 #include "chrome/common/chrome_notification_types.h" |
29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
30 #include "chrome/common/time_format.h" | 30 #include "chrome/common/time_format.h" |
31 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
32 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
33 #include "content/public/browser/notification_source.h" | 33 #include "content/public/browser/notification_source.h" |
34 #include "content/public/browser/url_data_source.h" | 34 #include "content/public/browser/url_data_source.h" |
35 #include "content/public/browser/web_contents.h" | 35 #include "content/public/browser/web_contents.h" |
| 36 #include "content/public/browser/web_contents_view.h" |
36 #include "content/public/browser/web_ui.h" | 37 #include "content/public/browser/web_ui.h" |
37 #include "grit/generated_resources.h" | 38 #include "grit/generated_resources.h" |
38 #include "ui/base/l10n/l10n_util.h" | 39 #include "ui/base/l10n/l10n_util.h" |
39 #include "ui/webui/web_ui_util.h" | 40 #include "ui/webui/web_ui_util.h" |
40 | 41 |
41 namespace browser_sync { | 42 namespace browser_sync { |
42 | 43 |
43 // Maximum number of sessions we're going to display on the NTP | 44 // Maximum number of sessions we're going to display on the NTP |
44 static const size_t kMaxSessionsToShow = 10; | 45 static const size_t kMaxSessionsToShow = 10; |
45 | 46 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 return; | 106 return; |
106 } | 107 } |
107 std::vector<const SessionWindow*>::const_iterator iter_begin = | 108 std::vector<const SessionWindow*>::const_iterator iter_begin = |
108 windows.begin() + (window_num == kInvalidId ? 0 : window_num); | 109 windows.begin() + (window_num == kInvalidId ? 0 : window_num); |
109 std::vector<const SessionWindow*>::const_iterator iter_end = | 110 std::vector<const SessionWindow*>::const_iterator iter_end = |
110 window_num == kInvalidId ? | 111 window_num == kInvalidId ? |
111 std::vector<const SessionWindow*>::const_iterator(windows.end()) : | 112 std::vector<const SessionWindow*>::const_iterator(windows.end()) : |
112 iter_begin + 1; | 113 iter_begin + 1; |
113 chrome::HostDesktopType host_desktop_type = | 114 chrome::HostDesktopType host_desktop_type = |
114 chrome::GetHostDesktopTypeForNativeView( | 115 chrome::GetHostDesktopTypeForNativeView( |
115 web_ui->GetWebContents()->GetNativeView()); | 116 web_ui->GetWebContents()->GetView()->GetNativeView()); |
116 SessionRestore::RestoreForeignSessionWindows( | 117 SessionRestore::RestoreForeignSessionWindows( |
117 Profile::FromWebUI(web_ui), host_desktop_type, iter_begin, iter_end); | 118 Profile::FromWebUI(web_ui), host_desktop_type, iter_begin, iter_end); |
118 } | 119 } |
119 | 120 |
120 // static | 121 // static |
121 bool ForeignSessionHandler::SessionTabToValue( | 122 bool ForeignSessionHandler::SessionTabToValue( |
122 const SessionTab& tab, | 123 const SessionTab& tab, |
123 DictionaryValue* dictionary) { | 124 DictionaryValue* dictionary) { |
124 if (tab.navigations.empty()) | 125 if (tab.navigations.empty()) |
125 return false; | 126 return false; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 dictionary->SetString("userVisibleTimestamp", | 403 dictionary->SetString("userVisibleTimestamp", |
403 last_synced < base::TimeDelta::FromMinutes(1) ? | 404 last_synced < base::TimeDelta::FromMinutes(1) ? |
404 l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW) : | 405 l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW) : |
405 TimeFormat::TimeElapsed(last_synced)); | 406 TimeFormat::TimeElapsed(last_synced)); |
406 dictionary->SetInteger("sessionId", window.window_id.id()); | 407 dictionary->SetInteger("sessionId", window.window_id.id()); |
407 dictionary->Set("tabs", tab_values.release()); | 408 dictionary->Set("tabs", tab_values.release()); |
408 return true; | 409 return true; |
409 } | 410 } |
410 | 411 |
411 } // namespace browser_sync | 412 } // namespace browser_sync |
OLD | NEW |