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

Side by Side Diff: chrome/browser/extensions/api/sessions/sessions_api.cc

Issue 2248873002: Convert WindowOpenDisposition to an enum class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 3 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
OLDNEW
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 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 // matches the provided ID and the entry type is Window. 465 // matches the provided ID and the entry type is Window.
466 is_window = is_window_entry(*entry); 466 is_window = is_window_entry(*entry);
467 break; 467 break;
468 } 468 }
469 } 469 }
470 470
471 sessions::LiveTabContext* context = 471 sessions::LiveTabContext* context =
472 BrowserLiveTabContext::FindContextForWebContents( 472 BrowserLiveTabContext::FindContextForWebContents(
473 browser->tab_strip_model()->GetActiveWebContents()); 473 browser->tab_strip_model()->GetActiveWebContents());
474 std::vector<sessions::LiveTab*> restored_tabs = 474 std::vector<sessions::LiveTab*> restored_tabs =
475 tab_restore_service->RestoreEntryById(context, session_id.id(), UNKNOWN); 475 tab_restore_service->RestoreEntryById(context, session_id.id(),
476 WindowOpenDisposition::UNKNOWN);
476 // If the ID is invalid, restored_tabs will be empty. 477 // If the ID is invalid, restored_tabs will be empty.
477 if (restored_tabs.empty()) { 478 if (restored_tabs.empty()) {
478 SetInvalidIdError(session_id.ToString()); 479 SetInvalidIdError(session_id.ToString());
479 return false; 480 return false;
480 } 481 }
481 482
482 sessions::ContentLiveTab* first_tab = 483 sessions::ContentLiveTab* first_tab =
483 static_cast<sessions::ContentLiveTab*>(restored_tabs[0]); 484 static_cast<sessions::ContentLiveTab*>(restored_tabs[0]);
484 485
485 // Retrieve the window through any of the tabs in restored_tabs. 486 // Retrieve the window through any of the tabs in restored_tabs.
(...skipping 21 matching lines...) Expand all
507 } 508 }
508 509
509 const sessions::SessionTab* tab = NULL; 510 const sessions::SessionTab* tab = NULL;
510 if (open_tabs->GetForeignTab(session_id.session_tag(), 511 if (open_tabs->GetForeignTab(session_id.session_tag(),
511 session_id.id(), 512 session_id.id(),
512 &tab)) { 513 &tab)) {
513 TabStripModel* tab_strip = browser->tab_strip_model(); 514 TabStripModel* tab_strip = browser->tab_strip_model();
514 content::WebContents* contents = tab_strip->GetActiveWebContents(); 515 content::WebContents* contents = tab_strip->GetActiveWebContents();
515 516
516 content::WebContents* tab_contents = 517 content::WebContents* tab_contents =
517 SessionRestore::RestoreForeignSessionTab(contents, *tab, 518 SessionRestore::RestoreForeignSessionTab(
518 NEW_FOREGROUND_TAB); 519 contents, *tab, WindowOpenDisposition::NEW_FOREGROUND_TAB);
519 SetResultRestoredTab(tab_contents); 520 SetResultRestoredTab(tab_contents);
520 return true; 521 return true;
521 } 522 }
522 523
523 // Restoring a full window. 524 // Restoring a full window.
524 std::vector<const sessions::SessionWindow*> windows; 525 std::vector<const sessions::SessionWindow*> windows;
525 if (!open_tabs->GetForeignSession(session_id.session_tag(), &windows)) { 526 if (!open_tabs->GetForeignSession(session_id.session_tag(), &windows)) {
526 SetInvalidIdError(session_id.ToString()); 527 SetInvalidIdError(session_id.ToString());
527 return false; 528 return false;
528 } 529 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 return g_factory.Pointer(); 626 return g_factory.Pointer();
626 } 627 }
627 628
628 void SessionsAPI::OnListenerAdded(const EventListenerInfo& details) { 629 void SessionsAPI::OnListenerAdded(const EventListenerInfo& details) {
629 sessions_event_router_.reset( 630 sessions_event_router_.reset(
630 new SessionsEventRouter(Profile::FromBrowserContext(browser_context_))); 631 new SessionsEventRouter(Profile::FromBrowserContext(browser_context_)));
631 EventRouter::Get(browser_context_)->UnregisterObserver(this); 632 EventRouter::Get(browser_context_)->UnregisterObserver(this);
632 } 633 }
633 634
634 } // namespace extensions 635 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698