| 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/web_applications/web_app.h" | 5 #include "chrome/browser/web_applications/web_app.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 bool ShouldCreateShortcutFor(web_app::ShortcutCreationReason reason, | 303 bool ShouldCreateShortcutFor(web_app::ShortcutCreationReason reason, |
| 304 Profile* profile, | 304 Profile* profile, |
| 305 const extensions::Extension* extension) { | 305 const extensions::Extension* extension) { |
| 306 // Shortcuts should never be created for component apps, or for apps that | 306 // Shortcuts should never be created for component apps, or for apps that |
| 307 // cannot be shown in the launcher. | 307 // cannot be shown in the launcher. |
| 308 if (extension->location() == extensions::Manifest::COMPONENT || | 308 if (extension->location() == extensions::Manifest::COMPONENT || |
| 309 !extensions::ui_util::CanDisplayInAppLauncher(extension, profile)) { | 309 !extensions::ui_util::CanDisplayInAppLauncher(extension, profile)) { |
| 310 return false; | 310 return false; |
| 311 } | 311 } |
| 312 | 312 |
| 313 // Otherwise, always create shortcuts for v2 packaged apps. | 313 // Always create shortcuts for v2 packaged apps. |
| 314 if (extension->is_platform_app()) | 314 if (extension->is_platform_app()) |
| 315 return true; | 315 return true; |
| 316 | 316 |
| 317 #if defined(OS_MACOSX) | 317 #if defined(OS_MACOSX) |
| 318 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 318 // A bookmark app installs itself as an extension, then automatically triggers |
| 319 switches::kDisableHostedAppShimCreation)) { | 319 // a shortcut request with SHORTCUT_CREATION_AUTOMATED. Allow this flow, but |
| 320 return extension->is_hosted_app(); | 320 // do not automatically create shortcuts for default-installed extensions, |
| 321 // until it is explicitly requested by the user. |
| 322 if (extension->was_installed_by_default() && |
| 323 reason == SHORTCUT_CREATION_AUTOMATED) |
| 324 return false; |
| 325 |
| 326 if (extension->from_bookmark()) |
| 327 return true; |
| 328 |
| 329 // Otherwise, don't create shortcuts for automated codepaths. |
| 330 if (reason == SHORTCUT_CREATION_AUTOMATED) |
| 331 return false; |
| 332 |
| 333 if (extension->is_hosted_app()) { |
| 334 return !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 335 switches::kDisableHostedAppShimCreation); |
| 321 } | 336 } |
| 322 | 337 |
| 338 // Only reached for "legacy" packaged apps. Default to false on Mac. |
| 323 return false; | 339 return false; |
| 324 #else | 340 #else |
| 325 // For other platforms, allow shortcut creation if it was explicitly | 341 // For other platforms, allow shortcut creation if it was explicitly |
| 326 // requested by the user (i.e. is not automatic). | 342 // requested by the user (i.e. is not automatic). |
| 327 return reason == SHORTCUT_CREATION_BY_USER; | 343 return reason == SHORTCUT_CREATION_BY_USER; |
| 328 #endif | 344 #endif |
| 329 } | 345 } |
| 330 | 346 |
| 331 base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path, | 347 base::FilePath GetWebAppDataDirectory(const base::FilePath& profile_path, |
| 332 const std::string& extension_id, | 348 const std::string& extension_id, |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 516 |
| 501 #if defined(OS_LINUX) | 517 #if defined(OS_LINUX) |
| 502 std::string GetWMClassFromAppName(std::string app_name) { | 518 std::string GetWMClassFromAppName(std::string app_name) { |
| 503 base::i18n::ReplaceIllegalCharactersInPath(&app_name, '_'); | 519 base::i18n::ReplaceIllegalCharactersInPath(&app_name, '_'); |
| 504 base::TrimString(app_name, "_", &app_name); | 520 base::TrimString(app_name, "_", &app_name); |
| 505 return app_name; | 521 return app_name; |
| 506 } | 522 } |
| 507 #endif | 523 #endif |
| 508 | 524 |
| 509 } // namespace web_app | 525 } // namespace web_app |
| OLD | NEW |