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/base_paths.h" | 5 #include "base/base_paths.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/task.h" | 10 #include "base/task.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 const wchar_t* kBackgroundModeRegistrySubkey = | 33 const wchar_t* kBackgroundModeRegistrySubkey = |
34 L"Software\\Microsoft\\Windows\\CurrentVersion\\Run"; | 34 L"Software\\Microsoft\\Windows\\CurrentVersion\\Run"; |
35 const wchar_t* kBackgroundModeRegistryKeyName = L"chromium"; | 35 const wchar_t* kBackgroundModeRegistryKeyName = L"chromium"; |
36 | 36 |
37 void DisableLaunchOnStartupTask::Run() { | 37 void DisableLaunchOnStartupTask::Run() { |
38 const wchar_t* key_name = kBackgroundModeRegistryKeyName; | 38 const wchar_t* key_name = kBackgroundModeRegistryKeyName; |
39 base::win::RegKey read_key(kBackgroundModeRegistryRootKey, | 39 base::win::RegKey read_key(kBackgroundModeRegistryRootKey, |
40 kBackgroundModeRegistrySubkey, KEY_READ); | 40 kBackgroundModeRegistrySubkey, KEY_READ); |
41 base::win::RegKey write_key(kBackgroundModeRegistryRootKey, | 41 base::win::RegKey write_key(kBackgroundModeRegistryRootKey, |
42 kBackgroundModeRegistrySubkey, KEY_WRITE); | 42 kBackgroundModeRegistrySubkey, KEY_WRITE); |
43 if (read_key.ValueExists(key_name)) { | 43 if (read_key.HasValue(key_name)) { |
44 LONG result = write_key.DeleteValue(key_name); | 44 LONG result = write_key.DeleteValue(key_name); |
45 DCHECK_EQ(ERROR_SUCCESS, result) << | 45 DCHECK_EQ(ERROR_SUCCESS, result) << |
46 "Failed to deregister launch on login. error: " << result; | 46 "Failed to deregister launch on login. error: " << result; |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 void EnableLaunchOnStartupTask::Run() { | 50 void EnableLaunchOnStartupTask::Run() { |
51 // TODO(rickcam): Bug 53597: Make RegKey mockable. | 51 // TODO(rickcam): Bug 53597: Make RegKey mockable. |
52 // TODO(rickcam): Bug 53600: Use distinct registry keys per flavor+profile. | 52 // TODO(rickcam): Bug 53600: Use distinct registry keys per flavor+profile. |
53 const wchar_t* key_name = kBackgroundModeRegistryKeyName; | 53 const wchar_t* key_name = kBackgroundModeRegistryKeyName; |
54 base::win::RegKey read_key(kBackgroundModeRegistryRootKey, | 54 base::win::RegKey read_key(kBackgroundModeRegistryRootKey, |
55 kBackgroundModeRegistrySubkey, KEY_READ); | 55 kBackgroundModeRegistrySubkey, KEY_READ); |
56 base::win::RegKey write_key(kBackgroundModeRegistryRootKey, | 56 base::win::RegKey write_key(kBackgroundModeRegistryRootKey, |
57 kBackgroundModeRegistrySubkey, KEY_WRITE); | 57 kBackgroundModeRegistrySubkey, KEY_WRITE); |
58 FilePath executable; | 58 FilePath executable; |
59 if (!PathService::Get(base::FILE_EXE, &executable)) | 59 if (!PathService::Get(base::FILE_EXE, &executable)) |
60 return; | 60 return; |
61 std::wstring new_value = executable.value() + | 61 std::wstring new_value = executable.value() + |
62 L" --" + ASCIIToUTF16(switches::kNoStartupWindow); | 62 L" --" + ASCIIToUTF16(switches::kNoStartupWindow); |
63 if (read_key.ValueExists(key_name)) { | 63 if (read_key.HasValue(key_name)) { |
64 std::wstring current_value; | 64 std::wstring current_value; |
65 if ((read_key.ReadValue(key_name, ¤t_value) == ERROR_SUCCESS) && | 65 if ((read_key.ReadValue(key_name, ¤t_value) == ERROR_SUCCESS) && |
66 (current_value == new_value)) { | 66 (current_value == new_value)) { |
67 return; | 67 return; |
68 } | 68 } |
69 } | 69 } |
70 LONG result = write_key.WriteValue(key_name, new_value.c_str()); | 70 LONG result = write_key.WriteValue(key_name, new_value.c_str()); |
71 DCHECK_EQ(ERROR_SUCCESS, result) << | 71 DCHECK_EQ(ERROR_SUCCESS, result) << |
72 "Failed to register launch on login. error: " << result; | 72 "Failed to register launch on login. error: " << result; |
73 } | 73 } |
(...skipping 22 matching lines...) Expand all Loading... |
96 l10n_util::GetStringUTF16(IDS_BACKGROUND_APP_INSTALLED_BALLOON_TITLE), | 96 l10n_util::GetStringUTF16(IDS_BACKGROUND_APP_INSTALLED_BALLOON_TITLE), |
97 l10n_util::GetStringFUTF16( | 97 l10n_util::GetStringFUTF16( |
98 IDS_BACKGROUND_APP_INSTALLED_BALLOON_BODY, | 98 IDS_BACKGROUND_APP_INSTALLED_BALLOON_BODY, |
99 UTF8ToUTF16(extension->name()), | 99 UTF8ToUTF16(extension->name()), |
100 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 100 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
101 } | 101 } |
102 | 102 |
103 string16 BackgroundModeManager::GetPreferencesMenuLabel() { | 103 string16 BackgroundModeManager::GetPreferencesMenuLabel() { |
104 return l10n_util::GetStringUTF16(IDS_OPTIONS); | 104 return l10n_util::GetStringUTF16(IDS_OPTIONS); |
105 } | 105 } |
OLD | NEW |