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/app_controller_mac.h" | 5 #import "chrome/browser/app_controller_mac.h" |
6 | 6 |
7 #include "apps/app_shim/extension_app_shim_handler_mac.h" | 7 #include "apps/app_shim/extension_app_shim_handler_mac.h" |
8 #include "apps/shell_window_registry.h" | 8 #include "apps/shell_window_registry.h" |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 } | 158 } |
159 | 159 |
160 // Record the location of the application bundle (containing the main framework) | 160 // Record the location of the application bundle (containing the main framework) |
161 // from which Chromium was loaded. This is used by app mode shims to find | 161 // from which Chromium was loaded. This is used by app mode shims to find |
162 // Chromium. | 162 // Chromium. |
163 void RecordLastRunAppBundlePath() { | 163 void RecordLastRunAppBundlePath() { |
164 // Going up three levels from |chrome::GetVersionedDirectory()| gives the | 164 // Going up three levels from |chrome::GetVersionedDirectory()| gives the |
165 // real, user-visible app bundle directory. (The alternatives give either the | 165 // real, user-visible app bundle directory. (The alternatives give either the |
166 // framework's path or the initial app's path, which may be an app mode shim | 166 // framework's path or the initial app's path, which may be an app mode shim |
167 // or a unit test.) | 167 // or a unit test.) |
| 168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 169 |
168 base::FilePath appBundlePath = | 170 base::FilePath appBundlePath = |
169 chrome::GetVersionedDirectory().DirName().DirName().DirName(); | 171 chrome::GetVersionedDirectory().DirName().DirName().DirName(); |
170 CFPreferencesSetAppValue( | 172 CFPreferencesSetAppValue( |
171 base::mac::NSToCFCast(app_mode::kLastRunAppBundlePathPrefsKey), | 173 base::mac::NSToCFCast(app_mode::kLastRunAppBundlePathPrefsKey), |
172 base::SysUTF8ToCFStringRef(appBundlePath.value()), | 174 base::SysUTF8ToCFStringRef(appBundlePath.value()), |
173 BaseBundleID_CFString()); | 175 BaseBundleID_CFString()); |
174 | 176 |
175 // Sync after a delay avoid I/O contention on startup; 1500 ms is plenty. | 177 // Sync after a delay avoid I/O contention on startup; 1500 ms is plenty. |
176 BrowserThread::PostDelayedTask( | 178 BrowserThread::PostDelayedTask( |
177 BrowserThread::FILE, FROM_HERE, | 179 BrowserThread::FILE, FROM_HERE, |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 // Instantiate the ProfileInfoCache observer so that we can get | 666 // Instantiate the ProfileInfoCache observer so that we can get |
665 // notified when a profile is deleted. | 667 // notified when a profile is deleted. |
666 profileInfoCacheObserver_.reset(new AppControllerProfileObserver( | 668 profileInfoCacheObserver_.reset(new AppControllerProfileObserver( |
667 g_browser_process->profile_manager(), self)); | 669 g_browser_process->profile_manager(), self)); |
668 | 670 |
669 // Since Chrome is localized to more languages than the OS, tell Cocoa which | 671 // Since Chrome is localized to more languages than the OS, tell Cocoa which |
670 // menu is the Help so it can add the search item to it. | 672 // menu is the Help so it can add the search item to it. |
671 [NSApp setHelpMenu:helpMenu_]; | 673 [NSApp setHelpMenu:helpMenu_]; |
672 | 674 |
673 // Record the path to the (browser) app bundle; this is used by the app mode | 675 // Record the path to the (browser) app bundle; this is used by the app mode |
674 // shim. | 676 // shim. It has to be done in FILE thread because getting the path requires |
675 RecordLastRunAppBundlePath(); | 677 // I/O. |
| 678 BrowserThread::PostTask( |
| 679 BrowserThread::FILE, FROM_HERE, |
| 680 base::Bind(&RecordLastRunAppBundlePath)); |
676 | 681 |
677 // Makes "Services" menu items available. | 682 // Makes "Services" menu items available. |
678 [self registerServicesMenuTypesTo:[notify object]]; | 683 [self registerServicesMenuTypesTo:[notify object]]; |
679 | 684 |
680 startupComplete_ = YES; | 685 startupComplete_ = YES; |
681 | 686 |
682 // TODO(viettrungluu): This is very temporary, since this should be done "in" | 687 // TODO(viettrungluu): This is very temporary, since this should be done "in" |
683 // |BrowserMain()|, i.e., this list of startup URLs should be appended to the | 688 // |BrowserMain()|, i.e., this list of startup URLs should be appended to the |
684 // (probably-empty) list of URLs from the command line. | 689 // (probably-empty) list of URLs from the command line. |
685 if (startupUrls_.size()) { | 690 if (startupUrls_.size()) { |
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1418 | 1423 |
1419 //--------------------------------------------------------------------------- | 1424 //--------------------------------------------------------------------------- |
1420 | 1425 |
1421 namespace app_controller_mac { | 1426 namespace app_controller_mac { |
1422 | 1427 |
1423 bool IsOpeningNewWindow() { | 1428 bool IsOpeningNewWindow() { |
1424 return g_is_opening_new_window; | 1429 return g_is_opening_new_window; |
1425 } | 1430 } |
1426 | 1431 |
1427 } // namespace app_controller_mac | 1432 } // namespace app_controller_mac |
OLD | NEW |