| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 #include "chrome/browser/background/background_mode_manager.h" | 8 #include "chrome/browser/background/background_mode_manager.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 void DisableLaunchOnStartupCallback() { | 21 void DisableLaunchOnStartupCallback() { |
| 22 // Check if Chrome is not a login Item, or is a Login Item but w/o 'hidden' | 22 // Check if Chrome is not a login Item, or is a Login Item but w/o 'hidden' |
| 23 // flag - most likely user has modified the setting, don't override it. | 23 // flag - most likely user has modified the setting, don't override it. |
| 24 bool is_hidden = false; | 24 bool is_hidden = false; |
| 25 if (!base::mac::CheckLoginItemStatus(&is_hidden) || !is_hidden) | 25 if (!base::mac::CheckLoginItemStatus(&is_hidden) || !is_hidden) |
| 26 return; | 26 return; |
| 27 | 27 |
| 28 base::mac::RemoveFromLoginItems(); | 28 base::mac::RemoveFromLoginItems(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 void SetUserCreatedLoginItemPrefCallback() { |
| 32 PrefService* service = g_browser_process->local_state(); |
| 33 service->SetBoolean(prefs::kUserCreatedLoginItem, true); |
| 34 } |
| 35 |
| 31 void EnableLaunchOnStartupCallback() { | 36 void EnableLaunchOnStartupCallback() { |
| 32 // Return if Chrome is already a Login Item (avoid overriding user choice). | 37 // Return if Chrome is already a Login Item (avoid overriding user choice). |
| 33 if (base::mac::CheckLoginItemStatus(NULL)) { | 38 if (base::mac::CheckLoginItemStatus(NULL)) { |
| 34 // Call back to the UI thread to set our preference so we don't delete the | 39 // Call back to the UI thread to set our preference so we don't delete the |
| 35 // user's login item when we disable launch on startup. There's a race | 40 // user's login item when we disable launch on startup. There's a race |
| 36 // condition here if the user disables launch on startup before our callback | 41 // condition here if the user disables launch on startup before our callback |
| 37 // is run, but the user can manually disable "Open At Login" via the dock if | 42 // is run, but the user can manually disable "Open At Login" via the dock if |
| 38 // this happens. | 43 // this happens. |
| 39 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 44 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 40 base::Bind(SetUserCreatedLoginItemPrefCallback)); | 45 base::Bind(SetUserCreatedLoginItemPrefCallback)); |
| 41 return; | 46 return; |
| 42 } | 47 } |
| 43 | 48 |
| 44 base::mac::AddToLoginItems(true); // Hide on startup. | 49 base::mac::AddToLoginItems(true); // Hide on startup. |
| 45 } | 50 } |
| 46 | 51 |
| 47 void SetUserCreatedLoginItemPrefCallback() { | |
| 48 PrefService* service = g_browser_process->local_state(); | |
| 49 service->SetBoolean(prefs::kUserCreatedLoginItem, true); | |
| 50 } | |
| 51 | |
| 52 } // namespace | 52 } // namespace |
| 53 | 53 |
| 54 void BackgroundModeManager::EnableLaunchOnStartup(bool should_launch) { | 54 void BackgroundModeManager::EnableLaunchOnStartup(bool should_launch) { |
| 55 // This functionality is only defined for default profile, currently. | 55 // This functionality is only defined for default profile, currently. |
| 56 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserDataDir)) | 56 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUserDataDir)) |
| 57 return; | 57 return; |
| 58 | 58 |
| 59 if (should_launch) { | 59 if (should_launch) { |
| 60 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 60 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 61 base::Bind(EnableLaunchOnStartupCallback)); | 61 base::Bind(EnableLaunchOnStartupCallback)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 75 | 75 |
| 76 void BackgroundModeManager::DisplayAppInstalledNotification( | 76 void BackgroundModeManager::DisplayAppInstalledNotification( |
| 77 const Extension* extension) { | 77 const Extension* extension) { |
| 78 // TODO(atwilson): Display a platform-appropriate notification here. | 78 // TODO(atwilson): Display a platform-appropriate notification here. |
| 79 // http://crbug.com/74970 | 79 // http://crbug.com/74970 |
| 80 } | 80 } |
| 81 | 81 |
| 82 string16 BackgroundModeManager::GetPreferencesMenuLabel() { | 82 string16 BackgroundModeManager::GetPreferencesMenuLabel() { |
| 83 return l10n_util::GetStringUTF16(IDS_OPTIONS); | 83 return l10n_util::GetStringUTF16(IDS_OPTIONS); |
| 84 } | 84 } |
| OLD | NEW |