| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/child_process_logging.h" | 5 #include "chrome/common/child_process_logging.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 if (!set_active_url) { | 73 if (!set_active_url) { |
| 74 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 74 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 75 if (!exe_module) | 75 if (!exe_module) |
| 76 return; | 76 return; |
| 77 set_active_url = reinterpret_cast<MainSetActiveURL>( | 77 set_active_url = reinterpret_cast<MainSetActiveURL>( |
| 78 GetProcAddress(exe_module, "SetActiveURL")); | 78 GetProcAddress(exe_module, "SetActiveURL")); |
| 79 if (!set_active_url) | 79 if (!set_active_url) |
| 80 return; | 80 return; |
| 81 } | 81 } |
| 82 | 82 |
| 83 (set_active_url)(UTF8ToWide(url.possibly_invalid_spec()).c_str()); | 83 (set_active_url)(base::UTF8ToWide(url.possibly_invalid_spec()).c_str()); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void SetClientId(const std::string& client_id) { | 86 void SetClientId(const std::string& client_id) { |
| 87 std::string str(client_id); | 87 std::string str(client_id); |
| 88 // Remove all instance of '-' char from the GUID. So BCD-WXY becomes BCDWXY. | 88 // Remove all instance of '-' char from the GUID. So BCD-WXY becomes BCDWXY. |
| 89 ReplaceSubstringsAfterOffset(&str, 0, "-", ""); | 89 ReplaceSubstringsAfterOffset(&str, 0, "-", ""); |
| 90 | 90 |
| 91 if (str.empty()) | 91 if (str.empty()) |
| 92 return; | 92 return; |
| 93 | 93 |
| 94 std::wstring wstr = ASCIIToWide(str); | 94 std::wstring wstr = base::ASCIIToWide(str); |
| 95 std::wstring old_wstr; | 95 std::wstring old_wstr; |
| 96 if (!GoogleUpdateSettings::GetMetricsId(&old_wstr) || | 96 if (!GoogleUpdateSettings::GetMetricsId(&old_wstr) || |
| 97 wstr != old_wstr) | 97 wstr != old_wstr) |
| 98 GoogleUpdateSettings::SetMetricsId(wstr); | 98 GoogleUpdateSettings::SetMetricsId(wstr); |
| 99 | 99 |
| 100 static MainSetClientId set_client_id = NULL; | 100 static MainSetClientId set_client_id = NULL; |
| 101 // note: benign race condition on set_client_id. | 101 // note: benign race condition on set_client_id. |
| 102 if (!set_client_id) { | 102 if (!set_client_id) { |
| 103 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 103 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 104 if (!exe_module) | 104 if (!exe_module) |
| 105 return; | 105 return; |
| 106 set_client_id = reinterpret_cast<MainSetClientId>( | 106 set_client_id = reinterpret_cast<MainSetClientId>( |
| 107 GetProcAddress(exe_module, "SetClientId")); | 107 GetProcAddress(exe_module, "SetClientId")); |
| 108 if (!set_client_id) | 108 if (!set_client_id) |
| 109 return; | 109 return; |
| 110 } | 110 } |
| 111 (set_client_id)(wstr.c_str()); | 111 (set_client_id)(wstr.c_str()); |
| 112 } | 112 } |
| 113 | 113 |
| 114 std::string GetClientId() { | 114 std::string GetClientId() { |
| 115 std::wstring wstr_client_id; | 115 std::wstring wstr_client_id; |
| 116 if (GoogleUpdateSettings::GetMetricsId(&wstr_client_id)) | 116 if (GoogleUpdateSettings::GetMetricsId(&wstr_client_id)) |
| 117 return WideToASCII(wstr_client_id); | 117 return base::WideToASCII(wstr_client_id); |
| 118 else | 118 else |
| 119 return std::string(); | 119 return std::string(); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void SetActiveExtensions(const std::set<std::string>& extension_ids) { | 122 void SetActiveExtensions(const std::set<std::string>& extension_ids) { |
| 123 static MainSetNumberOfExtensions set_number_of_extensions = NULL; | 123 static MainSetNumberOfExtensions set_number_of_extensions = NULL; |
| 124 // note: benign race condition on set_number_of_extensions. | 124 // note: benign race condition on set_number_of_extensions. |
| 125 if (!set_number_of_extensions) { | 125 if (!set_number_of_extensions) { |
| 126 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 126 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 127 if (!exe_module) | 127 if (!exe_module) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 142 GetProcAddress(exe_module, "SetExtensionID")); | 142 GetProcAddress(exe_module, "SetExtensionID")); |
| 143 if (!set_extension_id) | 143 if (!set_extension_id) |
| 144 return; | 144 return; |
| 145 } | 145 } |
| 146 | 146 |
| 147 (set_number_of_extensions)(static_cast<int>(extension_ids.size())); | 147 (set_number_of_extensions)(static_cast<int>(extension_ids.size())); |
| 148 | 148 |
| 149 std::set<std::string>::const_iterator iter = extension_ids.begin(); | 149 std::set<std::string>::const_iterator iter = extension_ids.begin(); |
| 150 for (size_t i = 0; i < kMaxReportedActiveExtensions; ++i) { | 150 for (size_t i = 0; i < kMaxReportedActiveExtensions; ++i) { |
| 151 if (iter != extension_ids.end()) { | 151 if (iter != extension_ids.end()) { |
| 152 (set_extension_id)(i, ASCIIToWide(iter->c_str()).c_str()); | 152 (set_extension_id)(i, base::ASCIIToWide(iter->c_str()).c_str()); |
| 153 ++iter; | 153 ++iter; |
| 154 } else { | 154 } else { |
| 155 (set_extension_id)(i, L""); | 155 (set_extension_id)(i, L""); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 | 159 |
| 160 void SetGpuInfo(const content::GPUInfo& gpu_info) { | 160 void SetGpuInfo(const content::GPUInfo& gpu_info) { |
| 161 static MainSetGpuInfo set_gpu_info = NULL; | 161 static MainSetGpuInfo set_gpu_info = NULL; |
| 162 // note: benign race condition on set_gpu_info. | 162 // note: benign race condition on set_gpu_info. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 182 // note: benign race condition on set_printer_info. | 182 // note: benign race condition on set_printer_info. |
| 183 if (!set_printer_info) { | 183 if (!set_printer_info) { |
| 184 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 184 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 185 if (!exe_module) | 185 if (!exe_module) |
| 186 return; | 186 return; |
| 187 set_printer_info = reinterpret_cast<MainSetPrinterInfo>( | 187 set_printer_info = reinterpret_cast<MainSetPrinterInfo>( |
| 188 GetProcAddress(exe_module, "SetPrinterInfo")); | 188 GetProcAddress(exe_module, "SetPrinterInfo")); |
| 189 if (!set_printer_info) | 189 if (!set_printer_info) |
| 190 return; | 190 return; |
| 191 } | 191 } |
| 192 (set_printer_info)(UTF8ToWide(printer_info).c_str()); | 192 (set_printer_info)(base::UTF8ToWide(printer_info).c_str()); |
| 193 } | 193 } |
| 194 | 194 |
| 195 void SetCommandLine(const CommandLine* command_line) { | 195 void SetCommandLine(const CommandLine* command_line) { |
| 196 static MainSetCommandLine set_command_line = NULL; | 196 static MainSetCommandLine set_command_line = NULL; |
| 197 // note: benign race condition on set_command_line. | 197 // note: benign race condition on set_command_line. |
| 198 if (!set_command_line) { | 198 if (!set_command_line) { |
| 199 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); | 199 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); |
| 200 if (!exe_module) | 200 if (!exe_module) |
| 201 return; | 201 return; |
| 202 set_command_line = reinterpret_cast<MainSetCommandLine>( | 202 set_command_line = reinterpret_cast<MainSetCommandLine>( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 return; | 250 return; |
| 251 set_number_of_views = reinterpret_cast<MainSetNumberOfViews>( | 251 set_number_of_views = reinterpret_cast<MainSetNumberOfViews>( |
| 252 GetProcAddress(exe_module, "SetNumberOfViews")); | 252 GetProcAddress(exe_module, "SetNumberOfViews")); |
| 253 if (!set_number_of_views) | 253 if (!set_number_of_views) |
| 254 return; | 254 return; |
| 255 } | 255 } |
| 256 (set_number_of_views)(number_of_views); | 256 (set_number_of_views)(number_of_views); |
| 257 } | 257 } |
| 258 | 258 |
| 259 } // namespace child_process_logging | 259 } // namespace child_process_logging |
| OLD | NEW |