Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: content/shell/browser/shell_win.cc

Issue 23769011: Move a bunch of windows stuff from ui/base/win to ui/gfx/win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moar bustage. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/shell/app/shell_main_delegate.cc ('k') | remoting/host/plugin/host_plugin.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/shell.h" 5 #include "content/shell/browser/shell.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <commctrl.h> 8 #include <commctrl.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <io.h> 10 #include <io.h>
11 11
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/win/wrapped_window_proc.h" 13 #include "base/win/wrapped_window_proc.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 #include "content/public/browser/web_contents_view.h" 15 #include "content/public/browser/web_contents_view.h"
16 #include "content/shell/app/resource.h" 16 #include "content/shell/app/resource.h"
17 #include "ui/base/win/hwnd_util.h" 17 #include "ui/gfx/win/hwnd_util.h"
18 18
19 namespace { 19 namespace {
20 20
21 const wchar_t kWindowTitle[] = L"Content Shell"; 21 const wchar_t kWindowTitle[] = L"Content Shell";
22 const wchar_t kWindowClass[] = L"CONTENT_SHELL"; 22 const wchar_t kWindowClass[] = L"CONTENT_SHELL";
23 23
24 const int kButtonWidth = 72; 24 const int kButtonWidth = 72;
25 const int kURLBarHeight = 24; 25 const int kURLBarHeight = 24;
26 26
27 const int kMaxURLLength = 1024; 27 const int kMaxURLLength = 1024;
(...skipping 17 matching lines...) Expand all
45 void Shell::PlatformExit() { 45 void Shell::PlatformExit() {
46 std::vector<Shell*> windows = windows_; 46 std::vector<Shell*> windows = windows_;
47 for (std::vector<Shell*>::iterator it = windows.begin(); 47 for (std::vector<Shell*>::iterator it = windows.begin();
48 it != windows.end(); ++it) 48 it != windows.end(); ++it)
49 DestroyWindow((*it)->window_); 49 DestroyWindow((*it)->window_);
50 } 50 }
51 51
52 void Shell::PlatformCleanUp() { 52 void Shell::PlatformCleanUp() {
53 // When the window is destroyed, tell the Edit field to forget about us, 53 // When the window is destroyed, tell the Edit field to forget about us,
54 // otherwise we will crash. 54 // otherwise we will crash.
55 ui::SetWindowProc(url_edit_view_, default_edit_wnd_proc_); 55 gfx::SetWindowProc(url_edit_view_, default_edit_wnd_proc_);
56 ui::SetWindowUserData(url_edit_view_, NULL); 56 gfx::SetWindowUserData(url_edit_view_, NULL);
57 } 57 }
58 58
59 void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) { 59 void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) {
60 int id; 60 int id;
61 switch (control) { 61 switch (control) {
62 case BACK_BUTTON: 62 case BACK_BUTTON:
63 id = IDC_NAV_BACK; 63 id = IDC_NAV_BACK;
64 break; 64 break;
65 case FORWARD_BUTTON: 65 case FORWARD_BUTTON:
66 id = IDC_NAV_FORWARD; 66 id = IDC_NAV_FORWARD;
(...skipping 15 matching lines...) Expand all
82 } 82 }
83 83
84 void Shell::PlatformSetIsLoading(bool loading) { 84 void Shell::PlatformSetIsLoading(bool loading) {
85 } 85 }
86 86
87 void Shell::PlatformCreateWindow(int width, int height) { 87 void Shell::PlatformCreateWindow(int width, int height) {
88 window_ = CreateWindow(kWindowClass, kWindowTitle, 88 window_ = CreateWindow(kWindowClass, kWindowTitle,
89 WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, 89 WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
90 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 90 CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
91 NULL, NULL, instance_handle_, NULL); 91 NULL, NULL, instance_handle_, NULL);
92 ui::SetWindowUserData(window_, this); 92 gfx::SetWindowUserData(window_, this);
93 93
94 HWND hwnd; 94 HWND hwnd;
95 int x = 0; 95 int x = 0;
96 96
97 hwnd = CreateWindow(L"BUTTON", L"Back", 97 hwnd = CreateWindow(L"BUTTON", L"Back",
98 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON , 98 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ,
99 x, 0, kButtonWidth, kURLBarHeight, 99 x, 0, kButtonWidth, kURLBarHeight,
100 window_, (HMENU) IDC_NAV_BACK, instance_handle_, 0); 100 window_, (HMENU) IDC_NAV_BACK, instance_handle_, 0);
101 x += kButtonWidth; 101 x += kButtonWidth;
102 102
(...skipping 14 matching lines...) Expand all
117 x, 0, kButtonWidth, kURLBarHeight, 117 x, 0, kButtonWidth, kURLBarHeight,
118 window_, (HMENU) IDC_NAV_STOP, instance_handle_, 0); 118 window_, (HMENU) IDC_NAV_STOP, instance_handle_, 0);
119 x += kButtonWidth; 119 x += kButtonWidth;
120 120
121 // This control is positioned by PlatformResizeSubViews. 121 // This control is positioned by PlatformResizeSubViews.
122 url_edit_view_ = CreateWindow(L"EDIT", 0, 122 url_edit_view_ = CreateWindow(L"EDIT", 0,
123 WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | 123 WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT |
124 ES_AUTOVSCROLL | ES_AUTOHSCROLL, 124 ES_AUTOVSCROLL | ES_AUTOHSCROLL,
125 x, 0, 0, 0, window_, 0, instance_handle_, 0); 125 x, 0, 0, 0, window_, 0, instance_handle_, 0);
126 126
127 default_edit_wnd_proc_ = ui::SetWindowProc(url_edit_view_, 127 default_edit_wnd_proc_ = gfx::SetWindowProc(url_edit_view_,
128 Shell::EditWndProc); 128 Shell::EditWndProc);
129 ui::SetWindowUserData(url_edit_view_, this); 129 gfx::SetWindowUserData(url_edit_view_, this);
130 130
131 ShowWindow(window_, SW_SHOW); 131 ShowWindow(window_, SW_SHOW);
132 132
133 SizeTo(width, height); 133 SizeTo(width, height);
134 } 134 }
135 135
136 void Shell::PlatformSetContents() { 136 void Shell::PlatformSetContents() {
137 SetParent(web_contents_->GetView()->GetNativeView(), window_); 137 SetParent(web_contents_->GetView()->GetNativeView(), window_);
138 } 138 }
139 139
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 MAKEINTRESOURCE(IDC_CONTENTSHELL), 185 MAKEINTRESOURCE(IDC_CONTENTSHELL),
186 NULL, 186 NULL,
187 NULL, 187 NULL,
188 &window_class); 188 &window_class);
189 instance_handle_ = window_class.hInstance; 189 instance_handle_ = window_class.hInstance;
190 return RegisterClassEx(&window_class); 190 return RegisterClassEx(&window_class);
191 } 191 }
192 192
193 LRESULT CALLBACK Shell::WndProc(HWND hwnd, UINT message, WPARAM wParam, 193 LRESULT CALLBACK Shell::WndProc(HWND hwnd, UINT message, WPARAM wParam,
194 LPARAM lParam) { 194 LPARAM lParam) {
195 Shell* shell = static_cast<Shell*>(ui::GetWindowUserData(hwnd)); 195 Shell* shell = static_cast<Shell*>(gfx::GetWindowUserData(hwnd));
196 196
197 switch (message) { 197 switch (message) {
198 case WM_COMMAND: { 198 case WM_COMMAND: {
199 int id = LOWORD(wParam); 199 int id = LOWORD(wParam);
200 switch (id) { 200 switch (id) {
201 case IDM_NEW_WINDOW: 201 case IDM_NEW_WINDOW:
202 CreateNewWindow( 202 CreateNewWindow(
203 shell->web_contents()->GetBrowserContext(), 203 shell->web_contents()->GetBrowserContext(),
204 GURL(), NULL, MSG_ROUTING_NONE, gfx::Size()); 204 GURL(), NULL, MSG_ROUTING_NONE, gfx::Size());
205 break; 205 break;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 247 }
248 break; 248 break;
249 } 249 }
250 } 250 }
251 251
252 return DefWindowProc(hwnd, message, wParam, lParam); 252 return DefWindowProc(hwnd, message, wParam, lParam);
253 } 253 }
254 254
255 LRESULT CALLBACK Shell::EditWndProc(HWND hwnd, UINT message, 255 LRESULT CALLBACK Shell::EditWndProc(HWND hwnd, UINT message,
256 WPARAM wParam, LPARAM lParam) { 256 WPARAM wParam, LPARAM lParam) {
257 Shell* shell = static_cast<Shell*>(ui::GetWindowUserData(hwnd)); 257 Shell* shell = static_cast<Shell*>(gfx::GetWindowUserData(hwnd));
258 258
259 switch (message) { 259 switch (message) {
260 case WM_CHAR: 260 case WM_CHAR:
261 if (wParam == VK_RETURN) { 261 if (wParam == VK_RETURN) {
262 wchar_t str[kMaxURLLength + 1]; // Leave room for adding a NULL; 262 wchar_t str[kMaxURLLength + 1]; // Leave room for adding a NULL;
263 *(str) = kMaxURLLength; 263 *(str) = kMaxURLLength;
264 LRESULT str_len = SendMessage(hwnd, EM_GETLINE, 0, (LPARAM)str); 264 LRESULT str_len = SendMessage(hwnd, EM_GETLINE, 0, (LPARAM)str);
265 if (str_len > 0) { 265 if (str_len > 0) {
266 str[str_len] = 0; // EM_GETLINE doesn't NULL terminate. 266 str[str_len] = 0; // EM_GETLINE doesn't NULL terminate.
267 GURL url(str); 267 GURL url(str);
268 if (!url.has_scheme()) 268 if (!url.has_scheme())
269 url = GURL(std::wstring(L"http://") + std::wstring(str)); 269 url = GURL(std::wstring(L"http://") + std::wstring(str));
270 shell->LoadURL(url); 270 shell->LoadURL(url);
271 } 271 }
272 272
273 return 0; 273 return 0;
274 } 274 }
275 } 275 }
276 276
277 return CallWindowProc(shell->default_edit_wnd_proc_, hwnd, message, wParam, 277 return CallWindowProc(shell->default_edit_wnd_proc_, hwnd, message, wParam,
278 lParam); 278 lParam);
279 } 279 }
280 280
281 void Shell::PlatformSetTitle(const string16& text) { 281 void Shell::PlatformSetTitle(const string16& text) {
282 ::SetWindowText(window_, text.c_str()); 282 ::SetWindowText(window_, text.c_str());
283 } 283 }
284 284
285 } // namespace content 285 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/app/shell_main_delegate.cc ('k') | remoting/host/plugin/host_plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698