OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/bookmark_app_helper.h" | 5 #include "chrome/browser/extensions/bookmark_app_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cctype> | 9 #include <cctype> |
10 #include <string> | 10 #include <string> |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 return; | 689 return; |
690 } | 690 } |
691 | 691 |
692 Browser* browser = chrome::FindBrowserWithWebContents(contents_); | 692 Browser* browser = chrome::FindBrowserWithWebContents(contents_); |
693 if (!browser) { | 693 if (!browser) { |
694 // The browser can be null in tests. | 694 // The browser can be null in tests. |
695 callback_.Run(extension, web_app_info_); | 695 callback_.Run(extension, web_app_info_); |
696 return; | 696 return; |
697 } | 697 } |
698 | 698 |
| 699 #if !defined(USE_ASH) |
699 // Pin the app to the relevant launcher depending on the OS. | 700 // Pin the app to the relevant launcher depending on the OS. |
700 Profile* current_profile = profile_->GetOriginalProfile(); | 701 Profile* current_profile = profile_->GetOriginalProfile(); |
| 702 #endif // !defined(USE_ASH) |
701 | 703 |
702 // On Mac, shortcuts are automatically created for hosted apps when they are | 704 // On Mac, shortcuts are automatically created for hosted apps when they are |
703 // installed, so there is no need to create them again. | 705 // installed, so there is no need to create them again. |
704 #if !defined(OS_MACOSX) | 706 #if !defined(OS_MACOSX) |
705 chrome::HostDesktopType desktop = browser->host_desktop_type(); | 707 #if !defined(USE_ASH) |
706 if (desktop != chrome::HOST_DESKTOP_TYPE_ASH) { | 708 web_app::ShortcutLocations creation_locations; |
707 web_app::ShortcutLocations creation_locations; | |
708 #if defined(OS_LINUX) || defined(OS_WIN) | 709 #if defined(OS_LINUX) || defined(OS_WIN) |
709 creation_locations.on_desktop = true; | 710 creation_locations.on_desktop = true; |
710 #else | 711 #else |
711 creation_locations.on_desktop = false; | 712 creation_locations.on_desktop = false; |
712 #endif | 713 #endif |
713 creation_locations.applications_menu_location = | 714 creation_locations.applications_menu_location = |
714 web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS; | 715 web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS; |
715 creation_locations.in_quick_launch_bar = false; | 716 creation_locations.in_quick_launch_bar = false; |
716 web_app::CreateShortcuts(web_app::SHORTCUT_CREATION_BY_USER, | 717 web_app::CreateShortcuts(web_app::SHORTCUT_CREATION_BY_USER, |
717 creation_locations, current_profile, extension); | 718 creation_locations, current_profile, extension); |
718 #if defined(USE_ASH) | 719 #else |
719 } else { | 720 ChromeLauncherController::instance()->PinAppWithID(extension->id()); |
720 ChromeLauncherController::instance()->PinAppWithID(extension->id()); | 721 #endif // !defined(USE_ASH) |
721 #endif | |
722 } | |
723 #endif // !defined(OS_MACOSX) | 722 #endif // !defined(OS_MACOSX) |
724 | 723 |
725 #if defined(OS_MACOSX) | 724 #if defined(OS_MACOSX) |
726 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 725 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
727 switches::kDisableHostedAppShimCreation)) { | 726 switches::kDisableHostedAppShimCreation)) { |
728 web_app::RevealAppShimInFinderForApp(current_profile, extension); | 727 web_app::RevealAppShimInFinderForApp(current_profile, extension); |
729 } | 728 } |
730 #endif | 729 #endif |
731 | 730 |
732 callback_.Run(extension, web_app_info_); | 731 callback_.Run(extension, web_app_info_); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); | 796 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); |
798 } | 797 } |
799 | 798 |
800 bool IsValidBookmarkAppUrl(const GURL& url) { | 799 bool IsValidBookmarkAppUrl(const GURL& url) { |
801 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); | 800 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); |
802 origin_only_pattern.SetMatchAllURLs(true); | 801 origin_only_pattern.SetMatchAllURLs(true); |
803 return url.is_valid() && origin_only_pattern.MatchesURL(url); | 802 return url.is_valid() && origin_only_pattern.MatchesURL(url); |
804 } | 803 } |
805 | 804 |
806 } // namespace extensions | 805 } // namespace extensions |
OLD | NEW |