| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/app_list/app_list_service_mac.h" | 5 #import "chrome/browser/ui/app_list/app_list_service_mac.h" |
| 6 | 6 |
| 7 #include <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "apps/app_shim/app_shim_mac.h" | 10 #include "apps/app_shim/app_shim_mac.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 // Version of the app list shortcut version installed. | 81 // Version of the app list shortcut version installed. |
| 82 const int kShortcutVersion = 1; | 82 const int kShortcutVersion = 1; |
| 83 | 83 |
| 84 // Duration of show and hide animations. | 84 // Duration of show and hide animations. |
| 85 const NSTimeInterval kAnimationDuration = 0.2; | 85 const NSTimeInterval kAnimationDuration = 0.2; |
| 86 | 86 |
| 87 // Distance towards the screen edge that the app list moves from when showing. | 87 // Distance towards the screen edge that the app list moves from when showing. |
| 88 const CGFloat kDistanceMovedOnShow = 20; | 88 const CGFloat kDistanceMovedOnShow = 20; |
| 89 | 89 |
| 90 ShellIntegration::ShortcutInfo GetAppListShortcutInfo( | 90 web_app::ShortcutInfo GetAppListShortcutInfo( |
| 91 const base::FilePath& profile_path) { | 91 const base::FilePath& profile_path) { |
| 92 ShellIntegration::ShortcutInfo shortcut_info; | 92 web_app::ShortcutInfo shortcut_info; |
| 93 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 93 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 94 if (channel == chrome::VersionInfo::CHANNEL_CANARY) { | 94 if (channel == chrome::VersionInfo::CHANNEL_CANARY) { |
| 95 shortcut_info.title = | 95 shortcut_info.title = |
| 96 l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME_CANARY); | 96 l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME_CANARY); |
| 97 } else { | 97 } else { |
| 98 shortcut_info.title = l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME); | 98 shortcut_info.title = l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME); |
| 99 } | 99 } |
| 100 | 100 |
| 101 shortcut_info.extension_id = app_mode::kAppListModeId; | 101 shortcut_info.extension_id = app_mode::kAppListModeId; |
| 102 shortcut_info.description = shortcut_info.title; | 102 shortcut_info.description = shortcut_info.title; |
| 103 shortcut_info.profile_path = profile_path; | 103 shortcut_info.profile_path = profile_path; |
| 104 | 104 |
| 105 return shortcut_info; | 105 return shortcut_info; |
| 106 } | 106 } |
| 107 | 107 |
| 108 void CreateAppListShim(const base::FilePath& profile_path) { | 108 void CreateAppListShim(const base::FilePath& profile_path) { |
| 109 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 109 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 110 WebApplicationInfo web_app_info; | 110 WebApplicationInfo web_app_info; |
| 111 ShellIntegration::ShortcutInfo shortcut_info = | 111 web_app::ShortcutInfo shortcut_info = |
| 112 GetAppListShortcutInfo(profile_path); | 112 GetAppListShortcutInfo(profile_path); |
| 113 | 113 |
| 114 ResourceBundle& resource_bundle = ResourceBundle::GetSharedInstance(); | 114 ResourceBundle& resource_bundle = ResourceBundle::GetSharedInstance(); |
| 115 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 115 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 116 if (channel == chrome::VersionInfo::CHANNEL_CANARY) { | 116 if (channel == chrome::VersionInfo::CHANNEL_CANARY) { |
| 117 #if defined(GOOGLE_CHROME_BUILD) | 117 #if defined(GOOGLE_CHROME_BUILD) |
| 118 shortcut_info.favicon.Add( | 118 shortcut_info.favicon.Add( |
| 119 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_16)); | 119 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_16)); |
| 120 shortcut_info.favicon.Add( | 120 shortcut_info.favicon.Add( |
| 121 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_32)); | 121 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_32)); |
| 122 shortcut_info.favicon.Add( | 122 shortcut_info.favicon.Add( |
| 123 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_128)); | 123 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_128)); |
| 124 shortcut_info.favicon.Add( | 124 shortcut_info.favicon.Add( |
| 125 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_256)); | 125 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_256)); |
| 126 #else | 126 #else |
| 127 NOTREACHED(); | 127 NOTREACHED(); |
| 128 #endif | 128 #endif |
| 129 } else { | 129 } else { |
| 130 shortcut_info.favicon.Add( | 130 shortcut_info.favicon.Add( |
| 131 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_16)); | 131 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_16)); |
| 132 shortcut_info.favicon.Add( | 132 shortcut_info.favicon.Add( |
| 133 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_32)); | 133 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_32)); |
| 134 shortcut_info.favicon.Add( | 134 shortcut_info.favicon.Add( |
| 135 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_128)); | 135 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_128)); |
| 136 shortcut_info.favicon.Add( | 136 shortcut_info.favicon.Add( |
| 137 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_256)); | 137 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_256)); |
| 138 } | 138 } |
| 139 | 139 |
| 140 ShellIntegration::ShortcutLocations shortcut_locations; | 140 web_app::ShortcutLocations shortcut_locations; |
| 141 PrefService* local_state = g_browser_process->local_state(); | 141 PrefService* local_state = g_browser_process->local_state(); |
| 142 int installed_version = | 142 int installed_version = |
| 143 local_state->GetInteger(prefs::kAppLauncherShortcutVersion); | 143 local_state->GetInteger(prefs::kAppLauncherShortcutVersion); |
| 144 | 144 |
| 145 // If this is a first-time install, add a dock icon. Otherwise just update | 145 // If this is a first-time install, add a dock icon. Otherwise just update |
| 146 // the target, and wait for OSX to refresh its icon caches. This might not | 146 // the target, and wait for OSX to refresh its icon caches. This might not |
| 147 // occur until a reboot, but OSX does not offer a nicer way. Deleting cache | 147 // occur until a reboot, but OSX does not offer a nicer way. Deleting cache |
| 148 // files on disk and killing processes can easily result in icon corruption. | 148 // files on disk and killing processes can easily result in icon corruption. |
| 149 if (installed_version == 0) | 149 if (installed_version == 0) |
| 150 shortcut_locations.in_quick_launch_bar = true; | 150 shortcut_locations.in_quick_launch_bar = true; |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 | 595 |
| 596 - (void)animationDidEnd:(NSAnimation*)animation { | 596 - (void)animationDidEnd:(NSAnimation*)animation { |
| 597 content::BrowserThread::PostTask( | 597 content::BrowserThread::PostTask( |
| 598 content::BrowserThread::UI, | 598 content::BrowserThread::UI, |
| 599 FROM_HERE, | 599 FROM_HERE, |
| 600 base::Bind(&AppListServiceMac::WindowAnimationDidEnd, | 600 base::Bind(&AppListServiceMac::WindowAnimationDidEnd, |
| 601 base::Unretained(AppListServiceMac::GetInstance()))); | 601 base::Unretained(AppListServiceMac::GetInstance()))); |
| 602 } | 602 } |
| 603 | 603 |
| 604 @end | 604 @end |
| OLD | NEW |