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

Side by Side Diff: chrome/browser/ui/browser_live_tab_context.cc

Issue 2345763002: Fix tabs duplication when restoring last closed window. (Closed)
Patch Set: 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 (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/browser_live_tab_context.h" 5 #include "chrome/browser/ui/browser_live_tab_context.h"
6 6
7 #include "chrome/browser/ui/browser.h" 7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/browser_commands.h" 8 #include "chrome/browser/ui/browser_commands.h"
9 #include "chrome/browser/ui/browser_finder.h" 9 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/browser_tabrestore.h" 10 #include "chrome/browser/ui/browser_tabrestore.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 void BrowserLiveTabContext::CloseTab() { 101 void BrowserLiveTabContext::CloseTab() {
102 chrome::CloseTab(browser_); 102 chrome::CloseTab(browser_);
103 } 103 }
104 104
105 // static 105 // static
106 sessions::LiveTabContext* BrowserLiveTabContext::Create( 106 sessions::LiveTabContext* BrowserLiveTabContext::Create(
107 Profile* profile, 107 Profile* profile,
108 const std::string& app_name) { 108 const std::string& app_name) {
109 Browser* browser; 109 Browser* browser;
110 if (app_name.empty()) { 110 if (app_name.empty()) {
111 browser = new Browser(Browser::CreateParams(profile)); 111 auto params = Browser::CreateParams(profile);
112 params.dont_restore = true;
113 browser = new Browser(params);
112 } else { 114 } else {
113 // Only trusted app popup windows should ever be restored. 115 // Only trusted app popup windows should ever be restored.
114 browser = new Browser(Browser::CreateParams::CreateForApp( 116 browser = new Browser(Browser::CreateParams::CreateForApp(
115 app_name, true /* trusted_source */, gfx::Rect(), profile)); 117 app_name, true /* trusted_source */, gfx::Rect(), profile));
116 } 118 }
117 if (browser) 119 if (browser)
118 return browser->live_tab_context(); 120 return browser->live_tab_context();
119 else 121 else
120 return NULL; 122 return NULL;
121 } 123 }
122 124
123 // static 125 // static
124 sessions::LiveTabContext* BrowserLiveTabContext::FindContextForWebContents( 126 sessions::LiveTabContext* BrowserLiveTabContext::FindContextForWebContents(
125 const WebContents* contents) { 127 const WebContents* contents) {
126 Browser* browser = chrome::FindBrowserWithWebContents(contents); 128 Browser* browser = chrome::FindBrowserWithWebContents(contents);
127 return browser ? browser->live_tab_context() : nullptr; 129 return browser ? browser->live_tab_context() : nullptr;
128 } 130 }
129 131
130 // static 132 // static
131 sessions::LiveTabContext* BrowserLiveTabContext::FindContextWithID( 133 sessions::LiveTabContext* BrowserLiveTabContext::FindContextWithID(
132 SessionID::id_type desired_id) { 134 SessionID::id_type desired_id) {
133 Browser* browser = chrome::FindBrowserWithID(desired_id); 135 Browser* browser = chrome::FindBrowserWithID(desired_id);
134 return browser ? browser->live_tab_context() : nullptr; 136 return browser ? browser->live_tab_context() : nullptr;
135 } 137 }
OLDNEW
« chrome/browser/sessions/tab_restore_browsertest.cc ('K') | « chrome/browser/ui/browser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698