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 "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 // Version of the app list shortcut version installed. | 82 // Version of the app list shortcut version installed. |
83 const int kShortcutVersion = 2; | 83 const int kShortcutVersion = 2; |
84 | 84 |
85 // Duration of show and hide animations. | 85 // Duration of show and hide animations. |
86 const NSTimeInterval kAnimationDuration = 0.2; | 86 const NSTimeInterval kAnimationDuration = 0.2; |
87 | 87 |
88 // Distance towards the screen edge that the app list moves from when showing. | 88 // Distance towards the screen edge that the app list moves from when showing. |
89 const CGFloat kDistanceMovedOnShow = 20; | 89 const CGFloat kDistanceMovedOnShow = 20; |
90 | 90 |
91 web_app::ShortcutInfo GetAppListShortcutInfo( | 91 scoped_ptr<web_app::ShortcutInfo> GetAppListShortcutInfo( |
92 const base::FilePath& profile_path) { | 92 const base::FilePath& profile_path) { |
93 web_app::ShortcutInfo shortcut_info; | 93 scoped_ptr<web_app::ShortcutInfo> shortcut_info(new web_app::ShortcutInfo); |
94 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 94 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
95 if (channel == chrome::VersionInfo::CHANNEL_CANARY) { | 95 if (channel == chrome::VersionInfo::CHANNEL_CANARY) { |
96 shortcut_info.title = | 96 shortcut_info->title = |
97 l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME_CANARY); | 97 l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME_CANARY); |
98 } else { | 98 } else { |
99 shortcut_info.title = l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME); | 99 shortcut_info->title = |
| 100 l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME); |
100 } | 101 } |
101 | 102 |
102 shortcut_info.extension_id = app_mode::kAppListModeId; | 103 shortcut_info->extension_id = app_mode::kAppListModeId; |
103 shortcut_info.description = shortcut_info.title; | 104 shortcut_info->description = shortcut_info->title; |
104 shortcut_info.profile_path = profile_path; | 105 shortcut_info->profile_path = profile_path; |
105 | 106 |
106 return shortcut_info; | 107 return shortcut_info; |
107 } | 108 } |
108 | 109 |
109 void CreateAppListShim(const base::FilePath& profile_path) { | 110 void CreateAppListShim(const base::FilePath& profile_path) { |
110 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 111 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
111 WebApplicationInfo web_app_info; | 112 WebApplicationInfo web_app_info; |
112 web_app::ShortcutInfo shortcut_info = | 113 scoped_ptr<web_app::ShortcutInfo> shortcut_info = |
113 GetAppListShortcutInfo(profile_path); | 114 GetAppListShortcutInfo(profile_path); |
114 | 115 |
115 ResourceBundle& resource_bundle = ResourceBundle::GetSharedInstance(); | 116 ResourceBundle& resource_bundle = ResourceBundle::GetSharedInstance(); |
116 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 117 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
117 if (channel == chrome::VersionInfo::CHANNEL_CANARY) { | 118 if (channel == chrome::VersionInfo::CHANNEL_CANARY) { |
118 #if defined(GOOGLE_CHROME_BUILD) | 119 #if defined(GOOGLE_CHROME_BUILD) |
119 shortcut_info.favicon.Add( | 120 shortcut_info->favicon.Add( |
120 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_16)); | 121 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_16)); |
121 shortcut_info.favicon.Add( | 122 shortcut_info->favicon.Add( |
122 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_32)); | 123 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_32)); |
123 shortcut_info.favicon.Add( | 124 shortcut_info->favicon.Add( |
124 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_128)); | 125 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_128)); |
125 shortcut_info.favicon.Add( | 126 shortcut_info->favicon.Add( |
126 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_256)); | 127 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_256)); |
127 #else | 128 #else |
128 NOTREACHED(); | 129 NOTREACHED(); |
129 #endif | 130 #endif |
130 } else { | 131 } else { |
131 shortcut_info.favicon.Add( | 132 shortcut_info->favicon.Add( |
132 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_16)); | 133 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_16)); |
133 shortcut_info.favicon.Add( | 134 shortcut_info->favicon.Add( |
134 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_32)); | 135 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_32)); |
135 shortcut_info.favicon.Add( | 136 shortcut_info->favicon.Add( |
136 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_128)); | 137 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_128)); |
137 shortcut_info.favicon.Add( | 138 shortcut_info->favicon.Add( |
138 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_256)); | 139 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_256)); |
139 } | 140 } |
140 | 141 |
141 web_app::ShortcutLocations shortcut_locations; | 142 web_app::ShortcutLocations shortcut_locations; |
142 PrefService* local_state = g_browser_process->local_state(); | 143 PrefService* local_state = g_browser_process->local_state(); |
143 int installed_version = | 144 int installed_version = |
144 local_state->GetInteger(prefs::kAppLauncherShortcutVersion); | 145 local_state->GetInteger(prefs::kAppLauncherShortcutVersion); |
145 | 146 |
146 // If this is a first-time install, add a dock icon. Otherwise just update | 147 // If this is a first-time install, add a dock icon. Otherwise just update |
147 // the target, and wait for OSX to refresh its icon caches. This might not | 148 // the target, and wait for OSX to refresh its icon caches. This might not |
148 // occur until a reboot, but OSX does not offer a nicer way. Deleting cache | 149 // occur until a reboot, but OSX does not offer a nicer way. Deleting cache |
149 // files on disk and killing processes can easily result in icon corruption. | 150 // files on disk and killing processes can easily result in icon corruption. |
150 if (installed_version == 0) | 151 if (installed_version == 0) |
151 shortcut_locations.in_quick_launch_bar = true; | 152 shortcut_locations.in_quick_launch_bar = true; |
152 | 153 |
153 web_app::CreateNonAppShortcut(shortcut_locations, shortcut_info); | 154 web_app::CreateNonAppShortcut(shortcut_locations, shortcut_info.Pass()); |
154 | 155 |
155 local_state->SetInteger(prefs::kAppLauncherShortcutVersion, | 156 local_state->SetInteger(prefs::kAppLauncherShortcutVersion, |
156 kShortcutVersion); | 157 kShortcutVersion); |
157 } | 158 } |
158 | 159 |
159 NSRunningApplication* ActiveApplicationNotChrome() { | 160 NSRunningApplication* ActiveApplicationNotChrome() { |
160 NSArray* applications = [[NSWorkspace sharedWorkspace] runningApplications]; | 161 NSArray* applications = [[NSWorkspace sharedWorkspace] runningApplications]; |
161 for (NSRunningApplication* application in applications) { | 162 for (NSRunningApplication* application in applications) { |
162 if (![application isActive]) | 163 if (![application isActive]) |
163 continue; | 164 continue; |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 | 615 |
615 - (void)animationDidEnd:(NSAnimation*)animation { | 616 - (void)animationDidEnd:(NSAnimation*)animation { |
616 content::BrowserThread::PostTask( | 617 content::BrowserThread::PostTask( |
617 content::BrowserThread::UI, | 618 content::BrowserThread::UI, |
618 FROM_HERE, | 619 FROM_HERE, |
619 base::Bind(&AppListServiceMac::WindowAnimationDidEnd, | 620 base::Bind(&AppListServiceMac::WindowAnimationDidEnd, |
620 base::Unretained(AppListServiceMac::GetInstance()))); | 621 base::Unretained(AppListServiceMac::GetInstance()))); |
621 } | 622 } |
622 | 623 |
623 @end | 624 @end |
OLD | NEW |