OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 5 #include "app/l10n_util.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/mac_util.h" | 7 #include "base/mac/mac_util.h" |
8 #include "chrome/browser/background_mode_manager.h" | 8 #include "chrome/browser/background_mode_manager.h" |
9 #include "chrome/browser/browser_thread.h" | 9 #include "chrome/browser/browser_thread.h" |
10 #include "chrome/common/app_mode_common_mac.h" | 10 #include "chrome/common/app_mode_common_mac.h" |
11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
12 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 class DisableLaunchOnStartupTask : public Task { | 16 class DisableLaunchOnStartupTask : public Task { |
17 public: | 17 public: |
(...skipping 15 matching lines...) Expand all Loading... |
33 &key_exists_and_has_valid_format)) | 33 &key_exists_and_has_valid_format)) |
34 return; | 34 return; |
35 | 35 |
36 CFPreferencesSetAppValue(kLaunchOnStartupResetAllowedPrefsKey, | 36 CFPreferencesSetAppValue(kLaunchOnStartupResetAllowedPrefsKey, |
37 kCFBooleanFalse, | 37 kCFBooleanFalse, |
38 app_mode::kAppPrefsID); | 38 app_mode::kAppPrefsID); |
39 | 39 |
40 // Check if Chrome is not a login Item, or is a Login Item but w/o 'hidden' | 40 // Check if Chrome is not a login Item, or is a Login Item but w/o 'hidden' |
41 // flag - most likely user has modified the setting, don't override it. | 41 // flag - most likely user has modified the setting, don't override it. |
42 bool is_hidden = false; | 42 bool is_hidden = false; |
43 if (!mac_util::CheckLoginItemStatus(&is_hidden) || !is_hidden) | 43 if (!base::mac::CheckLoginItemStatus(&is_hidden) || !is_hidden) |
44 return; | 44 return; |
45 | 45 |
46 mac_util::RemoveFromLoginItems(); | 46 base::mac::RemoveFromLoginItems(); |
47 } | 47 } |
48 | 48 |
49 void EnableLaunchOnStartupTask::Run() { | 49 void EnableLaunchOnStartupTask::Run() { |
50 // Return if Chrome is already a Login Item (avoid overriding user choice). | 50 // Return if Chrome is already a Login Item (avoid overriding user choice). |
51 if (mac_util::CheckLoginItemStatus(NULL)) | 51 if (base::mac::CheckLoginItemStatus(NULL)) |
52 return; | 52 return; |
53 | 53 |
54 mac_util::AddToLoginItems(true); // Hide on startup. | 54 base::mac::AddToLoginItems(true); // Hide on startup. |
55 CFPreferencesSetAppValue(kLaunchOnStartupResetAllowedPrefsKey, | 55 CFPreferencesSetAppValue(kLaunchOnStartupResetAllowedPrefsKey, |
56 kCFBooleanTrue, | 56 kCFBooleanTrue, |
57 app_mode::kAppPrefsID); | 57 app_mode::kAppPrefsID); |
58 } | 58 } |
59 | 59 |
60 } // namespace | 60 } // namespace |
61 | 61 |
62 void BackgroundModeManager::EnableLaunchOnStartup(bool should_launch) { | 62 void BackgroundModeManager::EnableLaunchOnStartup(bool should_launch) { |
63 // This functionality is only defined for default profile, currently. | 63 // This functionality is only defined for default profile, currently. |
64 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserDataDir)) | 64 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserDataDir)) |
65 return; | 65 return; |
66 | 66 |
67 if (should_launch) { | 67 if (should_launch) { |
68 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 68 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
69 new EnableLaunchOnStartupTask()); | 69 new EnableLaunchOnStartupTask()); |
70 } else { | 70 } else { |
71 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 71 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
72 new DisableLaunchOnStartupTask()); | 72 new DisableLaunchOnStartupTask()); |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 string16 BackgroundModeManager::GetPreferencesMenuLabel() { | 76 string16 BackgroundModeManager::GetPreferencesMenuLabel() { |
77 return l10n_util::GetStringUTF16(IDS_OPTIONS); | 77 return l10n_util::GetStringUTF16(IDS_OPTIONS); |
78 } | 78 } |
OLD | NEW |