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 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
25 #include "chrome/browser/ui/browser_commands.h" | 25 #include "chrome/browser/ui/browser_commands.h" |
26 #include "chrome/browser/ui/browser_finder.h" | 26 #include "chrome/browser/ui/browser_finder.h" |
27 #include "chrome/browser/ui/browser_tabstrip.h" | 27 #include "chrome/browser/ui/browser_tabstrip.h" |
28 #include "chrome/browser/ui/browser_window.h" | 28 #include "chrome/browser/ui/browser_window.h" |
29 #include "chrome/browser/ui/extensions/extension_enable_flow.h" | 29 #include "chrome/browser/ui/extensions/extension_enable_flow.h" |
30 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" | 30 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" |
31 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 31 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
32 #include "chrome/browser/web_applications/web_app.h" | 32 #include "chrome/browser/web_applications/web_app.h" |
33 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/common/extensions/extension_constants.h" |
34 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 35 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
35 #include "chrome/common/extensions/manifest_url_handler.h" | 36 #include "chrome/common/extensions/manifest_url_handler.h" |
36 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
37 #include "content/public/browser/render_view_host.h" | 38 #include "content/public/browser/render_view_host.h" |
38 #include "content/public/browser/web_contents.h" | 39 #include "content/public/browser/web_contents.h" |
39 #include "content/public/browser/web_contents_view.h" | 40 #include "content/public/browser/web_contents_view.h" |
40 #include "content/public/common/renderer_preferences.h" | 41 #include "content/public/common/renderer_preferences.h" |
41 #include "extensions/common/constants.h" | 42 #include "extensions/common/constants.h" |
42 #include "extensions/common/extension.h" | 43 #include "extensions/common/extension.h" |
43 #include "grit/generated_resources.h" | 44 #include "grit/generated_resources.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 url = GURL(chrome::kChromeUIExtensionsURL); | 142 url = GURL(chrome::kChromeUIExtensionsURL); |
142 } | 143 } |
143 | 144 |
144 return url; | 145 return url; |
145 } | 146 } |
146 | 147 |
147 ui::WindowShowState DetermineWindowShowState( | 148 ui::WindowShowState DetermineWindowShowState( |
148 Profile* profile, | 149 Profile* profile, |
149 extensions::LaunchContainer container, | 150 extensions::LaunchContainer container, |
150 const Extension* extension) { | 151 const Extension* extension) { |
151 if (!extension || | 152 if (!extension || container != extensions::LAUNCH_CONTAINER_WINDOW) |
152 container != extensions::LAUNCH_WINDOW) { | |
153 return ui::SHOW_STATE_DEFAULT; | 153 return ui::SHOW_STATE_DEFAULT; |
154 } | |
155 | 154 |
156 if (chrome::IsRunningInForcedAppMode()) | 155 if (chrome::IsRunningInForcedAppMode()) |
157 return ui::SHOW_STATE_FULLSCREEN; | 156 return ui::SHOW_STATE_FULLSCREEN; |
158 | 157 |
159 #if defined(USE_ASH) | 158 #if defined(USE_ASH) |
160 // In ash, LAUNCH_FULLSCREEN launches in a maximized app window and | 159 // In ash, LAUNCH_TYPE_FULLSCREEN launches in a maximized app window and |
161 // LAUNCH_WINDOW launches in a normal app window. | 160 // LAUNCH_TYPE_WINDOW launches in a normal app window. |
162 ExtensionService* service = | 161 ExtensionService* service = |
163 extensions::ExtensionSystem::Get(profile)->extension_service(); | 162 extensions::ExtensionSystem::Get(profile)->extension_service(); |
164 extensions::LaunchType launch_type = extensions::GetLaunchType( | 163 extensions::LaunchType launch_type = extensions::GetLaunchType( |
165 service->extension_prefs(), extension); | 164 service->extension_prefs(), extension); |
166 if (launch_type == extensions::LAUNCH_TYPE_FULLSCREEN) | 165 if (launch_type == extensions::LAUNCH_TYPE_FULLSCREEN) |
167 return ui::SHOW_STATE_MAXIMIZED; | 166 return ui::SHOW_STATE_MAXIMIZED; |
168 else if (launch_type == extensions::LAUNCH_TYPE_WINDOW) | 167 else if (launch_type == extensions::LAUNCH_TYPE_WINDOW) |
169 return ui::SHOW_STATE_NORMAL; | 168 return ui::SHOW_STATE_NORMAL; |
170 #endif | 169 #endif |
171 | 170 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 apps::LaunchPlatformAppWithCommandLine( | 354 apps::LaunchPlatformAppWithCommandLine( |
356 profile, extension, params.command_line, params.current_directory); | 355 profile, extension, params.command_line, params.current_directory); |
357 return NULL; | 356 return NULL; |
358 } | 357 } |
359 | 358 |
360 // Record v1 app launch. Platform app launch is recorded when dispatching | 359 // Record v1 app launch. Platform app launch is recorded when dispatching |
361 // the onLaunched event. | 360 // the onLaunched event. |
362 prefs->SetLastLaunchTime(extension->id(), base::Time::Now()); | 361 prefs->SetLastLaunchTime(extension->id(), base::Time::Now()); |
363 | 362 |
364 switch (params.container) { | 363 switch (params.container) { |
365 case extensions::LAUNCH_NONE: { | 364 case extensions::LAUNCH_CONTAINER_NONE: { |
366 NOTREACHED(); | 365 NOTREACHED(); |
367 break; | 366 break; |
368 } | 367 } |
369 case extensions::LAUNCH_PANEL: | 368 case extensions::LAUNCH_CONTAINER_PANEL: |
370 case extensions::LAUNCH_WINDOW: | 369 case extensions::LAUNCH_CONTAINER_WINDOW: |
371 tab = OpenApplicationWindow(params); | 370 tab = OpenApplicationWindow(params); |
372 break; | 371 break; |
373 case extensions::LAUNCH_TAB: { | 372 case extensions::LAUNCH_CONTAINER_TAB: { |
374 tab = OpenApplicationTab(params); | 373 tab = OpenApplicationTab(params); |
375 break; | 374 break; |
376 } | 375 } |
377 default: | 376 default: |
378 NOTREACHED(); | 377 NOTREACHED(); |
379 break; | 378 break; |
380 } | 379 } |
381 return tab; | 380 return tab; |
382 } | 381 } |
383 | 382 |
(...skipping 10 matching lines...) Expand all Loading... |
394 desktop_type(chrome::GetActiveDesktop()), | 393 desktop_type(chrome::GetActiveDesktop()), |
395 override_url(), | 394 override_url(), |
396 override_bounds(), | 395 override_bounds(), |
397 command_line(NULL) {} | 396 command_line(NULL) {} |
398 | 397 |
399 AppLaunchParams::AppLaunchParams(Profile* profile, | 398 AppLaunchParams::AppLaunchParams(Profile* profile, |
400 const extensions::Extension* extension, | 399 const extensions::Extension* extension, |
401 WindowOpenDisposition disposition) | 400 WindowOpenDisposition disposition) |
402 : profile(profile), | 401 : profile(profile), |
403 extension(extension), | 402 extension(extension), |
404 container(extensions::LAUNCH_NONE), | 403 container(extensions::LAUNCH_CONTAINER_NONE), |
405 disposition(disposition), | 404 disposition(disposition), |
406 desktop_type(chrome::GetActiveDesktop()), | 405 desktop_type(chrome::GetActiveDesktop()), |
407 override_url(), | 406 override_url(), |
408 override_bounds(), | 407 override_bounds(), |
409 command_line(NULL) { | 408 command_line(NULL) { |
410 ExtensionService* service = | 409 ExtensionService* service = |
411 extensions::ExtensionSystem::Get(profile)->extension_service(); | 410 extensions::ExtensionSystem::Get(profile)->extension_service(); |
412 DCHECK(service); | 411 DCHECK(service); |
413 | 412 |
414 // Look up the app preference to find out the right launch container. Default | 413 // Look up the app preference to find out the right launch container. Default |
415 // is to launch as a regular tab. | 414 // is to launch as a regular tab. |
416 container = extensions::GetLaunchContainer( | 415 container = extensions::GetLaunchContainer( |
417 service->extension_prefs(), extension); | 416 service->extension_prefs(), extension); |
418 } | 417 } |
419 | 418 |
420 AppLaunchParams::AppLaunchParams(Profile* profile, | 419 AppLaunchParams::AppLaunchParams(Profile* profile, |
421 const extensions::Extension* extension, | 420 const extensions::Extension* extension, |
422 int event_flags, | 421 int event_flags, |
423 chrome::HostDesktopType desktop_type) | 422 chrome::HostDesktopType desktop_type) |
424 : profile(profile), | 423 : profile(profile), |
425 extension(extension), | 424 extension(extension), |
426 container(extensions::LAUNCH_NONE), | 425 container(extensions::LAUNCH_CONTAINER_NONE), |
427 disposition(ui::DispositionFromEventFlags(event_flags)), | 426 disposition(ui::DispositionFromEventFlags(event_flags)), |
428 desktop_type(desktop_type), | 427 desktop_type(desktop_type), |
429 override_url(), | 428 override_url(), |
430 override_bounds(), | 429 override_bounds(), |
431 command_line(NULL) { | 430 command_line(NULL) { |
432 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) { | 431 if (disposition == NEW_FOREGROUND_TAB || disposition == NEW_BACKGROUND_TAB) { |
433 container = extensions::LAUNCH_TAB; | 432 container = extensions::LAUNCH_CONTAINER_TAB; |
434 } else if (disposition == NEW_WINDOW) { | 433 } else if (disposition == NEW_WINDOW) { |
435 container = extensions::LAUNCH_WINDOW; | 434 container = extensions::LAUNCH_CONTAINER_WINDOW; |
436 } else { | 435 } else { |
437 ExtensionService* service = | 436 ExtensionService* service = |
438 extensions::ExtensionSystem::Get(profile)->extension_service(); | 437 extensions::ExtensionSystem::Get(profile)->extension_service(); |
439 DCHECK(service); | 438 DCHECK(service); |
440 | 439 |
441 // Look at preference to find the right launch container. If no preference | 440 // Look at preference to find the right launch container. If no preference |
442 // is set, launch as a regular tab. | 441 // is set, launch as a regular tab. |
443 container = extensions::GetLaunchContainer( | 442 container = extensions::GetLaunchContainer( |
444 service->extension_prefs(), extension); | 443 service->extension_prefs(), extension); |
445 disposition = NEW_FOREGROUND_TAB; | 444 disposition = NEW_FOREGROUND_TAB; |
(...skipping 19 matching lines...) Expand all Loading... |
465 | 464 |
466 OpenEnabledApplication(params); | 465 OpenEnabledApplication(params); |
467 } | 466 } |
468 | 467 |
469 WebContents* OpenAppShortcutWindow(Profile* profile, | 468 WebContents* OpenAppShortcutWindow(Profile* profile, |
470 const GURL& url, | 469 const GURL& url, |
471 const gfx::Rect& override_bounds) { | 470 const gfx::Rect& override_bounds) { |
472 AppLaunchParams launch_params( | 471 AppLaunchParams launch_params( |
473 profile, | 472 profile, |
474 NULL, // this is a URL app. No extension. | 473 NULL, // this is a URL app. No extension. |
475 extensions::LAUNCH_WINDOW, | 474 extensions::LAUNCH_CONTAINER_WINDOW, |
476 NEW_WINDOW); | 475 NEW_WINDOW); |
477 launch_params.override_url = url; | 476 launch_params.override_url = url; |
478 launch_params.override_bounds = override_bounds; | 477 launch_params.override_bounds = override_bounds; |
479 | 478 |
480 WebContents* tab = OpenApplicationWindow(launch_params); | 479 WebContents* tab = OpenApplicationWindow(launch_params); |
481 | 480 |
482 if (!tab) | 481 if (!tab) |
483 return NULL; | 482 return NULL; |
484 | 483 |
485 // Set UPDATE_SHORTCUT as the pending web app action. This action is picked | 484 // Set UPDATE_SHORTCUT as the pending web app action. This action is picked |
486 // up in LoadingStateChanged to schedule a GetApplicationInfo. And when | 485 // up in LoadingStateChanged to schedule a GetApplicationInfo. And when |
487 // the web app info is available, extensions::TabHelper notifies Browser via | 486 // the web app info is available, extensions::TabHelper notifies Browser via |
488 // OnDidGetApplicationInfo, which calls | 487 // OnDidGetApplicationInfo, which calls |
489 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as | 488 // web_app::UpdateShortcutForTabContents when it sees UPDATE_SHORTCUT as |
490 // pending web app action. | 489 // pending web app action. |
491 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( | 490 extensions::TabHelper::FromWebContents(tab)->set_pending_web_app_action( |
492 extensions::TabHelper::UPDATE_SHORTCUT); | 491 extensions::TabHelper::UPDATE_SHORTCUT); |
493 | 492 |
494 return tab; | 493 return tab; |
495 } | 494 } |
OLD | NEW |