| 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 "app/resource_bundle.h" | 6 #include "app/resource_bundle.h" |
| 7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "chrome/browser/gtk/gtk_util.h" | 46 #include "chrome/browser/gtk/gtk_util.h" |
| 47 #endif | 47 #endif |
| 48 | 48 |
| 49 #if defined(OS_LINUX) | 49 #if defined(OS_LINUX) |
| 50 static const FilePath::CharType kAutostart[] = "autostart"; | 50 static const FilePath::CharType kAutostart[] = "autostart"; |
| 51 static const FilePath::CharType kConfig[] = ".config"; | 51 static const FilePath::CharType kConfig[] = ".config"; |
| 52 static const char kXdgConfigHome[] = "XDG_CONFIG_HOME"; | 52 static const char kXdgConfigHome[] = "XDG_CONFIG_HOME"; |
| 53 #endif | 53 #endif |
| 54 | 54 |
| 55 #if defined(OS_WIN) | 55 #if defined(OS_WIN) |
| 56 #include "base/registry.h" | 56 #include "base/win/registry.h" |
| 57 const HKEY kBackgroundModeRegistryRootKey = HKEY_CURRENT_USER; | 57 const HKEY kBackgroundModeRegistryRootKey = HKEY_CURRENT_USER; |
| 58 const wchar_t* kBackgroundModeRegistrySubkey = | 58 const wchar_t* kBackgroundModeRegistrySubkey = |
| 59 L"Software\\Microsoft\\Windows\\CurrentVersion\\Run"; | 59 L"Software\\Microsoft\\Windows\\CurrentVersion\\Run"; |
| 60 const wchar_t* kBackgroundModeRegistryKeyName = L"chromium"; | 60 const wchar_t* kBackgroundModeRegistryKeyName = L"chromium"; |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 #if defined(OS_LINUX) | 63 #if defined(OS_LINUX) |
| 64 namespace { | 64 namespace { |
| 65 | 65 |
| 66 FilePath GetAutostartDirectory(base::Environment* environment) { | 66 FilePath GetAutostartDirectory(base::Environment* environment) { |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 bool is_hidden = false; | 394 bool is_hidden = false; |
| 395 if (!mac_util::CheckLoginItemStatus(&is_hidden) || !is_hidden) | 395 if (!mac_util::CheckLoginItemStatus(&is_hidden) || !is_hidden) |
| 396 return; | 396 return; |
| 397 | 397 |
| 398 mac_util::RemoveFromLoginItems(); | 398 mac_util::RemoveFromLoginItems(); |
| 399 } | 399 } |
| 400 #elif defined(OS_WIN) | 400 #elif defined(OS_WIN) |
| 401 // TODO(rickcam): Bug 53597: Make RegKey mockable. | 401 // TODO(rickcam): Bug 53597: Make RegKey mockable. |
| 402 // TODO(rickcam): Bug 53600: Use distinct registry keys per flavor+profile. | 402 // TODO(rickcam): Bug 53600: Use distinct registry keys per flavor+profile. |
| 403 const wchar_t* key_name = kBackgroundModeRegistryKeyName; | 403 const wchar_t* key_name = kBackgroundModeRegistryKeyName; |
| 404 RegKey read_key(kBackgroundModeRegistryRootKey, | 404 base::win::RegKey read_key(kBackgroundModeRegistryRootKey, |
| 405 kBackgroundModeRegistrySubkey, KEY_READ); | 405 kBackgroundModeRegistrySubkey, KEY_READ); |
| 406 RegKey write_key(kBackgroundModeRegistryRootKey, | 406 base::win::RegKey write_key(kBackgroundModeRegistryRootKey, |
| 407 kBackgroundModeRegistrySubkey, KEY_WRITE); | 407 kBackgroundModeRegistrySubkey, KEY_WRITE); |
| 408 if (should_launch) { | 408 if (should_launch) { |
| 409 FilePath executable; | 409 FilePath executable; |
| 410 if (!PathService::Get(base::FILE_EXE, &executable)) | 410 if (!PathService::Get(base::FILE_EXE, &executable)) |
| 411 return; | 411 return; |
| 412 std::wstring new_value = executable.value() + | 412 std::wstring new_value = executable.value() + |
| 413 L" --enable-background-mode --no-startup-window"; | 413 L" --enable-background-mode --no-startup-window"; |
| 414 if (read_key.ValueExists(key_name)) { | 414 if (read_key.ValueExists(key_name)) { |
| 415 std::wstring current_value; | 415 std::wstring current_value; |
| 416 if (read_key.ReadValue(key_name, ¤t_value) && | 416 if (read_key.ReadValue(key_name, ¤t_value) && |
| 417 (current_value == new_value)) | 417 (current_value == new_value)) |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 browser = BrowserList::GetLastActive(); | 520 browser = BrowserList::GetLastActive(); |
| 521 } | 521 } |
| 522 return browser; | 522 return browser; |
| 523 } | 523 } |
| 524 | 524 |
| 525 // static | 525 // static |
| 526 void BackgroundModeManager::RegisterUserPrefs(PrefService* prefs) { | 526 void BackgroundModeManager::RegisterUserPrefs(PrefService* prefs) { |
| 527 prefs->RegisterBooleanPref(prefs::kBackgroundModeEnabled, true); | 527 prefs->RegisterBooleanPref(prefs::kBackgroundModeEnabled, true); |
| 528 prefs->RegisterBooleanPref(prefs::kLaunchOnStartupResetAllowed, false); | 528 prefs->RegisterBooleanPref(prefs::kLaunchOnStartupResetAllowed, false); |
| 529 } | 529 } |
| OLD | NEW |