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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 // Version of the app list shortcut version installed. | 80 // Version of the app list shortcut version installed. |
81 const int kShortcutVersion = 2; | 81 const int kShortcutVersion = 2; |
82 | 82 |
83 // Duration of show and hide animations. | 83 // Duration of show and hide animations. |
84 const NSTimeInterval kAnimationDuration = 0.2; | 84 const NSTimeInterval kAnimationDuration = 0.2; |
85 | 85 |
86 // Distance towards the screen edge that the app list moves from when showing. | 86 // Distance towards the screen edge that the app list moves from when showing. |
87 const CGFloat kDistanceMovedOnShow = 20; | 87 const CGFloat kDistanceMovedOnShow = 20; |
88 | 88 |
89 web_app::ShortcutInfo GetAppListShortcutInfo( | 89 scoped_ptr<web_app::ShortcutInfo> GetAppListShortcutInfo( |
90 const base::FilePath& profile_path) { | 90 const base::FilePath& profile_path) { |
91 web_app::ShortcutInfo shortcut_info; | 91 scoped_ptr<web_app::ShortcutInfo> shortcut_info(new web_app::ShortcutInfo); |
92 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 92 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
93 if (channel == chrome::VersionInfo::CHANNEL_CANARY) { | 93 if (channel == chrome::VersionInfo::CHANNEL_CANARY) { |
94 shortcut_info.title = | 94 shortcut_info->title = |
95 l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME_CANARY); | 95 l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME_CANARY); |
96 } else { | 96 } else { |
97 shortcut_info.title = l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME); | 97 shortcut_info->title = |
| 98 l10n_util::GetStringUTF16(IDS_APP_LIST_SHORTCUT_NAME); |
98 } | 99 } |
99 | 100 |
100 shortcut_info.extension_id = app_mode::kAppListModeId; | 101 shortcut_info->extension_id = app_mode::kAppListModeId; |
101 shortcut_info.description = shortcut_info.title; | 102 shortcut_info->description = shortcut_info->title; |
102 shortcut_info.profile_path = profile_path; | 103 shortcut_info->profile_path = profile_path; |
103 | 104 |
104 return shortcut_info; | 105 return shortcut_info; |
105 } | 106 } |
106 | 107 |
107 void CreateAppListShim(const base::FilePath& profile_path) { | 108 void CreateAppListShim(const base::FilePath& profile_path) { |
108 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 109 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
109 WebApplicationInfo web_app_info; | 110 WebApplicationInfo web_app_info; |
110 web_app::ShortcutInfo shortcut_info = | 111 scoped_ptr<web_app::ShortcutInfo> shortcut_info = |
111 GetAppListShortcutInfo(profile_path); | 112 GetAppListShortcutInfo(profile_path); |
112 | 113 |
113 ResourceBundle& resource_bundle = ResourceBundle::GetSharedInstance(); | 114 ResourceBundle& resource_bundle = ResourceBundle::GetSharedInstance(); |
114 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 115 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
115 if (channel == chrome::VersionInfo::CHANNEL_CANARY) { | 116 if (channel == chrome::VersionInfo::CHANNEL_CANARY) { |
116 #if defined(GOOGLE_CHROME_BUILD) | 117 #if defined(GOOGLE_CHROME_BUILD) |
117 shortcut_info.favicon.Add( | 118 shortcut_info->favicon.Add( |
118 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_16)); | 119 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_16)); |
119 shortcut_info.favicon.Add( | 120 shortcut_info->favicon.Add( |
120 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_32)); | 121 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_32)); |
121 shortcut_info.favicon.Add( | 122 shortcut_info->favicon.Add( |
122 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_128)); | 123 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_128)); |
123 shortcut_info.favicon.Add( | 124 shortcut_info->favicon.Add( |
124 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_256)); | 125 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_CANARY_256)); |
125 #else | 126 #else |
126 NOTREACHED(); | 127 NOTREACHED(); |
127 #endif | 128 #endif |
128 } else { | 129 } else { |
129 shortcut_info.favicon.Add( | 130 shortcut_info->favicon.Add( |
130 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_16)); | 131 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_16)); |
131 shortcut_info.favicon.Add( | 132 shortcut_info->favicon.Add( |
132 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_32)); | 133 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_32)); |
133 shortcut_info.favicon.Add( | 134 shortcut_info->favicon.Add( |
134 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_128)); | 135 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_128)); |
135 shortcut_info.favicon.Add( | 136 shortcut_info->favicon.Add( |
136 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_256)); | 137 *resource_bundle.GetImageSkiaNamed(IDR_APP_LIST_256)); |
137 } | 138 } |
138 | 139 |
139 web_app::ShortcutLocations shortcut_locations; | 140 web_app::ShortcutLocations shortcut_locations; |
140 PrefService* local_state = g_browser_process->local_state(); | 141 PrefService* local_state = g_browser_process->local_state(); |
141 int installed_version = | 142 int installed_version = |
142 local_state->GetInteger(prefs::kAppLauncherShortcutVersion); | 143 local_state->GetInteger(prefs::kAppLauncherShortcutVersion); |
143 | 144 |
144 // 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 |
145 // 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 |
146 // 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 |
147 // 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. |
148 if (installed_version == 0) | 149 if (installed_version == 0) |
149 shortcut_locations.in_quick_launch_bar = true; | 150 shortcut_locations.in_quick_launch_bar = true; |
150 | 151 |
151 web_app::CreateNonAppShortcut(shortcut_locations, shortcut_info); | 152 web_app::CreateNonAppShortcut(shortcut_locations, shortcut_info.Pass()); |
152 | 153 |
153 local_state->SetInteger(prefs::kAppLauncherShortcutVersion, | 154 local_state->SetInteger(prefs::kAppLauncherShortcutVersion, |
154 kShortcutVersion); | 155 kShortcutVersion); |
155 } | 156 } |
156 | 157 |
157 NSRunningApplication* ActiveApplicationNotChrome() { | 158 NSRunningApplication* ActiveApplicationNotChrome() { |
158 NSArray* applications = [[NSWorkspace sharedWorkspace] runningApplications]; | 159 NSArray* applications = [[NSWorkspace sharedWorkspace] runningApplications]; |
159 for (NSRunningApplication* application in applications) { | 160 for (NSRunningApplication* application in applications) { |
160 if (![application isActive]) | 161 if (![application isActive]) |
161 continue; | 162 continue; |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 | 573 |
573 - (void)animationDidEnd:(NSAnimation*)animation { | 574 - (void)animationDidEnd:(NSAnimation*)animation { |
574 content::BrowserThread::PostTask( | 575 content::BrowserThread::PostTask( |
575 content::BrowserThread::UI, | 576 content::BrowserThread::UI, |
576 FROM_HERE, | 577 FROM_HERE, |
577 base::Bind(&AppListServiceMac::WindowAnimationDidEnd, | 578 base::Bind(&AppListServiceMac::WindowAnimationDidEnd, |
578 base::Unretained(GetActiveInstance()))); | 579 base::Unretained(GetActiveInstance()))); |
579 } | 580 } |
580 | 581 |
581 @end | 582 @end |
OLD | NEW |