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 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 windows.begin(); | 561 windows.begin(); |
562 while (window != windows.end() | 562 while (window != windows.end() |
563 && (*window)->window_id.id() != session_id.id()) { | 563 && (*window)->window_id.id() != session_id.id()) { |
564 ++window; | 564 ++window; |
565 } | 565 } |
566 if (window == windows.end()) { | 566 if (window == windows.end()) { |
567 SetInvalidIdError(session_id.ToString()); | 567 SetInvalidIdError(session_id.ToString()); |
568 return false; | 568 return false; |
569 } | 569 } |
570 | 570 |
571 chrome::HostDesktopType host_desktop_type = browser->host_desktop_type(); | |
572 // Only restore one window at a time. | 571 // Only restore one window at a time. |
573 std::vector<Browser*> browsers = SessionRestore::RestoreForeignSessionWindows( | 572 std::vector<Browser*> browsers = SessionRestore::RestoreForeignSessionWindows( |
574 GetProfile(), host_desktop_type, window, window + 1); | 573 GetProfile(), window, window + 1); |
575 // Will always create one browser because we only restore one window per call. | 574 // Will always create one browser because we only restore one window per call. |
576 DCHECK_EQ(1u, browsers.size()); | 575 DCHECK_EQ(1u, browsers.size()); |
577 return SetResultRestoredWindow(ExtensionTabUtil::GetWindowId(browsers[0])); | 576 return SetResultRestoredWindow(ExtensionTabUtil::GetWindowId(browsers[0])); |
578 } | 577 } |
579 | 578 |
580 bool SessionsRestoreFunction::RunSync() { | 579 bool SessionsRestoreFunction::RunSync() { |
581 scoped_ptr<Restore::Params> params(Restore::Params::Create(*args_)); | 580 scoped_ptr<Restore::Params> params(Restore::Params::Create(*args_)); |
582 EXTENSION_FUNCTION_VALIDATE(params); | 581 EXTENSION_FUNCTION_VALIDATE(params); |
583 | 582 |
584 Browser* browser = chrome::FindBrowserWithProfile(GetProfile()); | 583 Browser* browser = chrome::FindBrowserWithProfile(GetProfile()); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 return g_factory.Pointer(); | 655 return g_factory.Pointer(); |
657 } | 656 } |
658 | 657 |
659 void SessionsAPI::OnListenerAdded(const EventListenerInfo& details) { | 658 void SessionsAPI::OnListenerAdded(const EventListenerInfo& details) { |
660 sessions_event_router_.reset( | 659 sessions_event_router_.reset( |
661 new SessionsEventRouter(Profile::FromBrowserContext(browser_context_))); | 660 new SessionsEventRouter(Profile::FromBrowserContext(browser_context_))); |
662 EventRouter::Get(browser_context_)->UnregisterObserver(this); | 661 EventRouter::Get(browser_context_)->UnregisterObserver(this); |
663 } | 662 } |
664 | 663 |
665 } // namespace extensions | 664 } // namespace extensions |
OLD | NEW |