| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/api/sessions/sessions_api.h" | 5 #include "chrome/browser/extensions/api/sessions/sessions_api.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 scoped_ptr<api::sessions::Device> SessionsGetDevicesFunction::CreateDeviceModel( | 342 scoped_ptr<api::sessions::Device> SessionsGetDevicesFunction::CreateDeviceModel( |
| 343 const browser_sync::SyncedSession* session) { | 343 const browser_sync::SyncedSession* session) { |
| 344 int max_results = api::sessions::MAX_SESSION_RESULTS; | 344 int max_results = api::sessions::MAX_SESSION_RESULTS; |
| 345 // Already validated in RunAsync(). | 345 // Already validated in RunAsync(). |
| 346 scoped_ptr<GetDevices::Params> params(GetDevices::Params::Create(*args_)); | 346 scoped_ptr<GetDevices::Params> params(GetDevices::Params::Create(*args_)); |
| 347 if (params->filter && params->filter->max_results) | 347 if (params->filter && params->filter->max_results) |
| 348 max_results = *params->filter->max_results; | 348 max_results = *params->filter->max_results; |
| 349 | 349 |
| 350 scoped_ptr<api::sessions::Device> device_struct(new api::sessions::Device); | 350 scoped_ptr<api::sessions::Device> device_struct(new api::sessions::Device); |
| 351 device_struct->info = session->session_name; | 351 device_struct->info = session->session_name; |
| 352 device_struct->device_name = session->session_name; |
| 352 | 353 |
| 353 for (browser_sync::SyncedSession::SyncedWindowMap::const_iterator it = | 354 for (browser_sync::SyncedSession::SyncedWindowMap::const_iterator it = |
| 354 session->windows.begin(); it != session->windows.end() && | 355 session->windows.begin(); it != session->windows.end() && |
| 355 static_cast<int>(device_struct->sessions.size()) < max_results; ++it) { | 356 static_cast<int>(device_struct->sessions.size()) < max_results; ++it) { |
| 356 scoped_ptr<api::sessions::Session> session_model(CreateSessionModel( | 357 scoped_ptr<api::sessions::Session> session_model(CreateSessionModel( |
| 357 *it->second, session->session_tag)); | 358 *it->second, session->session_tag)); |
| 358 if (session_model) | 359 if (session_model) |
| 359 device_struct->sessions.push_back(make_linked_ptr( | 360 device_struct->sessions.push_back(make_linked_ptr( |
| 360 session_model.release())); | 361 session_model.release())); |
| 361 } | 362 } |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 return g_factory.Pointer(); | 644 return g_factory.Pointer(); |
| 644 } | 645 } |
| 645 | 646 |
| 646 void SessionsAPI::OnListenerAdded(const EventListenerInfo& details) { | 647 void SessionsAPI::OnListenerAdded(const EventListenerInfo& details) { |
| 647 sessions_event_router_.reset( | 648 sessions_event_router_.reset( |
| 648 new SessionsEventRouter(Profile::FromBrowserContext(browser_context_))); | 649 new SessionsEventRouter(Profile::FromBrowserContext(browser_context_))); |
| 649 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 650 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
| 650 } | 651 } |
| 651 | 652 |
| 652 } // namespace extensions | 653 } // namespace extensions |
| OLD | NEW |