| 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 #import "chrome/browser/web_applications/web_app_mac.h" | 5 #import "chrome/browser/web_applications/web_app_mac.h" |
| 6 | 6 |
| 7 #import <Carbon/Carbon.h> | 7 #import <Carbon/Carbon.h> |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "grit/chromium_strings.h" | 37 #include "grit/chromium_strings.h" |
| 38 #include "grit/generated_resources.h" | 38 #include "grit/generated_resources.h" |
| 39 #import "skia/ext/skia_utils_mac.h" | 39 #import "skia/ext/skia_utils_mac.h" |
| 40 #include "third_party/skia/include/core/SkBitmap.h" | 40 #include "third_party/skia/include/core/SkBitmap.h" |
| 41 #include "third_party/skia/include/core/SkColor.h" | 41 #include "third_party/skia/include/core/SkColor.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
| 43 #import "ui/base/l10n/l10n_util_mac.h" | 43 #import "ui/base/l10n/l10n_util_mac.h" |
| 44 #include "ui/base/resource/resource_bundle.h" | 44 #include "ui/base/resource/resource_bundle.h" |
| 45 #include "ui/gfx/image/image_family.h" | 45 #include "ui/gfx/image/image_family.h" |
| 46 | 46 |
| 47 bool g_app_shims_allow_update_and_launch_in_tests = false; |
| 48 |
| 47 namespace { | 49 namespace { |
| 48 | 50 |
| 49 // Launch Services Key to run as an agent app, which doesn't launch in the dock. | 51 // Launch Services Key to run as an agent app, which doesn't launch in the dock. |
| 50 NSString* const kLSUIElement = @"LSUIElement"; | 52 NSString* const kLSUIElement = @"LSUIElement"; |
| 51 | 53 |
| 52 class ScopedCarbonHandle { | 54 class ScopedCarbonHandle { |
| 53 public: | 55 public: |
| 54 ScopedCarbonHandle(size_t initial_size) : handle_(NewHandle(initial_size)) { | 56 ScopedCarbonHandle(size_t initial_size) : handle_(NewHandle(initial_size)) { |
| 55 DCHECK(handle_); | 57 DCHECK(handle_); |
| 56 DCHECK_EQ(noErr, MemError()); | 58 DCHECK_EQ(noErr, MemError()); |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 inFileViewerRootedAtPath:nil]; | 849 inFileViewerRootedAtPath:nil]; |
| 848 } | 850 } |
| 849 | 851 |
| 850 base::FilePath GetAppInstallPath(const ShortcutInfo& shortcut_info) { | 852 base::FilePath GetAppInstallPath(const ShortcutInfo& shortcut_info) { |
| 851 WebAppShortcutCreator shortcut_creator( | 853 WebAppShortcutCreator shortcut_creator( |
| 852 base::FilePath(), shortcut_info, extensions::FileHandlersInfo()); | 854 base::FilePath(), shortcut_info, extensions::FileHandlersInfo()); |
| 853 return shortcut_creator.GetApplicationsShortcutPath(); | 855 return shortcut_creator.GetApplicationsShortcutPath(); |
| 854 } | 856 } |
| 855 | 857 |
| 856 void MaybeLaunchShortcut(const ShortcutInfo& shortcut_info) { | 858 void MaybeLaunchShortcut(const ShortcutInfo& shortcut_info) { |
| 857 if (AppShimsDisabledForTest()) | 859 if (AppShimsDisabledForTest() && |
| 860 !g_app_shims_allow_update_and_launch_in_tests) { |
| 858 return; | 861 return; |
| 862 } |
| 859 | 863 |
| 860 content::BrowserThread::PostTask( | 864 content::BrowserThread::PostTask( |
| 861 content::BrowserThread::FILE, FROM_HERE, | 865 content::BrowserThread::FILE, FROM_HERE, |
| 862 base::Bind(&LaunchShimOnFileThread, shortcut_info)); | 866 base::Bind(&LaunchShimOnFileThread, shortcut_info)); |
| 863 } | 867 } |
| 864 | 868 |
| 865 // Called when the app's ShortcutInfo (with icon) is loaded when creating app | 869 // Called when the app's ShortcutInfo (with icon) is loaded when creating app |
| 866 // shortcuts. | 870 // shortcuts. |
| 867 void CreateAppShortcutInfoLoaded( | 871 void CreateAppShortcutInfoLoaded( |
| 868 Profile* profile, | 872 Profile* profile, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 app_data_path, shortcut_info, extensions::FileHandlersInfo()); | 943 app_data_path, shortcut_info, extensions::FileHandlersInfo()); |
| 940 shortcut_creator.DeleteShortcuts(); | 944 shortcut_creator.DeleteShortcuts(); |
| 941 } | 945 } |
| 942 | 946 |
| 943 void UpdatePlatformShortcuts( | 947 void UpdatePlatformShortcuts( |
| 944 const base::FilePath& app_data_path, | 948 const base::FilePath& app_data_path, |
| 945 const base::string16& old_app_title, | 949 const base::string16& old_app_title, |
| 946 const ShortcutInfo& shortcut_info, | 950 const ShortcutInfo& shortcut_info, |
| 947 const extensions::FileHandlersInfo& file_handlers_info) { | 951 const extensions::FileHandlersInfo& file_handlers_info) { |
| 948 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 952 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
| 949 if (AppShimsDisabledForTest()) | 953 if (AppShimsDisabledForTest() && |
| 954 !g_app_shims_allow_update_and_launch_in_tests) { |
| 950 return; | 955 return; |
| 956 } |
| 951 | 957 |
| 952 WebAppShortcutCreator shortcut_creator( | 958 WebAppShortcutCreator shortcut_creator( |
| 953 app_data_path, shortcut_info, file_handlers_info); | 959 app_data_path, shortcut_info, file_handlers_info); |
| 954 shortcut_creator.UpdateShortcuts(); | 960 shortcut_creator.UpdateShortcuts(); |
| 955 } | 961 } |
| 956 | 962 |
| 957 void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) { | 963 void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) { |
| 958 const std::string profile_base_name = profile_path.BaseName().value(); | 964 const std::string profile_base_name = profile_path.BaseName().value(); |
| 959 std::vector<base::FilePath> bundles = GetAllAppBundlesInPath( | 965 std::vector<base::FilePath> bundles = GetAllAppBundlesInPath( |
| 960 profile_path.Append(chrome::kWebAppDirname), profile_base_name); | 966 profile_path.Append(chrome::kWebAppDirname), profile_base_name); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 983 web_app::UpdateShortcutInfoAndIconForApp( | 989 web_app::UpdateShortcutInfoAndIconForApp( |
| 984 app, | 990 app, |
| 985 profile, | 991 profile, |
| 986 base::Bind(&web_app::CreateAppShortcutInfoLoaded, | 992 base::Bind(&web_app::CreateAppShortcutInfoLoaded, |
| 987 profile, | 993 profile, |
| 988 app, | 994 app, |
| 989 close_callback)); | 995 close_callback)); |
| 990 } | 996 } |
| 991 | 997 |
| 992 } // namespace chrome | 998 } // namespace chrome |
| OLD | NEW |