OLD | NEW |
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 return sessions::ContentLiveTab::GetForWebContents(web_contents); | 98 return sessions::ContentLiveTab::GetForWebContents(web_contents); |
99 } | 99 } |
100 | 100 |
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 chrome::HostDesktopType host_desktop_type, | |
109 const std::string& app_name) { | 108 const std::string& app_name) { |
110 Browser* browser; | 109 Browser* browser; |
111 if (app_name.empty()) { | 110 if (app_name.empty()) { |
112 browser = new Browser(Browser::CreateParams(profile)); | 111 browser = new Browser(Browser::CreateParams(profile)); |
113 } else { | 112 } else { |
114 // Only trusted app popup windows should ever be restored. | 113 // Only trusted app popup windows should ever be restored. |
115 browser = new Browser(Browser::CreateParams::CreateForApp( | 114 browser = new Browser(Browser::CreateParams::CreateForApp( |
116 app_name, true /* trusted_source */, gfx::Rect(), profile)); | 115 app_name, true /* trusted_source */, gfx::Rect(), profile)); |
117 } | 116 } |
118 if (browser) | 117 if (browser) |
119 return browser->live_tab_context(); | 118 return browser->live_tab_context(); |
120 else | 119 else |
121 return NULL; | 120 return NULL; |
122 } | 121 } |
123 | 122 |
124 // static | 123 // static |
125 sessions::LiveTabContext* BrowserLiveTabContext::FindContextForWebContents( | 124 sessions::LiveTabContext* BrowserLiveTabContext::FindContextForWebContents( |
126 const WebContents* contents) { | 125 const WebContents* contents) { |
127 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 126 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
128 return browser ? browser->live_tab_context() : nullptr; | 127 return browser ? browser->live_tab_context() : nullptr; |
129 } | 128 } |
130 | 129 |
131 // static | 130 // static |
132 sessions::LiveTabContext* BrowserLiveTabContext::FindContextWithID( | 131 sessions::LiveTabContext* BrowserLiveTabContext::FindContextWithID( |
133 SessionID::id_type desired_id, | 132 SessionID::id_type desired_id) { |
134 chrome::HostDesktopType host_desktop_type) { | |
135 Browser* browser = chrome::FindBrowserWithID(desired_id); | 133 Browser* browser = chrome::FindBrowserWithID(desired_id); |
136 return (browser && browser->host_desktop_type() == host_desktop_type) | 134 return browser ? browser->live_tab_context() : nullptr; |
137 ? browser->live_tab_context() | |
138 : NULL; | |
139 } | 135 } |
OLD | NEW |