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

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

Issue 10830260: Add local file system directory listings support for content shell. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 4 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
« content/content_shell.gypi ('K') | « content/shell/shell_mac.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« content/content_shell.gypi ('K') | « content/shell/shell_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698