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/extensions/application_launch.h" | 5 #include "chrome/browser/ui/extensions/application_launch.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/field_trial.h" | 8 #include "base/metrics/field_trial.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "chrome/browser/extensions/default_apps_trial.h" | 10 #include "chrome/browser/extensions/default_apps_trial.h" |
11 #include "chrome/browser/extensions/extension_prefs.h" | 11 #include "chrome/browser/extensions/extension_prefs.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/extensions/extension_tab_helper.h" | 13 #include "chrome/browser/extensions/extension_tab_helper.h" |
14 #include "chrome/browser/extensions/platform_app_launcher.h" | 14 #include "chrome/browser/extensions/platform_app_launcher.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/browser/ui/browser_finder.h" | 18 #include "chrome/browser/ui/browser_finder.h" |
| 19 #include "chrome/browser/ui/browser_tabstrip.h" |
19 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
20 #include "chrome/browser/ui/panels/panel_manager.h" | 21 #include "chrome/browser/ui/panels/panel_manager.h" |
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
22 #include "chrome/browser/web_applications/web_app.h" | 23 #include "chrome/browser/web_applications/web_app.h" |
23 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
25 #include "chrome/common/extensions/extension_constants.h" | 26 #include "chrome/common/extensions/extension_constants.h" |
26 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
27 #include "content/public/browser/render_view_host.h" | 28 #include "content/public/browser/render_view_host.h" |
28 #include "content/public/browser/web_contents.h" | 29 #include "content/public/browser/web_contents.h" |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 else if (launch_type == ExtensionPrefs::LAUNCH_WINDOW) | 203 else if (launch_type == ExtensionPrefs::LAUNCH_WINDOW) |
203 params.initial_show_state = ui::SHOW_STATE_NORMAL; | 204 params.initial_show_state = ui::SHOW_STATE_NORMAL; |
204 } | 205 } |
205 #endif | 206 #endif |
206 | 207 |
207 Browser* browser = Browser::CreateWithParams(params); | 208 Browser* browser = Browser::CreateWithParams(params); |
208 | 209 |
209 if (app_browser) | 210 if (app_browser) |
210 *app_browser = browser; | 211 *app_browser = browser; |
211 | 212 |
212 TabContents* tab_contents = | 213 TabContents* tab_contents = chrome::AddSelectedTabWithURL( |
213 browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_START_PAGE); | 214 browser, url, content::PAGE_TRANSITION_START_PAGE); |
214 WebContents* contents = tab_contents->web_contents(); | 215 WebContents* contents = tab_contents->web_contents(); |
215 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 216 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
216 contents->GetRenderViewHost()->SyncRendererPrefs(); | 217 contents->GetRenderViewHost()->SyncRendererPrefs(); |
217 // TODO(stevenjb): Find the right centralized place to do this. Currently it | 218 // TODO(stevenjb): Find the right centralized place to do this. Currently it |
218 // is only done for app tabs in normal browsers through SetExtensionAppById. | 219 // is only done for app tabs in normal browsers through SetExtensionAppById. |
219 if (extension && type == Browser::TYPE_PANEL) { | 220 if (extension && type == Browser::TYPE_PANEL) { |
220 tab_contents->extension_tab_helper()-> | 221 tab_contents->extension_tab_helper()-> |
221 SetExtensionAppIconById(extension->id()); | 222 SetExtensionAppIconById(extension->id()); |
222 } | 223 } |
223 | 224 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 297 |
297 GURL extension_url = UrlForExtension(extension, override_url); | 298 GURL extension_url = UrlForExtension(extension, override_url); |
298 // TODO(erikkay): START_PAGE doesn't seem like the right transition in all | 299 // TODO(erikkay): START_PAGE doesn't seem like the right transition in all |
299 // cases. | 300 // cases. |
300 browser::NavigateParams params(browser, extension_url, | 301 browser::NavigateParams params(browser, extension_url, |
301 content::PAGE_TRANSITION_START_PAGE); | 302 content::PAGE_TRANSITION_START_PAGE); |
302 params.tabstrip_add_types = add_type; | 303 params.tabstrip_add_types = add_type; |
303 params.disposition = disposition; | 304 params.disposition = disposition; |
304 | 305 |
305 if (disposition == CURRENT_TAB) { | 306 if (disposition == CURRENT_TAB) { |
306 WebContents* existing_tab = browser->GetActiveWebContents(); | 307 WebContents* existing_tab = chrome::GetActiveWebContents(browser); |
307 TabStripModel* model = browser->tab_strip_model(); | 308 TabStripModel* model = browser->tab_strip_model(); |
308 int tab_index = model->GetIndexOfWebContents(existing_tab); | 309 int tab_index = model->GetIndexOfWebContents(existing_tab); |
309 | 310 |
310 existing_tab->OpenURL(content::OpenURLParams( | 311 existing_tab->OpenURL(content::OpenURLParams( |
311 extension_url, | 312 extension_url, |
312 content::Referrer(existing_tab->GetURL(), | 313 content::Referrer(existing_tab->GetURL(), |
313 WebKit::WebReferrerPolicyDefault), | 314 WebKit::WebReferrerPolicyDefault), |
314 disposition, content::PAGE_TRANSITION_LINK, false)); | 315 disposition, content::PAGE_TRANSITION_LINK, false)); |
315 // Reset existing_tab as OpenURL() may have clobbered it. | 316 // Reset existing_tab as OpenURL() may have clobbered it. |
316 existing_tab = browser->GetActiveWebContents(); | 317 existing_tab = chrome::GetActiveWebContents(browser); |
317 if (params.tabstrip_add_types & TabStripModel::ADD_PINNED) { | 318 if (params.tabstrip_add_types & TabStripModel::ADD_PINNED) { |
318 model->SetTabPinned(tab_index, true); | 319 model->SetTabPinned(tab_index, true); |
319 // Pinning may have moved the tab. | 320 // Pinning may have moved the tab. |
320 tab_index = model->GetIndexOfWebContents(existing_tab); | 321 tab_index = model->GetIndexOfWebContents(existing_tab); |
321 } | 322 } |
322 if (params.tabstrip_add_types & TabStripModel::ADD_ACTIVE) | 323 if (params.tabstrip_add_types & TabStripModel::ADD_ACTIVE) |
323 model->ActivateTabAt(tab_index, true); | 324 model->ActivateTabAt(tab_index, true); |
324 | 325 |
325 contents = existing_tab; | 326 contents = existing_tab; |
326 } else { | 327 } else { |
(...skipping 13 matching lines...) Expand all Loading... |
340 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN && | 341 if (launch_type == ExtensionPrefs::LAUNCH_FULLSCREEN && |
341 !browser->window()->IsFullscreen()) { | 342 !browser->window()->IsFullscreen()) { |
342 browser->ToggleFullscreenMode(); | 343 browser->ToggleFullscreenMode(); |
343 } | 344 } |
344 #endif | 345 #endif |
345 | 346 |
346 return contents; | 347 return contents; |
347 } | 348 } |
348 | 349 |
349 } // namespace application_launch | 350 } // namespace application_launch |
OLD | NEW |