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/macros.h" | 10 #include "base/macros.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 gfx::Rect initial_bounds; | 188 gfx::Rect initial_bounds; |
189 if (!params.override_bounds.IsEmpty()) { | 189 if (!params.override_bounds.IsEmpty()) { |
190 initial_bounds = params.override_bounds; | 190 initial_bounds = params.override_bounds; |
191 } else if (extension) { | 191 } else if (extension) { |
192 initial_bounds.set_width( | 192 initial_bounds.set_width( |
193 extensions::AppLaunchInfo::GetLaunchWidth(extension)); | 193 extensions::AppLaunchInfo::GetLaunchWidth(extension)); |
194 initial_bounds.set_height( | 194 initial_bounds.set_height( |
195 extensions::AppLaunchInfo::GetLaunchHeight(extension)); | 195 extensions::AppLaunchInfo::GetLaunchHeight(extension)); |
196 } | 196 } |
197 | 197 |
198 Browser::CreateParams browser_params( | 198 Browser::CreateParams browser_params(Browser::CreateParams::CreateForApp( |
199 Browser::CreateParams::CreateForApp(app_name, | 199 app_name, true /* trusted_source */, initial_bounds, profile)); |
200 true /* trusted_source */, | |
201 initial_bounds, | |
202 profile, | |
203 params.desktop_type)); | |
204 | 200 |
205 browser_params.initial_show_state = DetermineWindowShowState(profile, | 201 browser_params.initial_show_state = DetermineWindowShowState(profile, |
206 params.container, | 202 params.container, |
207 extension); | 203 extension); |
208 | 204 |
209 Browser* browser = new Browser(browser_params); | 205 Browser* browser = new Browser(browser_params); |
210 ui::PageTransition transition = | 206 ui::PageTransition transition = |
211 (extension ? ui::PAGE_TRANSITION_AUTO_BOOKMARK | 207 (extension ? ui::PAGE_TRANSITION_AUTO_BOOKMARK |
212 : ui::PAGE_TRANSITION_AUTO_TOPLEVEL); | 208 : ui::PAGE_TRANSITION_AUTO_TOPLEVEL); |
213 | 209 |
(...skipping 14 matching lines...) Expand all Loading... |
228 const GURL& url) { | 224 const GURL& url) { |
229 const Extension* extension = GetExtension(launch_params); | 225 const Extension* extension = GetExtension(launch_params); |
230 CHECK(extension); | 226 CHECK(extension); |
231 Profile* const profile = launch_params.profile; | 227 Profile* const profile = launch_params.profile; |
232 WindowOpenDisposition disposition = launch_params.disposition; | 228 WindowOpenDisposition disposition = launch_params.disposition; |
233 | 229 |
234 Browser* browser = chrome::FindTabbedBrowser(profile, false); | 230 Browser* browser = chrome::FindTabbedBrowser(profile, false); |
235 WebContents* contents = NULL; | 231 WebContents* contents = NULL; |
236 if (!browser) { | 232 if (!browser) { |
237 // No browser for this profile, need to open a new one. | 233 // No browser for this profile, need to open a new one. |
238 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, | 234 browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile)); |
239 profile, | |
240 launch_params.desktop_type)); | |
241 browser->window()->Show(); | 235 browser->window()->Show(); |
242 // There's no current tab in this browser window, so add a new one. | 236 // There's no current tab in this browser window, so add a new one. |
243 disposition = NEW_FOREGROUND_TAB; | 237 disposition = NEW_FOREGROUND_TAB; |
244 } else { | 238 } else { |
245 // For existing browser, ensure its window is shown and activated. | 239 // For existing browser, ensure its window is shown and activated. |
246 browser->window()->Show(); | 240 browser->window()->Show(); |
247 browser->window()->Activate(); | 241 browser->window()->Activate(); |
248 } | 242 } |
249 | 243 |
250 extensions::LaunchType launch_type = | 244 extensions::LaunchType launch_type = |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); | 417 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); |
424 | 418 |
425 return tab; | 419 return tab; |
426 } | 420 } |
427 | 421 |
428 bool CanLaunchViaEvent(const extensions::Extension* extension) { | 422 bool CanLaunchViaEvent(const extensions::Extension* extension) { |
429 const extensions::Feature* feature = | 423 const extensions::Feature* feature = |
430 extensions::FeatureProvider::GetAPIFeature("app.runtime"); | 424 extensions::FeatureProvider::GetAPIFeature("app.runtime"); |
431 return feature->IsAvailableToExtension(extension).is_available(); | 425 return feature->IsAvailableToExtension(extension).is_available(); |
432 } | 426 } |
OLD | NEW |