| 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 "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/browser/background/background_mode_manager.h" | 9 #include "chrome/browser/background/background_mode_manager.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 16 | 16 |
| 17 using content::BrowserThread; | 17 using content::BrowserThread; |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 void SetUserRemovedLoginItemPrefOnUIThread() { | 20 void SetUserRemovedLoginItemPrefOnUIThread() { |
| 21 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 21 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 22 PrefService* service = g_browser_process->local_state(); | 22 PrefService* service = g_browser_process->local_state(); |
| 23 service->SetBoolean(prefs::kUserRemovedLoginItem, true); | 23 service->SetBoolean(prefs::kUserRemovedLoginItem, true); |
| 24 } | 24 } |
| 25 | 25 |
| 26 void SetCreatedLoginItemPrefOnUIThread() { | 26 void SetCreatedLoginItemPrefOnUIThread() { |
| 27 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 27 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 28 PrefService* service = g_browser_process->local_state(); | 28 PrefService* service = g_browser_process->local_state(); |
| 29 service->SetBoolean(prefs::kChromeCreatedLoginItem, true); | 29 service->SetBoolean(prefs::kChromeCreatedLoginItem, true); |
| 30 } | 30 } |
| 31 | 31 |
| 32 void DisableLaunchOnStartupOnFileThread() { | 32 void DisableLaunchOnStartupOnFileThread() { |
| 33 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 33 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
| 34 // If the LoginItem is not hidden, it means it's user created, so don't | 34 // If the LoginItem is not hidden, it means it's user created, so don't |
| 35 // delete it. | 35 // delete it. |
| 36 bool is_hidden = false; | 36 bool is_hidden = false; |
| 37 if (base::mac::CheckLoginItemStatus(&is_hidden) && is_hidden) | 37 if (base::mac::CheckLoginItemStatus(&is_hidden) && is_hidden) |
| 38 base::mac::RemoveFromLoginItems(); | 38 base::mac::RemoveFromLoginItems(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void CheckForUserRemovedLoginItemOnFileThread() { | 41 void CheckForUserRemovedLoginItemOnFileThread() { |
| 42 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 42 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
| 43 if (!base::mac::CheckLoginItemStatus(NULL)) { | 43 if (!base::mac::CheckLoginItemStatus(NULL)) { |
| 44 // There's no LoginItem, so set the kUserRemovedLoginItem pref. | 44 // There's no LoginItem, so set the kUserRemovedLoginItem pref. |
| 45 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 45 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 46 base::Bind(SetUserRemovedLoginItemPrefOnUIThread)); | 46 base::Bind(SetUserRemovedLoginItemPrefOnUIThread)); |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 void EnableLaunchOnStartupOnFileThread(bool need_migration) { | 50 void EnableLaunchOnStartupOnFileThread(bool need_migration) { |
| 51 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); | 51 DCHECK_CURRENTLY_ON(content::BrowserThread::FILE); |
| 52 if (need_migration) { | 52 if (need_migration) { |
| 53 // This is the first time running Chrome since the kChromeCreatedLoginItem | 53 // This is the first time running Chrome since the kChromeCreatedLoginItem |
| 54 // pref was added. Initialize the status of this pref based on whether | 54 // pref was added. Initialize the status of this pref based on whether |
| 55 // there is already a hidden login item. | 55 // there is already a hidden login item. |
| 56 bool is_hidden = false; | 56 bool is_hidden = false; |
| 57 if (base::mac::CheckLoginItemStatus(&is_hidden)) { | 57 if (base::mac::CheckLoginItemStatus(&is_hidden)) { |
| 58 if (is_hidden) { | 58 if (is_hidden) { |
| 59 // We already have a hidden login item, so set the kChromeCreatedLoginItem | 59 // We already have a hidden login item, so set the kChromeCreatedLoginItem |
| 60 // flag. | 60 // flag. |
| 61 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 61 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 151 |
| 152 void BackgroundModeManager::DisplayAppInstalledNotification( | 152 void BackgroundModeManager::DisplayAppInstalledNotification( |
| 153 const extensions::Extension* extension) { | 153 const extensions::Extension* extension) { |
| 154 // TODO(atwilson): Display a platform-appropriate notification here. | 154 // TODO(atwilson): Display a platform-appropriate notification here. |
| 155 // http://crbug.com/74970 | 155 // http://crbug.com/74970 |
| 156 } | 156 } |
| 157 | 157 |
| 158 base::string16 BackgroundModeManager::GetPreferencesMenuLabel() { | 158 base::string16 BackgroundModeManager::GetPreferencesMenuLabel() { |
| 159 return l10n_util::GetStringUTF16(IDS_OPTIONS); | 159 return l10n_util::GetStringUTF16(IDS_OPTIONS); |
| 160 } | 160 } |
| OLD | NEW |