| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 using content::WebContents; | 51 using content::WebContents; |
| 52 using extensions::Extension; | 52 using extensions::Extension; |
| 53 using extensions::ExtensionPrefs; | 53 using extensions::ExtensionPrefs; |
| 54 using extensions::ExtensionRegistry; | 54 using extensions::ExtensionRegistry; |
| 55 | 55 |
| 56 namespace { | 56 namespace { |
| 57 | 57 |
| 58 // Shows the app list for |desktop_type| and returns the app list's window. | 58 // Shows the app list for |desktop_type| and returns the app list's window. |
| 59 gfx::NativeWindow ShowAppListAndGetNativeWindow( | 59 gfx::NativeWindow ShowAppListAndGetNativeWindow() { |
| 60 chrome::HostDesktopType desktop_type) { | 60 AppListService* app_list_service = |
| 61 AppListService* app_list_service = AppListService::Get(desktop_type); | 61 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 62 app_list_service->Show(); | 62 app_list_service->Show(); |
| 63 return app_list_service->GetAppListWindow(); | 63 return app_list_service->GetAppListWindow(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 // Attempts to launch an app, prompting the user to enable it if necessary. If | 66 // Attempts to launch an app, prompting the user to enable it if necessary. If |
| 67 // a prompt is required it will be shown inside the window returned by | 67 // a prompt is required it will be shown inside the window returned by |
| 68 // |parent_window_getter|. | 68 // |parent_window_getter|. |
| 69 // This class manages its own lifetime. | 69 // This class manages its own lifetime. |
| 70 class EnableViaDialogFlow : public ExtensionEnableFlowDelegate { | 70 class EnableViaDialogFlow : public ExtensionEnableFlowDelegate { |
| 71 public: | 71 public: |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 Profile* profile = params.profile; | 376 Profile* profile = params.profile; |
| 377 | 377 |
| 378 ExtensionService* service = | 378 ExtensionService* service = |
| 379 extensions::ExtensionSystem::Get(profile)->extension_service(); | 379 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 380 if (!service->IsExtensionEnabled(extension->id()) || | 380 if (!service->IsExtensionEnabled(extension->id()) || |
| 381 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( | 381 extensions::ExtensionRegistry::Get(profile)->GetExtensionById( |
| 382 extension->id(), extensions::ExtensionRegistry::TERMINATED)) { | 382 extension->id(), extensions::ExtensionRegistry::TERMINATED)) { |
| 383 base::Callback<gfx::NativeWindow(void)> dialog_parent_window_getter; | 383 base::Callback<gfx::NativeWindow(void)> dialog_parent_window_getter; |
| 384 // TODO(pkotwicz): Figure out which window should be used as the parent for | 384 // TODO(pkotwicz): Figure out which window should be used as the parent for |
| 385 // the "enable application" dialog in Athena. | 385 // the "enable application" dialog in Athena. |
| 386 dialog_parent_window_getter = | 386 dialog_parent_window_getter = base::Bind(&ShowAppListAndGetNativeWindow); |
| 387 base::Bind(&ShowAppListAndGetNativeWindow, params.desktop_type); | |
| 388 (new EnableViaDialogFlow( | 387 (new EnableViaDialogFlow( |
| 389 service, profile, extension->id(), dialog_parent_window_getter, | 388 service, profile, extension->id(), dialog_parent_window_getter, |
| 390 base::Bind(base::IgnoreResult(OpenEnabledApplication), params)))->Run(); | 389 base::Bind(base::IgnoreResult(OpenEnabledApplication), params)))->Run(); |
| 391 return; | 390 return; |
| 392 } | 391 } |
| 393 | 392 |
| 394 OpenEnabledApplication(params); | 393 OpenEnabledApplication(params); |
| 395 } | 394 } |
| 396 | 395 |
| 397 WebContents* OpenAppShortcutWindow(Profile* profile, | 396 WebContents* OpenAppShortcutWindow(Profile* profile, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 410 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); | 409 extensions::TabHelper::FromWebContents(tab)->UpdateShortcutOnLoadComplete(); |
| 411 | 410 |
| 412 return tab; | 411 return tab; |
| 413 } | 412 } |
| 414 | 413 |
| 415 bool CanLaunchViaEvent(const extensions::Extension* extension) { | 414 bool CanLaunchViaEvent(const extensions::Extension* extension) { |
| 416 const extensions::Feature* feature = | 415 const extensions::Feature* feature = |
| 417 extensions::FeatureProvider::GetAPIFeature("app.runtime"); | 416 extensions::FeatureProvider::GetAPIFeature("app.runtime"); |
| 418 return feature->IsAvailableToExtension(extension).is_available(); | 417 return feature->IsAvailableToExtension(extension).is_available(); |
| 419 } | 418 } |
| OLD | NEW |