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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 ++it) { | 342 ++it) { |
343 std::unique_ptr<api::sessions::Session> session_model( | 343 std::unique_ptr<api::sessions::Session> session_model( |
344 CreateSessionModel(*it->second, session->session_tag)); | 344 CreateSessionModel(*it->second, session->session_tag)); |
345 if (session_model) | 345 if (session_model) |
346 device_struct.sessions.push_back(std::move(*session_model)); | 346 device_struct.sessions.push_back(std::move(*session_model)); |
347 } | 347 } |
348 return device_struct; | 348 return device_struct; |
349 } | 349 } |
350 | 350 |
351 bool SessionsGetDevicesFunction::RunSync() { | 351 bool SessionsGetDevicesFunction::RunSync() { |
352 ProfileSyncService* service = | 352 browser_sync::ProfileSyncService* service = |
353 ProfileSyncServiceFactory::GetInstance()->GetForProfile(GetProfile()); | 353 ProfileSyncServiceFactory::GetInstance()->GetForProfile(GetProfile()); |
354 if (!(service && service->GetPreferredDataTypes().Has(syncer::SESSIONS))) { | 354 if (!(service && service->GetPreferredDataTypes().Has(syncer::SESSIONS))) { |
355 // Sync not enabled. | 355 // Sync not enabled. |
356 results_ = | 356 results_ = |
357 GetDevices::Results::Create(std::vector<api::sessions::Device>()); | 357 GetDevices::Results::Create(std::vector<api::sessions::Device>()); |
358 return true; | 358 return true; |
359 } | 359 } |
360 | 360 |
361 sync_sessions::OpenTabsUIDelegate* open_tabs = | 361 sync_sessions::OpenTabsUIDelegate* open_tabs = |
362 service->GetOpenTabsUIDelegate(); | 362 service->GetOpenTabsUIDelegate(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 return SetResultRestoredWindow( | 489 return SetResultRestoredWindow( |
490 ExtensionTabUtil::GetWindowIdOfTab(first_tab->web_contents())); | 490 ExtensionTabUtil::GetWindowIdOfTab(first_tab->web_contents())); |
491 } | 491 } |
492 | 492 |
493 SetResultRestoredTab(first_tab->web_contents()); | 493 SetResultRestoredTab(first_tab->web_contents()); |
494 return true; | 494 return true; |
495 } | 495 } |
496 | 496 |
497 bool SessionsRestoreFunction::RestoreForeignSession(const SessionId& session_id, | 497 bool SessionsRestoreFunction::RestoreForeignSession(const SessionId& session_id, |
498 Browser* browser) { | 498 Browser* browser) { |
499 ProfileSyncService* service = | 499 browser_sync::ProfileSyncService* service = |
500 ProfileSyncServiceFactory::GetInstance()->GetForProfile(GetProfile()); | 500 ProfileSyncServiceFactory::GetInstance()->GetForProfile(GetProfile()); |
501 if (!(service && service->GetPreferredDataTypes().Has(syncer::SESSIONS))) { | 501 if (!(service && service->GetPreferredDataTypes().Has(syncer::SESSIONS))) { |
502 SetError(kSessionSyncError); | 502 SetError(kSessionSyncError); |
503 return false; | 503 return false; |
504 } | 504 } |
505 sync_sessions::OpenTabsUIDelegate* open_tabs = | 505 sync_sessions::OpenTabsUIDelegate* open_tabs = |
506 service->GetOpenTabsUIDelegate(); | 506 service->GetOpenTabsUIDelegate(); |
507 if (!open_tabs) { | 507 if (!open_tabs) { |
508 SetError(kSessionSyncError); | 508 SetError(kSessionSyncError); |
509 return false; | 509 return false; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 return g_factory.Pointer(); | 628 return g_factory.Pointer(); |
629 } | 629 } |
630 | 630 |
631 void SessionsAPI::OnListenerAdded(const EventListenerInfo& details) { | 631 void SessionsAPI::OnListenerAdded(const EventListenerInfo& details) { |
632 sessions_event_router_.reset( | 632 sessions_event_router_.reset( |
633 new SessionsEventRouter(Profile::FromBrowserContext(browser_context_))); | 633 new SessionsEventRouter(Profile::FromBrowserContext(browser_context_))); |
634 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 634 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
635 } | 635 } |
636 | 636 |
637 } // namespace extensions | 637 } // namespace extensions |
OLD | NEW |