summaryrefslogtreecommitdiffstats
path: root/content/shell
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-20 23:31:34 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-20 23:31:34 +0000
commit9fbd3f863f3cde073ff6c6ae15ac2c7dc2a9a0bd (patch)
tree05bb5ced1dbefe68107d7c7995b886630d2b50fa /content/shell
parent9044359baca309ab260075f8b6a87762c675ada1 (diff)
downloadchromium_src-9fbd3f863f3cde073ff6c6ae15ac2c7dc2a9a0bd.zip
chromium_src-9fbd3f863f3cde073ff6c6ae15ac2c7dc2a9a0bd.tar.gz
chromium_src-9fbd3f863f3cde073ff6c6ae15ac2c7dc2a9a0bd.tar.bz2
Add a simple GUI around the content shell. This is inspired heavily by TestShell.
BUG=90445 Review URL: http://codereview.chromium.org/7983015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102053 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/shell')
-rw-r--r--content/shell/resource.h32
-rw-r--r--content/shell/shell.cc102
-rw-r--r--content/shell/shell.h90
-rw-r--r--content/shell/shell.rc70
-rw-r--r--content/shell/shell_browser_main.cc20
-rw-r--r--content/shell/shell_browser_main.h2
-rw-r--r--content/shell/shell_gtk.cc41
-rw-r--r--content/shell/shell_mac.mm41
-rw-r--r--content/shell/shell_win.cc252
9 files changed, 635 insertions, 15 deletions
diff --git a/content/shell/resource.h b/content/shell/resource.h
new file mode 100644
index 0000000..6a0d6c7
--- /dev/null
+++ b/content/shell/resource.h
@@ -0,0 +1,32 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by test_shell.rc
+//
+
+
+#define IDR_MAINFRAME 128
+#define IDM_EXIT 105
+#define IDC_CONTENTSHELL 109
+#define IDC_NAV_BACK 1001
+#define IDC_NAV_FORWARD 1002
+#define IDC_NAV_RELOAD 1003
+#define IDC_NAV_STOP 1004
+#ifndef IDC_STATIC
+#define IDC_STATIC -1
+#endif
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+
+#define _APS_NO_MFC 130
+#define _APS_NEXT_RESOURCE_VALUE 129
+#define _APS_NEXT_COMMAND_VALUE 32771
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 117
+#endif
+#endif
diff --git a/content/shell/shell.cc b/content/shell/shell.cc
new file mode 100644
index 0000000..a41c91c
--- /dev/null
+++ b/content/shell/shell.cc
@@ -0,0 +1,102 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/shell/shell.h"
+
+#include "base/message_loop.h"
+#include "base/path_service.h"
+#include "base/string_util.h"
+#include "content/browser/tab_contents/navigation_controller.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "content/shell/shell_browser_context.h"
+#include "ui/gfx/size.h"
+
+#if defined(OS_WIN)
+#include "content/browser/tab_contents/tab_contents_view_win.h"
+#endif
+
+// Content area size for newly created windows.
+static const int kTestWindowWidth = 800;
+static const int kTestWindowHeight = 600;
+
+namespace content {
+
+int Shell::shell_count_;
+
+Shell::Shell()
+ : main_window_(NULL),
+ edit_window_(NULL)
+#if defined(OS_WIN)
+ , default_edit_wnd_proc_(0)
+#endif
+ {
+ shell_count_++;
+}
+
+Shell::~Shell() {
+ PlatformCleanUp();
+ --shell_count_;
+}
+
+Shell* Shell::CreateNewWindow(ShellBrowserContext* browser_context) {
+ Shell* shell = new Shell();
+ shell->PlatformCreateWindow();
+
+ shell->PlatformSizeTo(kTestWindowWidth, kTestWindowHeight);
+
+ shell->tab_contents_.reset(new TabContents(
+ browser_context,
+ NULL,
+ MSG_ROUTING_NONE,
+ NULL,
+ NULL));
+
+#if defined (OS_WIN)
+ TabContentsViewWin* view =
+ static_cast<TabContentsViewWin*>(shell->tab_contents_->view());
+ view->SetParent(shell->main_window_);
+#endif
+
+ shell->PlatformResizeSubViews();
+
+ shell->LoadURL(GURL("http://www.google.com"));
+ return shell;
+}
+
+void Shell::LoadURL(const GURL& url) {
+ tab_contents_->controller().LoadURL(
+ url,
+ GURL(),
+ PageTransition::TYPED,
+ std::string());
+}
+
+void Shell::GoBackOrForward(int offset) {
+ tab_contents_->controller().GoToOffset(offset);
+}
+
+void Shell::Reload() {
+ tab_contents_->controller().Reload(false);
+}
+
+void Shell::Stop() {
+ tab_contents_->Stop();
+}
+
+void Shell::UpdateNavigationControls() {
+ int current_index = tab_contents_->controller().GetCurrentEntryIndex();
+ int max_index = tab_contents_->controller().entry_count() - 1;
+
+ PlatformEnableUIControl(BACK_BUTTON, current_index > 0);
+ PlatformEnableUIControl(FORWARD_BUTTON, current_index < max_index);
+ PlatformEnableUIControl(STOP_BUTTON, true);//is_loading_);
+}
+
+gfx::NativeView Shell::GetContentView() {
+ if (!tab_contents_.get())
+ return NULL;
+ return tab_contents_->GetNativeView();
+}
+
+} // namespace content
diff --git a/content/shell/shell.h b/content/shell/shell.h
new file mode 100644
index 0000000..ac53ac5
--- /dev/null
+++ b/content/shell/shell.h
@@ -0,0 +1,90 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_SHELL_SHELL_H_
+#define CONTENT_SHELL_SHELL_H_
+
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/memory/scoped_ptr.h"
+#include "ui/gfx/native_widget_types.h"
+
+class GURL;
+class TabContents;
+
+namespace base {
+class StringPiece;
+}
+
+namespace content {
+
+class ShellBrowserContext;
+
+// This represents one window of the Content Shell, i.e. all the UI including
+// buttons and url bar, as well as the web content area.
+class Shell {
+ public:
+ ~Shell();
+
+ void LoadURL(const GURL& url);
+ void GoBackOrForward(int offset);
+ void Reload();
+ void Stop();
+ void UpdateNavigationControls();
+
+ // Do one time initialization at application startup.
+ static void PlatformInitialize();
+
+ // This is called indirectly by the modules that need access resources.
+ static base::StringPiece PlatformResourceProvider(int key);
+
+ static Shell* CreateNewWindow(ShellBrowserContext* browser_context);
+
+ private:
+ enum UIControl {
+ BACK_BUTTON,
+ FORWARD_BUTTON,
+ STOP_BUTTON
+ };
+
+ Shell();
+
+ // All the methods that begin with Platform need to be implemented by the
+ // platform specific Shell implementation.
+ // Called from the destructor to let each platform do any necessary cleanup.
+ void PlatformCleanUp();
+ // Creates the main window GUI.
+ void PlatformCreateWindow();
+ // Resizes the main window to the given dimensions.
+ void PlatformSizeTo(int width, int height);
+ // Resize the content area and GUI.
+ void PlatformResizeSubViews();
+ // Enable/disable a button.
+ void PlatformEnableUIControl(UIControl control, bool is_enabled);
+
+ gfx::NativeView GetContentView();
+
+#if defined(OS_WIN)
+ static ATOM RegisterWindowClass();
+ static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
+ static LRESULT CALLBACK EditWndProc(HWND, UINT, WPARAM, LPARAM);
+#endif
+
+ scoped_ptr<TabContents> tab_contents_;
+
+ gfx::NativeWindow main_window_;
+ gfx::NativeEditView edit_window_;
+
+#if defined(OS_WIN)
+ WNDPROC default_edit_wnd_proc_;
+ static HINSTANCE instance_handle_;
+#endif
+
+ static int shell_count_;
+};
+
+} // namespace content
+
+#endif // CONTENT_SHELL_SHELL_H_
diff --git a/content/shell/shell.rc b/content/shell/shell.rc
new file mode 100644
index 0000000..6d34fb8
--- /dev/null
+++ b/content/shell/shell.rc
@@ -0,0 +1,70 @@
+//Microsoft Visual C++ generated resource script.
+//
+#include "shell/resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+LANGUAGE 9, 1
+#pragma code_page(1252)
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDC_CONTENTSHELL MENU
+BEGIN
+ POPUP "&File"
+ BEGIN
+ MENUITEM "E&xit", IDM_EXIT
+ END
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+1 TEXTINCLUDE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+ "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""windows.h""\r\n"
+ "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
diff --git a/content/shell/shell_browser_main.cc b/content/shell/shell_browser_main.cc
index ed86f3b..dabfa13 100644
--- a/content/shell/shell_browser_main.cc
+++ b/content/shell/shell_browser_main.cc
@@ -9,11 +9,11 @@
#include "base/threading/thread_restrictions.h"
#include "content/browser/browser_process_sub_thread.h"
#include "content/browser/renderer_host/resource_dispatcher_host.h"
-#include "content/browser/tab_contents/tab_contents.h"
-#include "content/browser/tab_contents/navigation_controller.h"
#include "content/common/page_transition_types.h"
+#include "content/shell/shell.h"
#include "content/shell/shell_browser_context.h"
#include "content/shell/shell_content_browser_client.h"
+#include "net/base/net_module.h"
#include "ui/base/clipboard/clipboard.h"
namespace content {
@@ -61,17 +61,10 @@ void ShellBrowserMainParts::PreMainMessageLoopRun() {
browser_context_.reset(new ShellBrowserContext(this));
- tab_contents_.reset(new TabContents(
- browser_context_.get(),
- NULL,
- MSG_ROUTING_NONE,
- NULL,
- NULL));
- tab_contents_->controller().LoadURL(
- GURL("http://www.google.com"),
- GURL(),
- PageTransition::TYPED,
- std::string());
+ Shell::PlatformInitialize();
+ net::NetModule::SetResourceProvider(Shell::PlatformResourceProvider);
+
+ Shell::CreateNewWindow(browser_context_.get());
}
ResourceDispatcherHost* ShellBrowserMainParts::GetResourceDispatcherHost() {
@@ -79,6 +72,7 @@ ResourceDispatcherHost* ShellBrowserMainParts::GetResourceDispatcherHost() {
ResourceQueue::DelegateSet resource_queue_delegates;
resource_dispatcher_host_.reset(
new ResourceDispatcherHost(resource_queue_delegates));
+ resource_dispatcher_host_->Initialize();
}
return resource_dispatcher_host_.get();
}
diff --git a/content/shell/shell_browser_main.h b/content/shell/shell_browser_main.h
index fc1bb21..5d46e1f 100644
--- a/content/shell/shell_browser_main.h
+++ b/content/shell/shell_browser_main.h
@@ -10,7 +10,6 @@
#include "content/browser/browser_main.h"
class ResourceDispatcherHost;
-class TabContents;
namespace base {
class Thread;
@@ -39,7 +38,6 @@ class ShellBrowserMainParts : public BrowserMainParts {
private:
scoped_ptr<ShellBrowserContext> browser_context_;
- scoped_ptr<TabContents> tab_contents_;
scoped_ptr<ResourceDispatcherHost> resource_dispatcher_host_;
scoped_ptr<ui::Clipboard> clipboard_;
diff --git a/content/shell/shell_gtk.cc b/content/shell/shell_gtk.cc
new file mode 100644
index 0000000..23084fa
--- /dev/null
+++ b/content/shell/shell_gtk.cc
@@ -0,0 +1,41 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/shell/shell.h"
+
+#include "base/logging.h"
+#include "base/string_piece.h"
+
+namespace content {
+
+void Shell::PlatformInitialize() {
+ NOTIMPLEMENTED();
+}
+
+base::StringPiece Shell::PlatformResourceProvider(int key) {
+ NOTIMPLEMENTED();
+ return base::StringPiece();
+}
+
+void Shell::PlatformCleanUp() {
+ NOTIMPLEMENTED();
+}
+
+void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) {
+ NOTIMPLEMENTED();
+}
+
+void Shell::PlatformCreateWindow() {
+ NOTIMPLEMENTED();
+}
+
+void Shell::PlatformSizeTo(int width, int height) {
+ NOTIMPLEMENTED();
+}
+
+void Shell::PlatformResizeSubViews() {
+ NOTIMPLEMENTED();
+}
+
+} // namespace content
diff --git a/content/shell/shell_mac.mm b/content/shell/shell_mac.mm
new file mode 100644
index 0000000..23084fa
--- /dev/null
+++ b/content/shell/shell_mac.mm
@@ -0,0 +1,41 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/shell/shell.h"
+
+#include "base/logging.h"
+#include "base/string_piece.h"
+
+namespace content {
+
+void Shell::PlatformInitialize() {
+ NOTIMPLEMENTED();
+}
+
+base::StringPiece Shell::PlatformResourceProvider(int key) {
+ NOTIMPLEMENTED();
+ return base::StringPiece();
+}
+
+void Shell::PlatformCleanUp() {
+ NOTIMPLEMENTED();
+}
+
+void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) {
+ NOTIMPLEMENTED();
+}
+
+void Shell::PlatformCreateWindow() {
+ NOTIMPLEMENTED();
+}
+
+void Shell::PlatformSizeTo(int width, int height) {
+ NOTIMPLEMENTED();
+}
+
+void Shell::PlatformResizeSubViews() {
+ NOTIMPLEMENTED();
+}
+
+} // namespace content
diff --git a/content/shell/shell_win.cc b/content/shell/shell_win.cc
new file mode 100644
index 0000000..f2647c1
--- /dev/null
+++ b/content/shell/shell_win.cc
@@ -0,0 +1,252 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/shell/shell.h"
+
+#include <windows.h>
+#include <commctrl.h>
+
+#include "base/message_loop.h"
+#include "base/string_piece.h"
+#include "base/win/resource_util.h"
+#include "content/shell/resource.h"
+#include "googleurl/src/gurl.h"
+#include "grit/webkit_resources.h"
+#include "grit/webkit_chromium_resources.h"
+#include "net/base/net_module.h"
+#include "ui/base/win/hwnd_util.h"
+
+namespace {
+
+static const wchar_t kWindowTitle[] = L"Content Shell";
+static const wchar_t kWindowClass[] = L"CONTENT_SHELL";
+
+static const int kButtonWidth = 72;
+static const int kURLBarHeight = 24;
+
+static const int kMaxURLLength = 1024;
+
+static base::StringPiece GetRawDataResource(HMODULE module, int resource_id) {
+ void* data_ptr;
+ size_t data_size;
+ return base::win::GetDataResourceFromModule(module, resource_id, &data_ptr,
+ &data_size)
+ ? base::StringPiece(static_cast<char*>(data_ptr), data_size)
+ : base::StringPiece();
+}
+
+} // namespace
+
+namespace content {
+
+HINSTANCE Shell::instance_handle_;
+
+void Shell::PlatformInitialize() {
+ instance_handle_ = ::GetModuleHandle(NULL);
+
+ INITCOMMONCONTROLSEX InitCtrlEx;
+ InitCtrlEx.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ InitCtrlEx.dwICC = ICC_STANDARD_CLASSES;
+ InitCommonControlsEx(&InitCtrlEx);
+ RegisterWindowClass();
+}
+
+base::StringPiece Shell::PlatformResourceProvider(int key) {
+ return GetRawDataResource(::GetModuleHandle(NULL), key);
+}
+
+void Shell::PlatformCleanUp() {
+ // When the window is destroyed, tell the Edit field to forget about us,
+ // otherwise we will crash.
+ ui::SetWindowProc(edit_window_, default_edit_wnd_proc_);
+ ui::SetWindowUserData(edit_window_, NULL);
+}
+
+void Shell::PlatformEnableUIControl(UIControl control, bool is_enabled) {
+ int id;
+ switch (control) {
+ case BACK_BUTTON:
+ id = IDC_NAV_BACK;
+ break;
+ case FORWARD_BUTTON:
+ id = IDC_NAV_FORWARD;
+ break;
+ case STOP_BUTTON:
+ id = IDC_NAV_STOP;
+ break;
+ default:
+ NOTREACHED() << "Unknown UI control";
+ return;
+ }
+ EnableWindow(GetDlgItem(main_window_, id), is_enabled);
+}
+
+void Shell::PlatformCreateWindow() {
+ main_window_ = CreateWindow(kWindowClass, kWindowTitle,
+ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
+ CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,
+ NULL, NULL, instance_handle_, NULL);
+ ui::SetWindowUserData(main_window_, this);
+
+ HWND hwnd;
+ int x = 0;
+
+ hwnd = CreateWindow(L"BUTTON", L"Back",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ,
+ x, 0, kButtonWidth, kURLBarHeight,
+ main_window_, (HMENU) IDC_NAV_BACK, instance_handle_, 0);
+ x += kButtonWidth;
+
+ hwnd = CreateWindow(L"BUTTON", L"Forward",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ,
+ x, 0, kButtonWidth, kURLBarHeight,
+ main_window_, (HMENU) IDC_NAV_FORWARD, instance_handle_,
+ 0);
+ x += kButtonWidth;
+
+ hwnd = CreateWindow(L"BUTTON", L"Reload",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ,
+ x, 0, kButtonWidth, kURLBarHeight,
+ main_window_, (HMENU) IDC_NAV_RELOAD, instance_handle_,
+ 0);
+ x += kButtonWidth;
+
+ hwnd = CreateWindow(L"BUTTON", L"Stop",
+ WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON ,
+ x, 0, kButtonWidth, kURLBarHeight,
+ main_window_, (HMENU) IDC_NAV_STOP, instance_handle_, 0);
+ x += kButtonWidth;
+
+ // This control is positioned by PlatformResizeSubViews.
+ edit_window_ = CreateWindow(L"EDIT", 0,
+ WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT |
+ ES_AUTOVSCROLL | ES_AUTOHSCROLL,
+ x, 0, 0, 0, main_window_, 0, instance_handle_, 0);
+
+ default_edit_wnd_proc_ = ui::SetWindowProc(edit_window_, Shell::EditWndProc);
+ ui::SetWindowUserData(edit_window_, this);
+
+ ShowWindow(main_window_, SW_SHOW);
+}
+
+void Shell::PlatformSizeTo(int width, int height) {
+ RECT rc, rw;
+ GetClientRect(main_window_, &rc);
+ GetWindowRect(main_window_, &rw);
+
+ int client_width = rc.right - rc.left;
+ int window_width = rw.right - rw.left;
+ window_width = (window_width - client_width) + width;
+
+ int client_height = rc.bottom - rc.top;
+ int window_height = rw.bottom - rw.top;
+ window_height = (window_height - client_height) + height;
+
+ // Add space for the url bar.
+ window_height += kURLBarHeight;
+
+ SetWindowPos(main_window_, NULL, 0, 0, window_width, window_height,
+ SWP_NOMOVE | SWP_NOZORDER);
+}
+
+void Shell::PlatformResizeSubViews() {
+ RECT rc;
+ GetClientRect(main_window_, &rc);
+
+ int x = kButtonWidth * 4;
+ MoveWindow(edit_window_, x, 0, rc.right - x, kURLBarHeight, TRUE);
+
+ MoveWindow(GetContentView(), 0, kURLBarHeight, rc.right,
+ rc.bottom - kURLBarHeight, TRUE);
+}
+
+ATOM Shell::RegisterWindowClass() {
+ WNDCLASSEX wcex = {
+ sizeof(WNDCLASSEX),
+ CS_HREDRAW | CS_VREDRAW,
+ Shell::WndProc,
+ 0,
+ 0,
+ instance_handle_,
+ NULL,
+ LoadCursor(NULL, IDC_ARROW),
+ 0,
+ MAKEINTRESOURCE(IDC_CONTENTSHELL),
+ kWindowClass,
+ NULL,
+ };
+ return RegisterClassEx(&wcex);
+}
+
+LRESULT CALLBACK Shell::WndProc(HWND hwnd, UINT message, WPARAM wParam,
+ LPARAM lParam) {
+ Shell* shell = static_cast<Shell*>(ui::GetWindowUserData(hwnd));
+
+ switch (message) {
+ case WM_COMMAND: {
+ int id = LOWORD(wParam);
+ switch (id) {
+ case IDM_EXIT:
+ DestroyWindow(hwnd);
+ break;
+ case IDC_NAV_BACK:
+ shell->GoBackOrForward(-1);
+ break;
+ case IDC_NAV_FORWARD:
+ shell->GoBackOrForward(1);
+ break;
+ case IDC_NAV_RELOAD:
+ case IDC_NAV_STOP: {
+ if (id == IDC_NAV_RELOAD) {
+ shell->Reload();
+ } else {
+ shell->Stop();
+ }
+ break;
+ }
+ break;
+ }
+ break;
+ }
+ case WM_DESTROY: {
+ delete shell;
+ if (!shell_count_)
+ MessageLoop::current()->Quit();
+ return 0;
+ }
+
+ case WM_SIZE: {
+ if (shell->GetContentView())
+ shell->PlatformResizeSubViews();
+ return 0;
+ }
+ }
+
+ return DefWindowProc(hwnd, message, wParam, lParam);
+}
+
+LRESULT CALLBACK Shell::EditWndProc(HWND hwnd, UINT message,
+ WPARAM wParam, LPARAM lParam) {
+ Shell* shell = static_cast<Shell*>(ui::GetWindowUserData(hwnd));
+
+ switch (message) {
+ case WM_CHAR:
+ if (wParam == VK_RETURN) {
+ wchar_t str[kMaxURLLength + 1]; // Leave room for adding a NULL;
+ *(str) = kMaxURLLength;
+ LRESULT str_len = SendMessage(hwnd, EM_GETLINE, 0, (LPARAM)str);
+ if (str_len > 0) {
+ str[str_len] = 0; // EM_GETLINE doesn't NULL terminate.
+ shell->LoadURL(GURL(str));
+ }
+
+ return 0;
+ }
+ }
+
+ return CallWindowProc(shell->default_edit_wnd_proc_, hwnd, message, wParam,
+ lParam);
+}
+
+} // namespace content