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 #include "apps/app_shim/app_shim_handler_mac.h" | 5 #include "apps/app_shim/app_shim_handler_mac.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/memory/scoped_nsobject.h" | 10 #include "base/memory/scoped_nsobject.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 // TODO(tapted): Create a dock icon using chrome/browser/mac/dock.h . | 134 // TODO(tapted): Create a dock icon using chrome/browser/mac/dock.h . |
135 web_app::CreateShortcuts(shortcut_info, | 135 web_app::CreateShortcuts(shortcut_info, |
136 ShellIntegration::ShortcutLocations()); | 136 ShellIntegration::ShortcutLocations()); |
137 } | 137 } |
138 | 138 |
139 // Check that there is an app list shim. If enabling and there is not, make one. | 139 // Check that there is an app list shim. If enabling and there is not, make one. |
140 // If disabling with --enable-app-list-shim=0, and there is one, delete it. | 140 // If disabling with --enable-app-list-shim=0, and there is one, delete it. |
141 void CheckAppListShimOnFileThread(const base::FilePath& profile_path) { | 141 void CheckAppListShimOnFileThread(const base::FilePath& profile_path) { |
142 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 142 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); |
143 const bool enable = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 143 const bool enable = |
144 switches::kEnableAppListShim).c_str()[0] != '0'; | 144 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAppListShim); |
145 base::FilePath install_path = web_app::GetAppInstallPath( | 145 base::FilePath install_path = web_app::GetAppInstallPath( |
146 GetAppListShortcutInfo(profile_path)); | 146 GetAppListShortcutInfo(profile_path)); |
147 if (enable == file_util::PathExists(install_path)) | 147 if (enable == file_util::PathExists(install_path)) |
148 return; | 148 return; |
149 | 149 |
150 if (enable) { | 150 if (enable) { |
151 content::BrowserThread::PostTask( | 151 content::BrowserThread::PostTask( |
152 content::BrowserThread::UI, FROM_HERE, | 152 content::BrowserThread::UI, FROM_HERE, |
153 base::Bind(&CreateAppListShim, profile_path)); | 153 base::Bind(&CreateAppListShim, profile_path)); |
154 return; | 154 return; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 [[window_controller_ appListViewController] setDelegate:delegate.Pass()]; | 207 [[window_controller_ appListViewController] setDelegate:delegate.Pass()]; |
208 } | 208 } |
209 | 209 |
210 void AppListServiceMac::Init(Profile* initial_profile) { | 210 void AppListServiceMac::Init(Profile* initial_profile) { |
211 // On Mac, Init() is called multiple times for a process: any time there is no | 211 // On Mac, Init() is called multiple times for a process: any time there is no |
212 // browser window open and a new window is opened, and during process startup | 212 // browser window open and a new window is opened, and during process startup |
213 // to handle the silent launch case (e.g. for app shims). In the startup case, | 213 // to handle the silent launch case (e.g. for app shims). In the startup case, |
214 // a profile has not yet been determined so |initial_profile| will be NULL. | 214 // a profile has not yet been determined so |initial_profile| will be NULL. |
215 if (initial_profile) { | 215 if (initial_profile) { |
216 static bool checked_shim = false; | 216 static bool checked_shim = false; |
217 if (!checked_shim && CommandLine::ForCurrentProcess()->HasSwitch( | 217 if (!checked_shim) { |
218 switches::kEnableAppListShim)) { | |
219 checked_shim = true; | 218 checked_shim = true; |
220 content::BrowserThread::PostTask( | 219 content::BrowserThread::PostTask( |
221 content::BrowserThread::FILE, FROM_HERE, | 220 content::BrowserThread::FILE, FROM_HERE, |
222 base::Bind(&CheckAppListShimOnFileThread, | 221 base::Bind(&CheckAppListShimOnFileThread, |
223 initial_profile->GetPath())); | 222 initial_profile->GetPath())); |
224 } | 223 } |
225 } | 224 } |
226 | 225 |
227 static bool init_called = false; | 226 static bool init_called = false; |
228 if (init_called) | 227 if (init_called) |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 | 364 |
366 // static | 365 // static |
367 AppListService* AppListService::Get() { | 366 AppListService* AppListService::Get() { |
368 return AppListServiceMac::GetInstance(); | 367 return AppListServiceMac::GetInstance(); |
369 } | 368 } |
370 | 369 |
371 // static | 370 // static |
372 void AppListService::InitAll(Profile* initial_profile) { | 371 void AppListService::InitAll(Profile* initial_profile) { |
373 Get()->Init(initial_profile); | 372 Get()->Init(initial_profile); |
374 } | 373 } |
OLD | NEW |