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 "chrome/utility/chrome_content_utility_client.h" | 5 #include "chrome/utility/chrome_content_utility_client.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
11 #include "chrome/common/chrome_utility_messages.h" | 11 #include "chrome/common/chrome_utility_messages.h" |
12 #include "chrome/common/extensions/extension_l10n_util.h" | 12 #include "chrome/common/extensions/extension_l10n_util.h" |
13 #include "chrome/common/extensions/extension_unpacker.h" | 13 #include "chrome/common/extensions/extension_unpacker.h" |
14 #include "chrome/common/extensions/update_manifest.h" | 14 #include "chrome/common/extensions/update_manifest.h" |
15 #include "chrome/common/web_resource/web_resource_unpacker.h" | 15 #include "chrome/common/web_resource/web_resource_unpacker.h" |
16 #include "content/utility/utility_thread.h" | 16 #include "content/utility/utility_thread.h" |
17 #include "printing/backend/print_backend.h" | 17 #include "printing/backend/print_backend.h" |
18 #include "printing/page_range.h" | 18 #include "printing/page_range.h" |
19 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
20 #include "ui/base/ui_base_switches.h" | 20 #include "ui/base/ui_base_switches.h" |
21 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
22 #include "webkit/glue/image_decoder.h" | 22 #include "webkit/glue/image_decoder.h" |
23 | 23 |
24 #if defined(OS_WIN) | 24 #if defined(OS_WIN) |
25 #include "app/win/iat_patch_function.h" | |
26 #include "base/file_util.h" | 25 #include "base/file_util.h" |
27 #include "base/memory/scoped_ptr.h" | 26 #include "base/memory/scoped_ptr.h" |
28 #include "base/path_service.h" | 27 #include "base/path_service.h" |
| 28 #include "base/win/iat_patch_function.h" |
29 #include "base/win/scoped_handle.h" | 29 #include "base/win/scoped_handle.h" |
30 #include "content/common/content_switches.h" | 30 #include "content/common/content_switches.h" |
31 #include "content/common/sandbox_init_wrapper.h" | 31 #include "content/common/sandbox_init_wrapper.h" |
32 #include "printing/emf_win.h" | 32 #include "printing/emf_win.h" |
33 #endif // defined(OS_WIN) | 33 #endif // defined(OS_WIN) |
34 | 34 |
35 namespace chrome { | 35 namespace chrome { |
36 | 36 |
37 ChromeContentUtilityClient::ChromeContentUtilityClient() { | 37 ChromeContentUtilityClient::ChromeContentUtilityClient() { |
38 } | 38 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 int bounds_width, int bounds_height, bool fit_to_bounds, | 186 int bounds_width, int bounds_height, bool fit_to_bounds, |
187 bool stretch_to_bounds, bool keep_aspect_ratio, bool center_in_bounds); | 187 bool stretch_to_bounds, bool keep_aspect_ratio, bool center_in_bounds); |
188 | 188 |
189 typedef bool (*GetPDFDocInfoProc)(const unsigned char* pdf_buffer, | 189 typedef bool (*GetPDFDocInfoProc)(const unsigned char* pdf_buffer, |
190 int buffer_size, int* page_count, | 190 int buffer_size, int* page_count, |
191 double* max_page_width); | 191 double* max_page_width); |
192 | 192 |
193 // The 2 below IAT patch functions are almost identical to the code in | 193 // The 2 below IAT patch functions are almost identical to the code in |
194 // render_process_impl.cc. This is needed to work around specific Windows APIs | 194 // render_process_impl.cc. This is needed to work around specific Windows APIs |
195 // used by the Chrome PDF plugin that will fail in the sandbox. | 195 // used by the Chrome PDF plugin that will fail in the sandbox. |
196 static app::win::IATPatchFunction g_iat_patch_createdca; | 196 static base::win::IATPatchFunction g_iat_patch_createdca; |
197 HDC WINAPI UtilityProcess_CreateDCAPatch(LPCSTR driver_name, | 197 HDC WINAPI UtilityProcess_CreateDCAPatch(LPCSTR driver_name, |
198 LPCSTR device_name, | 198 LPCSTR device_name, |
199 LPCSTR output, | 199 LPCSTR output, |
200 const DEVMODEA* init_data) { | 200 const DEVMODEA* init_data) { |
201 if (driver_name && | 201 if (driver_name && |
202 (std::string("DISPLAY") == std::string(driver_name))) | 202 (std::string("DISPLAY") == std::string(driver_name))) |
203 // CreateDC fails behind the sandbox, but not CreateCompatibleDC. | 203 // CreateDC fails behind the sandbox, but not CreateCompatibleDC. |
204 return CreateCompatibleDC(NULL); | 204 return CreateCompatibleDC(NULL); |
205 | 205 |
206 NOTREACHED(); | 206 NOTREACHED(); |
207 return CreateDCA(driver_name, device_name, output, init_data); | 207 return CreateDCA(driver_name, device_name, output, init_data); |
208 } | 208 } |
209 | 209 |
210 static app::win::IATPatchFunction g_iat_patch_get_font_data; | 210 static base::win::IATPatchFunction g_iat_patch_get_font_data; |
211 DWORD WINAPI UtilityProcess_GetFontDataPatch( | 211 DWORD WINAPI UtilityProcess_GetFontDataPatch( |
212 HDC hdc, DWORD table, DWORD offset, LPVOID buffer, DWORD length) { | 212 HDC hdc, DWORD table, DWORD offset, LPVOID buffer, DWORD length) { |
213 int rv = GetFontData(hdc, table, offset, buffer, length); | 213 int rv = GetFontData(hdc, table, offset, buffer, length); |
214 if (rv == GDI_ERROR && hdc) { | 214 if (rv == GDI_ERROR && hdc) { |
215 HFONT font = static_cast<HFONT>(GetCurrentObject(hdc, OBJ_FONT)); | 215 HFONT font = static_cast<HFONT>(GetCurrentObject(hdc, OBJ_FONT)); |
216 | 216 |
217 LOGFONT logfont; | 217 LOGFONT logfont; |
218 if (GetObject(font, sizeof(LOGFONT), &logfont)) { | 218 if (GetObject(font, sizeof(LOGFONT), &logfont)) { |
219 std::vector<char> font_data; | 219 std::vector<char> font_data; |
220 if (UtilityThread::current()->Send( | 220 if (UtilityThread::current()->Send( |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 if (print_backend->GetPrinterCapsAndDefaults(printer_name, &printer_info)) { | 340 if (print_backend->GetPrinterCapsAndDefaults(printer_name, &printer_info)) { |
341 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded(printer_name, | 341 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded(printer_name, |
342 printer_info)); | 342 printer_info)); |
343 } else { | 343 } else { |
344 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name)); | 344 Send(new UtilityHostMsg_GetPrinterCapsAndDefaults_Failed(printer_name)); |
345 } | 345 } |
346 UtilityThread::current()->ReleaseProcessIfNeeded(); | 346 UtilityThread::current()->ReleaseProcessIfNeeded(); |
347 } | 347 } |
348 | 348 |
349 } // namespace chrome | 349 } // namespace chrome |
OLD | NEW |