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 "content/shell/shell.h" | 5 #include "content/shell/shell.h" |
6 | 6 |
7 #include <commctrl.h> | 7 #include <commctrl.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <io.h> | 9 #include <io.h> |
10 #include <windows.h> | 10 #include <windows.h> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/string_piece.h" | |
14 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
15 #include "base/win/resource_util.h" | |
16 #include "base/win/wrapped_window_proc.h" | 14 #include "base/win/wrapped_window_proc.h" |
17 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
18 #include "content/public/browser/web_contents_view.h" | 16 #include "content/public/browser/web_contents_view.h" |
19 #include "content/shell/resource.h" | 17 #include "content/shell/resource.h" |
20 #include "content/shell/shell_switches.h" | 18 #include "content/shell/shell_switches.h" |
21 #include "googleurl/src/gurl.h" | |
22 #include "grit/webkit_resources.h" | |
23 #include "grit/webkit_chromium_resources.h" | |
24 #include "ipc/ipc_message.h" | |
25 #include "net/base/net_module.h" | |
26 #include "ui/base/win/hwnd_util.h" | 19 #include "ui/base/win/hwnd_util.h" |
27 | 20 |
28 namespace { | 21 namespace { |
29 | 22 |
30 const wchar_t kWindowTitle[] = L"Content Shell"; | 23 const wchar_t kWindowTitle[] = L"Content Shell"; |
31 const wchar_t kWindowClass[] = L"CONTENT_SHELL"; | 24 const wchar_t kWindowClass[] = L"CONTENT_SHELL"; |
32 | 25 |
33 const int kButtonWidth = 72; | 26 const int kButtonWidth = 72; |
34 const int kURLBarHeight = 24; | 27 const int kURLBarHeight = 24; |
35 | 28 |
36 const int kMaxURLLength = 1024; | 29 const int kMaxURLLength = 1024; |
37 | 30 |
38 static base::StringPiece GetRawDataResource(HMODULE module, int resource_id) { | |
39 void* data_ptr; | |
40 size_t data_size; | |
41 return base::win::GetDataResourceFromModule(module, resource_id, &data_ptr, | |
42 &data_size) | |
43 ? base::StringPiece(static_cast<char*>(data_ptr), data_size) | |
44 : base::StringPiece(); | |
45 } | |
46 | |
47 } // namespace | 31 } // namespace |
48 | 32 |
49 namespace content { | 33 namespace content { |
50 | 34 |
51 HINSTANCE Shell::instance_handle_; | 35 HINSTANCE Shell::instance_handle_; |
52 | 36 |
53 void Shell::PlatformInitialize() { | 37 void Shell::PlatformInitialize() { |
54 _setmode(_fileno(stdout), _O_BINARY); | 38 _setmode(_fileno(stdout), _O_BINARY); |
55 _setmode(_fileno(stderr), _O_BINARY); | 39 _setmode(_fileno(stderr), _O_BINARY); |
56 INITCOMMONCONTROLSEX InitCtrlEx; | 40 INITCOMMONCONTROLSEX InitCtrlEx; |
57 InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); | 41 InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX); |
58 InitCtrlEx.dwICC = ICC_STANDARD_CLASSES; | 42 InitCtrlEx.dwICC = ICC_STANDARD_CLASSES; |
59 InitCommonControlsEx(&InitCtrlEx); | 43 InitCommonControlsEx(&InitCtrlEx); |
60 RegisterWindowClass(); | 44 RegisterWindowClass(); |
61 } | 45 } |
62 | 46 |
63 base::StringPiece Shell::PlatformResourceProvider(int key) { | |
64 return GetRawDataResource(::GetModuleHandle(NULL), key); | |
65 } | |
66 | |
67 void Shell::PlatformExit() { | 47 void Shell::PlatformExit() { |
68 std::vector<Shell*> windows = windows_; | 48 std::vector<Shell*> windows = windows_; |
69 for (std::vector<Shell*>::iterator it = windows.begin(); | 49 for (std::vector<Shell*>::iterator it = windows.begin(); |
70 it != windows.end(); ++it) | 50 it != windows.end(); ++it) |
71 DestroyWindow((*it)->window_); | 51 DestroyWindow((*it)->window_); |
72 } | 52 } |
73 | 53 |
74 void Shell::PlatformCleanUp() { | 54 void Shell::PlatformCleanUp() { |
75 // When the window is destroyed, tell the Edit field to forget about us, | 55 // When the window is destroyed, tell the Edit field to forget about us, |
76 // otherwise we will crash. | 56 // otherwise we will crash. |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 283 |
304 return CallWindowProc(shell->default_edit_wnd_proc_, hwnd, message, wParam, | 284 return CallWindowProc(shell->default_edit_wnd_proc_, hwnd, message, wParam, |
305 lParam); | 285 lParam); |
306 } | 286 } |
307 | 287 |
308 void Shell::PlatformSetTitle(const string16& text) { | 288 void Shell::PlatformSetTitle(const string16& text) { |
309 ::SetWindowText(window_, text.c_str()); | 289 ::SetWindowText(window_, text.c_str()); |
310 } | 290 } |
311 | 291 |
312 } // namespace content | 292 } // namespace content |
OLD | NEW |