mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Update all files to use Windows CRLF (\r\n) line endings (issue #45).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@33 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
// Copyright (c) 2008-2009 The Chromium Embedded Framework 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 "stdafx.h"
|
||||
#include "cefclient.h"
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
#define MAX_LOADSTRING 100
|
||||
#define MAX_URL_LENGTH 255
|
||||
#define BUTTON_WIDTH 72
|
||||
#define BUTTON_WIDTH 72
|
||||
#define URLBAR_HEIGHT 24
|
||||
|
||||
// Define this value to run CEF with messages processed using the current
|
||||
@ -135,24 +135,24 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
|
||||
|
||||
// Register a V8 extension with the below JavaScript code that calls native
|
||||
// methods implemented in ClientV8ExtensionHandler.
|
||||
std::wstring code = L"var cef;"
|
||||
L"if (!cef)"
|
||||
L" cef = {};"
|
||||
L"if (!cef.test)"
|
||||
L" cef.test = {};"
|
||||
L"(function() {"
|
||||
L" cef.test.__defineGetter__('test_param', function() {"
|
||||
L" native function GetTestParam();"
|
||||
L" return GetTestParam();"
|
||||
L" });"
|
||||
L" cef.test.__defineSetter__('test_param', function(b) {"
|
||||
L" native function SetTestParam();"
|
||||
L" if(b) SetTestParam(b);"
|
||||
L" });"
|
||||
L" cef.test.test_object = function() {"
|
||||
L" native function GetTestObject();"
|
||||
L" return GetTestObject();"
|
||||
L" };"
|
||||
std::wstring code = L"var cef;"
|
||||
L"if (!cef)"
|
||||
L" cef = {};"
|
||||
L"if (!cef.test)"
|
||||
L" cef.test = {};"
|
||||
L"(function() {"
|
||||
L" cef.test.__defineGetter__('test_param', function() {"
|
||||
L" native function GetTestParam();"
|
||||
L" return GetTestParam();"
|
||||
L" });"
|
||||
L" cef.test.__defineSetter__('test_param', function(b) {"
|
||||
L" native function SetTestParam();"
|
||||
L" if(b) SetTestParam(b);"
|
||||
L" });"
|
||||
L" cef.test.test_object = function() {"
|
||||
L" native function GetTestObject();"
|
||||
L" return GetTestObject();"
|
||||
L" };"
|
||||
L"})();";
|
||||
CefRegisterExtension(L"v8/test", code, new ClientV8ExtensionHandler());
|
||||
|
||||
@ -704,33 +704,33 @@ public:
|
||||
// or RV_HANDLED if you displayed a custom alert.
|
||||
virtual RetVal HandleJSAlert(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& message)
|
||||
{
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
const std::wstring& message)
|
||||
{
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Run a JS confirm request. Return RV_CONTINUE to display the default alert
|
||||
// or RV_HANDLED if you displayed a custom alert. If you handled the alert
|
||||
// set |retval| to true if the user accepted the confirmation.
|
||||
virtual RetVal HandleJSConfirm(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& message, bool& retval)
|
||||
{
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
const std::wstring& message, bool& retval)
|
||||
{
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Run a JS prompt request. Return RV_CONTINUE to display the default prompt
|
||||
// or RV_HANDLED if you displayed a custom prompt. If you handled the prompt
|
||||
// set |retval| to true if the user accepted the prompt and request and
|
||||
// |result| to the resulting value.
|
||||
virtual RetVal HandleJSPrompt(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const std::wstring& message,
|
||||
const std::wstring& defaultValue,
|
||||
bool& retval,
|
||||
const std::wstring& message,
|
||||
const std::wstring& defaultValue,
|
||||
bool& retval,
|
||||
std::wstring& result)
|
||||
{
|
||||
return RV_CONTINUE;
|
||||
return RV_CONTINUE;
|
||||
}
|
||||
|
||||
// Called just before a window is closed. The return value is currently
|
||||
@ -863,25 +863,25 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
if(hWnd == editWnd)
|
||||
{
|
||||
// Callback for the edit window
|
||||
switch (message)
|
||||
{
|
||||
case WM_CHAR:
|
||||
if (wParam == VK_RETURN && handler.get())
|
||||
{
|
||||
// When the user hits the enter key load the URL
|
||||
CefRefPtr<CefBrowser> browser = handler->GetBrowser();
|
||||
wchar_t strPtr[MAX_URL_LENGTH] = {0};
|
||||
*((LPWORD)strPtr) = MAX_URL_LENGTH;
|
||||
LRESULT strLen = SendMessage(hWnd, EM_GETLINE, 0, (LPARAM)strPtr);
|
||||
if (strLen > 0) {
|
||||
strPtr[strLen] = 0;
|
||||
browser->GetMainFrame()->LoadURL(strPtr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case WM_CHAR:
|
||||
if (wParam == VK_RETURN && handler.get())
|
||||
{
|
||||
// When the user hits the enter key load the URL
|
||||
CefRefPtr<CefBrowser> browser = handler->GetBrowser();
|
||||
wchar_t strPtr[MAX_URL_LENGTH] = {0};
|
||||
*((LPWORD)strPtr) = MAX_URL_LENGTH;
|
||||
LRESULT strLen = SendMessage(hWnd, EM_GETLINE, 0, (LPARAM)strPtr);
|
||||
if (strLen > 0) {
|
||||
strPtr[strLen] = 0;
|
||||
browser->GetMainFrame()->LoadURL(strPtr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return (LRESULT)CallWindowProc(editWndOldProc, hWnd, message, wParam, lParam);
|
||||
}
|
||||
else
|
||||
@ -897,46 +897,46 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
// Create the child windows used for navigation
|
||||
RECT rect;
|
||||
int x = 0;
|
||||
|
||||
int x = 0;
|
||||
|
||||
GetClientRect(hWnd, &rect);
|
||||
|
||||
backWnd = CreateWindow(L"BUTTON", L"Back",
|
||||
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
||||
| WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
|
||||
hWnd, (HMENU) IDC_NAV_BACK, hInst, 0);
|
||||
x += BUTTON_WIDTH;
|
||||
|
||||
forwardWnd = CreateWindow(L"BUTTON", L"Forward",
|
||||
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
||||
| WS_DISABLED, x, 0, BUTTON_WIDTH,
|
||||
URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_FORWARD,
|
||||
hInst, 0);
|
||||
x += BUTTON_WIDTH;
|
||||
|
||||
reloadWnd = CreateWindow(L"BUTTON", L"Reload",
|
||||
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
||||
| WS_DISABLED, x, 0, BUTTON_WIDTH,
|
||||
URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_RELOAD,
|
||||
hInst, 0);
|
||||
x += BUTTON_WIDTH;
|
||||
|
||||
stopWnd = CreateWindow(L"BUTTON", L"Stop",
|
||||
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
||||
| WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
|
||||
hWnd, (HMENU) IDC_NAV_STOP, hInst, 0);
|
||||
x += BUTTON_WIDTH;
|
||||
|
||||
editWnd = CreateWindow(L"EDIT", 0,
|
||||
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT |
|
||||
ES_AUTOVSCROLL | ES_AUTOHSCROLL| WS_DISABLED,
|
||||
x, 0, rect.right - BUTTON_WIDTH * 4,
|
||||
URLBAR_HEIGHT, hWnd, 0, hInst, 0);
|
||||
|
||||
// Assign the edit window's WNDPROC to this function so that we can
|
||||
// capture the enter key
|
||||
editWndOldProc =
|
||||
reinterpret_cast<WNDPROC>(GetWindowLongPtr(editWnd, GWLP_WNDPROC));
|
||||
|
||||
backWnd = CreateWindow(L"BUTTON", L"Back",
|
||||
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
||||
| WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
|
||||
hWnd, (HMENU) IDC_NAV_BACK, hInst, 0);
|
||||
x += BUTTON_WIDTH;
|
||||
|
||||
forwardWnd = CreateWindow(L"BUTTON", L"Forward",
|
||||
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
||||
| WS_DISABLED, x, 0, BUTTON_WIDTH,
|
||||
URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_FORWARD,
|
||||
hInst, 0);
|
||||
x += BUTTON_WIDTH;
|
||||
|
||||
reloadWnd = CreateWindow(L"BUTTON", L"Reload",
|
||||
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
||||
| WS_DISABLED, x, 0, BUTTON_WIDTH,
|
||||
URLBAR_HEIGHT, hWnd, (HMENU) IDC_NAV_RELOAD,
|
||||
hInst, 0);
|
||||
x += BUTTON_WIDTH;
|
||||
|
||||
stopWnd = CreateWindow(L"BUTTON", L"Stop",
|
||||
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON
|
||||
| WS_DISABLED, x, 0, BUTTON_WIDTH, URLBAR_HEIGHT,
|
||||
hWnd, (HMENU) IDC_NAV_STOP, hInst, 0);
|
||||
x += BUTTON_WIDTH;
|
||||
|
||||
editWnd = CreateWindow(L"EDIT", 0,
|
||||
WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT |
|
||||
ES_AUTOVSCROLL | ES_AUTOHSCROLL| WS_DISABLED,
|
||||
x, 0, rect.right - BUTTON_WIDTH * 4,
|
||||
URLBAR_HEIGHT, hWnd, 0, hInst, 0);
|
||||
|
||||
// Assign the edit window's WNDPROC to this function so that we can
|
||||
// capture the enter key
|
||||
editWndOldProc =
|
||||
reinterpret_cast<WNDPROC>(GetWindowLongPtr(editWnd, GWLP_WNDPROC));
|
||||
SetWindowLongPtr(editWnd, GWLP_WNDPROC,
|
||||
reinterpret_cast<LONG_PTR>(WndProc));
|
||||
handler->SetEditHwnd(editWnd);
|
||||
@ -1148,14 +1148,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
if(handler.get() && handler->GetBrowserHwnd())
|
||||
{
|
||||
// Dont erase the background if the browser window has been loaded
|
||||
// (this avoids flashing)
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case WM_ERASEBKGND:
|
||||
if(handler.get() && handler->GetBrowserHwnd())
|
||||
{
|
||||
// Dont erase the background if the browser window has been loaded
|
||||
// (this avoids flashing)
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
// The frame window has exited
|
||||
|
Reference in New Issue
Block a user