| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "apps/launcher.h" | 9 #include "apps/launcher.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 profile, | 175 profile, |
| 176 params.desktop_type)); | 176 params.desktop_type)); |
| 177 | 177 |
| 178 browser_params.initial_show_state = DetermineWindowShowState(profile, | 178 browser_params.initial_show_state = DetermineWindowShowState(profile, |
| 179 params.container, | 179 params.container, |
| 180 extension); | 180 extension); |
| 181 | 181 |
| 182 Browser* browser = new Browser(browser_params); | 182 Browser* browser = new Browser(browser_params); |
| 183 | 183 |
| 184 WebContents* web_contents = chrome::AddSelectedTabWithURL( | 184 WebContents* web_contents = chrome::AddSelectedTabWithURL( |
| 185 browser, url, content::PAGE_TRANSITION_AUTO_TOPLEVEL); | 185 browser, url, ui::PAGE_TRANSITION_AUTO_TOPLEVEL); |
| 186 web_contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 186 web_contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 187 web_contents->GetRenderViewHost()->SyncRendererPrefs(); | 187 web_contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 188 | 188 |
| 189 browser->window()->Show(); | 189 browser->window()->Show(); |
| 190 | 190 |
| 191 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial | 191 // TODO(jcampan): http://crbug.com/8123 we should not need to set the initial |
| 192 // focus explicitly. | 192 // focus explicitly. |
| 193 web_contents->SetInitialFocus(); | 193 web_contents->SetInitialFocus(); |
| 194 return web_contents; | 194 return web_contents; |
| 195 } | 195 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 221 extensions::LaunchType launch_type = | 221 extensions::LaunchType launch_type = |
| 222 extensions::GetLaunchType(ExtensionPrefs::Get(profile), extension); | 222 extensions::GetLaunchType(ExtensionPrefs::Get(profile), extension); |
| 223 UMA_HISTOGRAM_ENUMERATION("Extensions.AppTabLaunchType", launch_type, 100); | 223 UMA_HISTOGRAM_ENUMERATION("Extensions.AppTabLaunchType", launch_type, 100); |
| 224 | 224 |
| 225 int add_type = TabStripModel::ADD_ACTIVE; | 225 int add_type = TabStripModel::ADD_ACTIVE; |
| 226 if (launch_type == extensions::LAUNCH_TYPE_PINNED) | 226 if (launch_type == extensions::LAUNCH_TYPE_PINNED) |
| 227 add_type |= TabStripModel::ADD_PINNED; | 227 add_type |= TabStripModel::ADD_PINNED; |
| 228 | 228 |
| 229 GURL extension_url = UrlForExtension(extension, launch_params.override_url); | 229 GURL extension_url = UrlForExtension(extension, launch_params.override_url); |
| 230 chrome::NavigateParams params(browser, extension_url, | 230 chrome::NavigateParams params(browser, extension_url, |
| 231 content::PAGE_TRANSITION_AUTO_TOPLEVEL); | 231 ui::PAGE_TRANSITION_AUTO_TOPLEVEL); |
| 232 params.tabstrip_add_types = add_type; | 232 params.tabstrip_add_types = add_type; |
| 233 params.disposition = disposition; | 233 params.disposition = disposition; |
| 234 | 234 |
| 235 if (disposition == CURRENT_TAB) { | 235 if (disposition == CURRENT_TAB) { |
| 236 WebContents* existing_tab = | 236 WebContents* existing_tab = |
| 237 browser->tab_strip_model()->GetActiveWebContents(); | 237 browser->tab_strip_model()->GetActiveWebContents(); |
| 238 TabStripModel* model = browser->tab_strip_model(); | 238 TabStripModel* model = browser->tab_strip_model(); |
| 239 int tab_index = model->GetIndexOfWebContents(existing_tab); | 239 int tab_index = model->GetIndexOfWebContents(existing_tab); |
| 240 | 240 |
| 241 existing_tab->OpenURL(content::OpenURLParams( | 241 existing_tab->OpenURL(content::OpenURLParams( |
| 242 extension_url, | 242 extension_url, |
| 243 content::Referrer(existing_tab->GetURL(), | 243 content::Referrer(existing_tab->GetURL(), |
| 244 blink::WebReferrerPolicyDefault), | 244 blink::WebReferrerPolicyDefault), |
| 245 disposition, content::PAGE_TRANSITION_LINK, false)); | 245 disposition, ui::PAGE_TRANSITION_LINK, false)); |
| 246 // Reset existing_tab as OpenURL() may have clobbered it. | 246 // Reset existing_tab as OpenURL() may have clobbered it. |
| 247 existing_tab = browser->tab_strip_model()->GetActiveWebContents(); | 247 existing_tab = browser->tab_strip_model()->GetActiveWebContents(); |
| 248 if (params.tabstrip_add_types & TabStripModel::ADD_PINNED) { | 248 if (params.tabstrip_add_types & TabStripModel::ADD_PINNED) { |
| 249 model->SetTabPinned(tab_index, true); | 249 model->SetTabPinned(tab_index, true); |
| 250 // Pinning may have moved the tab. | 250 // Pinning may have moved the tab. |
| 251 tab_index = model->GetIndexOfWebContents(existing_tab); | 251 tab_index = model->GetIndexOfWebContents(existing_tab); |
| 252 } | 252 } |
| 253 if (params.tabstrip_add_types & TabStripModel::ADD_ACTIVE) | 253 if (params.tabstrip_add_types & TabStripModel::ADD_ACTIVE) |
| 254 model->ActivateTabAt(tab_index, true); | 254 model->ActivateTabAt(tab_index, true); |
| 255 | 255 |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 | 456 |
| 457 // For extensions lacking launch urls, determine a reasonable fallback. | 457 // For extensions lacking launch urls, determine a reasonable fallback. |
| 458 if (!url.is_valid()) { | 458 if (!url.is_valid()) { |
| 459 url = extensions::OptionsPageInfo::GetOptionsPage(extension); | 459 url = extensions::OptionsPageInfo::GetOptionsPage(extension); |
| 460 if (!url.is_valid()) | 460 if (!url.is_valid()) |
| 461 url = GURL(chrome::kChromeUIExtensionsURL); | 461 url = GURL(chrome::kChromeUIExtensionsURL); |
| 462 } | 462 } |
| 463 | 463 |
| 464 return url; | 464 return url; |
| 465 } | 465 } |
| OLD | NEW |