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