Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: chrome/browser/ui/webui/ntp/foreign_session_handler.cc

Issue 10695192: Add DeviceTypeAsString to SyncedSession. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated comment to match real usage. Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/glue/synced_session.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 current_collapsed_sessions->DeepCopy()); 154 current_collapsed_sessions->DeepCopy());
155 current_collapsed_sessions->Clear(); 155 current_collapsed_sessions->Clear();
156 156
157 // Note: we don't own the SyncedSessions themselves. 157 // Note: we don't own the SyncedSessions themselves.
158 for (size_t i = 0; i < sessions.size() && i < kMaxSessionsToShow; ++i) { 158 for (size_t i = 0; i < sessions.size() && i < kMaxSessionsToShow; ++i) {
159 const SyncedSession* session = sessions[i]; 159 const SyncedSession* session = sessions[i];
160 const std::string& session_tag = session->session_tag; 160 const std::string& session_tag = session->session_tag;
161 scoped_ptr<DictionaryValue> session_data(new DictionaryValue()); 161 scoped_ptr<DictionaryValue> session_data(new DictionaryValue());
162 session_data->SetString("tag", session_tag); 162 session_data->SetString("tag", session_tag);
163 session_data->SetString("name", session->session_name); 163 session_data->SetString("name", session->session_name);
164 session_data->SetString("deviceType", session->DeviceTypeAsString());
164 session_data->SetString("modifiedTime", 165 session_data->SetString("modifiedTime",
165 FormatSessionTime(session->modified_time)); 166 FormatSessionTime(session->modified_time));
166 167
167 bool is_collapsed = collapsed_sessions->HasKey(session_tag); 168 bool is_collapsed = collapsed_sessions->HasKey(session_tag);
168 session_data->SetBoolean("collapsed", is_collapsed); 169 session_data->SetBoolean("collapsed", is_collapsed);
169 if (is_collapsed) 170 if (is_collapsed)
170 current_collapsed_sessions->SetBoolean(session_tag, true); 171 current_collapsed_sessions->SetBoolean(session_tag, true);
171 172
172 scoped_ptr<ListValue> window_list(new ListValue()); 173 scoped_ptr<ListValue> window_list(new ListValue());
173 for (SyncedSession::SyncedWindowMap::const_iterator it = 174 for (SyncedSession::SyncedWindowMap::const_iterator it =
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 325 }
325 scoped_ptr<ListValue> tab_values(new ListValue()); 326 scoped_ptr<ListValue> tab_values(new ListValue());
326 // Calculate the last |modification_time| for all entries within a window. 327 // Calculate the last |modification_time| for all entries within a window.
327 base::Time modification_time = window.timestamp; 328 base::Time modification_time = window.timestamp;
328 for (size_t i = 0; i < window.tabs.size(); ++i) { 329 for (size_t i = 0; i < window.tabs.size(); ++i) {
329 scoped_ptr<DictionaryValue> tab_value(new DictionaryValue()); 330 scoped_ptr<DictionaryValue> tab_value(new DictionaryValue());
330 if (SessionTabToValue(*window.tabs[i], tab_value.get())) { 331 if (SessionTabToValue(*window.tabs[i], tab_value.get())) {
331 modification_time = std::max(modification_time, 332 modification_time = std::max(modification_time,
332 window.tabs[i]->timestamp); 333 window.tabs[i]->timestamp);
333 tab_values->Append(tab_value.release()); 334 tab_values->Append(tab_value.release());
334 } 335 }
335 } 336 }
336 if (tab_values->GetSize() == 0) 337 if (tab_values->GetSize() == 0)
337 return false; 338 return false;
338 dictionary->SetString("type", "window"); 339 dictionary->SetString("type", "window");
339 dictionary->SetDouble("timestamp", modification_time.ToInternalValue()); 340 dictionary->SetDouble("timestamp", modification_time.ToInternalValue());
340 const base::TimeDelta last_synced = base::Time::Now() - modification_time; 341 const base::TimeDelta last_synced = base::Time::Now() - modification_time;
341 // If clock skew leads to a future time, or we last synced less than a minute 342 // If clock skew leads to a future time, or we last synced less than a minute
342 // ago, output "Just now". 343 // ago, output "Just now".
343 dictionary->SetString("userVisibleTimestamp", 344 dictionary->SetString("userVisibleTimestamp",
344 last_synced < base::TimeDelta::FromMinutes(1) ? 345 last_synced < base::TimeDelta::FromMinutes(1) ?
345 l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW) : 346 l10n_util::GetStringUTF16(IDS_SYNC_TIME_JUST_NOW) :
346 TimeFormat::TimeElapsed(last_synced)); 347 TimeFormat::TimeElapsed(last_synced));
347 dictionary->SetInteger("sessionId", window.window_id.id()); 348 dictionary->SetInteger("sessionId", window.window_id.id());
348 dictionary->Set("tabs", tab_values.release()); 349 dictionary->Set("tabs", tab_values.release());
349 return true; 350 return true;
350 } 351 }
351 352
352 } // namespace browser_sync 353 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/synced_session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698