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 <cctype> | 7 #include <cctype> |
8 | 8 |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 web_app::RevealAppShimInFinderForApp(current_profile, extension); | 724 web_app::RevealAppShimInFinderForApp(current_profile, extension); |
725 } | 725 } |
726 #endif | 726 #endif |
727 | 727 |
728 callback_.Run(extension, web_app_info_); | 728 callback_.Run(extension, web_app_info_); |
729 } | 729 } |
730 | 730 |
731 void BookmarkAppHelper::Observe(int type, | 731 void BookmarkAppHelper::Observe(int type, |
732 const content::NotificationSource& source, | 732 const content::NotificationSource& source, |
733 const content::NotificationDetails& details) { | 733 const content::NotificationDetails& details) { |
| 734 // TODO(dominickn): bookmark app creation fails when extensions cannot be |
| 735 // created (e.g. due to management policies). Add to shelf visibility should |
| 736 // be gated on whether extensions can be created - see crbug.com/545541. |
734 switch (type) { | 737 switch (type) { |
735 case extensions::NOTIFICATION_CRX_INSTALLER_DONE: { | 738 case extensions::NOTIFICATION_CRX_INSTALLER_DONE: { |
736 const Extension* extension = | 739 const Extension* extension = |
737 content::Details<const Extension>(details).ptr(); | 740 content::Details<const Extension>(details).ptr(); |
738 DCHECK(extension); | 741 if (extension) { |
739 DCHECK_EQ(AppLaunchInfo::GetLaunchWebURL(extension), | 742 DCHECK_EQ(AppLaunchInfo::GetLaunchWebURL(extension), |
740 web_app_info_.app_url); | 743 web_app_info_.app_url); |
741 FinishInstallation(extension); | 744 FinishInstallation(extension); |
| 745 } else { |
| 746 callback_.Run(nullptr, web_app_info_); |
| 747 } |
742 break; | 748 break; |
743 } | 749 } |
744 case extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR: | 750 case extensions::NOTIFICATION_EXTENSION_INSTALL_ERROR: |
745 callback_.Run(nullptr, web_app_info_); | 751 callback_.Run(nullptr, web_app_info_); |
746 break; | 752 break; |
747 default: | 753 default: |
748 NOTREACHED(); | 754 NOTREACHED(); |
749 break; | 755 break; |
750 } | 756 } |
751 } | 757 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); | 796 extension, info_list, base::Bind(&OnIconsLoaded, web_app_info, callback)); |
791 } | 797 } |
792 | 798 |
793 bool IsValidBookmarkAppUrl(const GURL& url) { | 799 bool IsValidBookmarkAppUrl(const GURL& url) { |
794 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); | 800 URLPattern origin_only_pattern(Extension::kValidBookmarkAppSchemes); |
795 origin_only_pattern.SetMatchAllURLs(true); | 801 origin_only_pattern.SetMatchAllURLs(true); |
796 return url.is_valid() && origin_only_pattern.MatchesURL(url); | 802 return url.is_valid() && origin_only_pattern.MatchesURL(url); |
797 } | 803 } |
798 | 804 |
799 } // namespace extensions | 805 } // namespace extensions |
OLD | NEW |