mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-16 20:20:51 +01:00
cefclient: Move all remaining files to the client
namespace (issue #1500).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1989 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
87c41bf99f
commit
68cb4b6213
@ -9,6 +9,8 @@
|
||||
|
||||
#include "include/wrapper/cef_helpers.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
BytesWriteHandler::BytesWriteHandler(size_t grow)
|
||||
: grow_(grow),
|
||||
datasize_(grow),
|
||||
@ -92,3 +94,5 @@ size_t BytesWriteHandler::Grow(size_t size) {
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "include/base/cef_lock.h"
|
||||
#include "include/cef_stream.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
class BytesWriteHandler : public CefWriteHandler {
|
||||
public:
|
||||
explicit BytesWriteHandler(size_t grow);
|
||||
@ -36,4 +38,6 @@ class BytesWriteHandler : public CefWriteHandler {
|
||||
IMPLEMENT_REFCOUNTING(BytesWriteHandler);
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_BYTES_WRITE_HANDLER_H_
|
||||
|
@ -30,18 +30,21 @@
|
||||
#include "cefclient/resource.h"
|
||||
#include "cefclient/test_runner.h"
|
||||
|
||||
namespace client {
|
||||
namespace {
|
||||
|
||||
// The global ClientHandler reference.
|
||||
CefRefPtr<ClientHandler> g_handler;
|
||||
|
||||
namespace {
|
||||
|
||||
// Height of the buttons at the top of the GTK window.
|
||||
int g_toolbar_height = 0;
|
||||
|
||||
// Height of the integrated menu bar (if any) at the top of the GTK window.
|
||||
int g_menubar_height = 0;
|
||||
|
||||
class MainBrowserProvider : public client::OSRBrowserProvider {
|
||||
|
||||
// Used by off-screen rendering to find the associated CefBrowser.
|
||||
class MainBrowserProvider : public OSRBrowserProvider {
|
||||
virtual CefRefPtr<CefBrowser> GetBrowser() {
|
||||
if (g_handler.get())
|
||||
return g_handler->GetBrowser();
|
||||
@ -50,6 +53,7 @@ class MainBrowserProvider : public client::OSRBrowserProvider {
|
||||
}
|
||||
} g_main_browser_provider;
|
||||
|
||||
|
||||
int XErrorHandlerImpl(Display *display, XErrorEvent *event) {
|
||||
LOG(WARNING)
|
||||
<< "X error received: "
|
||||
@ -89,7 +93,7 @@ gboolean delete_event(GtkWidget* widget, GdkEvent* event,
|
||||
}
|
||||
|
||||
void TerminationSignalHandler(int signatl) {
|
||||
client::MainMessageLoop::Get()->Quit();
|
||||
MainMessageLoop::Get()->Quit();
|
||||
}
|
||||
|
||||
void VboxSizeAllocated(GtkWidget* widget,
|
||||
@ -225,10 +229,8 @@ gboolean WindowConfigure(GtkWindow* window,
|
||||
|
||||
// Callback for Tests menu items.
|
||||
gboolean MenuItemActivated(GtkWidget* widget, gpointer data) {
|
||||
if (g_handler.get() && g_handler->GetBrowserId()) {
|
||||
client::test_runner::RunTest(g_handler->GetBrowser(),
|
||||
GPOINTER_TO_INT(data));
|
||||
}
|
||||
if (g_handler.get() && g_handler->GetBrowserId())
|
||||
test_runner::RunTest(g_handler->GetBrowser(), GPOINTER_TO_INT(data));
|
||||
|
||||
return FALSE; // Don't stop this message.
|
||||
}
|
||||
@ -317,9 +319,7 @@ GtkWidget* CreateMenuBar() {
|
||||
return menu_bar;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int RunMain(int argc, char* argv[]) {
|
||||
// Create a copy of |argv| on Linux because Chromium mangles the value
|
||||
// internally (see issue #620).
|
||||
CefScopedArgArray scoped_arg_array(argc, argv);
|
||||
@ -334,8 +334,7 @@ int main(int argc, char* argv[]) {
|
||||
return exit_code;
|
||||
|
||||
// Create the main context object.
|
||||
scoped_ptr<client::MainContextImpl> context(
|
||||
new client::MainContextImpl(argc, argv));
|
||||
scoped_ptr<MainContextImpl> context(new MainContextImpl(argc, argv));
|
||||
|
||||
CefSettings settings;
|
||||
|
||||
@ -348,8 +347,7 @@ int main(int argc, char* argv[]) {
|
||||
XSetIOErrorHandler(XIOErrorHandlerImpl);
|
||||
|
||||
// Create the main message loop object.
|
||||
scoped_ptr<client::MainMessageLoop> message_loop(
|
||||
new client::MainMessageLoopStd);
|
||||
scoped_ptr<MainMessageLoop> message_loop(new MainMessageLoopStd);
|
||||
|
||||
// Initialize CEF.
|
||||
CefInitialize(main_args, settings, app.get(), NULL);
|
||||
@ -362,7 +360,7 @@ int main(int argc, char* argv[]) {
|
||||
gtk_gl_init(&argc, &argv_copy);
|
||||
|
||||
// Register scheme handlers.
|
||||
client::test_runner::RegisterSchemeHandlers();
|
||||
test_runner::RegisterSchemeHandlers();
|
||||
|
||||
GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
|
||||
@ -443,16 +441,16 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
if (command_line->HasSwitch(cefclient::kOffScreenRenderingEnabled)) {
|
||||
if (command_line->HasSwitch(switches::kOffScreenRenderingEnabled)) {
|
||||
const bool transparent =
|
||||
command_line->HasSwitch(cefclient::kTransparentPaintingEnabled);
|
||||
command_line->HasSwitch(switches::kTransparentPaintingEnabled);
|
||||
const bool show_update_rect =
|
||||
command_line->HasSwitch(cefclient::kShowUpdateRect);
|
||||
command_line->HasSwitch(switches::kShowUpdateRect);
|
||||
|
||||
// Create the GTKGL surface.
|
||||
CefRefPtr<client::OSRWindow> osr_window =
|
||||
client::OSRWindow::Create(&g_main_browser_provider, transparent,
|
||||
show_update_rect, vbox);
|
||||
CefRefPtr<OSRWindow> osr_window =
|
||||
OSRWindow::Create(&g_main_browser_provider, transparent,
|
||||
show_update_rect, vbox);
|
||||
|
||||
// Show the GTK window.
|
||||
gtk_widget_show_all(GTK_WIDGET(window));
|
||||
@ -493,3 +491,12 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace client
|
||||
|
||||
|
||||
// Program entry point function.
|
||||
int main(int argc, char* argv[]) {
|
||||
return client::RunMain(argc, argv);
|
||||
}
|
||||
|
@ -19,9 +19,12 @@
|
||||
#include "cefclient/resource_util.h"
|
||||
#include "cefclient/test_runner.h"
|
||||
|
||||
// The global ClientHandler reference.
|
||||
CefRefPtr<ClientHandler> g_handler;
|
||||
namespace {
|
||||
|
||||
// The global ClientHandler reference.
|
||||
CefRefPtr<client::ClientHandler> g_handler;
|
||||
|
||||
// Used by off-screen rendering to find the associated CefBrowser.
|
||||
class MainBrowserProvider : public client::OSRBrowserProvider {
|
||||
virtual CefRefPtr<CefBrowser> GetBrowser() {
|
||||
if (g_handler.get())
|
||||
@ -31,6 +34,7 @@ class MainBrowserProvider : public client::OSRBrowserProvider {
|
||||
}
|
||||
} g_main_browser_provider;
|
||||
|
||||
|
||||
// Sizes for URL bar layout
|
||||
#define BUTTON_HEIGHT 22
|
||||
#define BUTTON_WIDTH 72
|
||||
@ -41,6 +45,26 @@ class MainBrowserProvider : public client::OSRBrowserProvider {
|
||||
const int kWindowWidth = 800;
|
||||
const int kWindowHeight = 600;
|
||||
|
||||
|
||||
NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
||||
NSButton* button = [[[NSButton alloc] initWithFrame:*rect] autorelease];
|
||||
[button setTitle:title];
|
||||
[button setBezelStyle:NSSmallSquareBezelStyle];
|
||||
[button setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)];
|
||||
[parent addSubview:button];
|
||||
rect->origin.x += BUTTON_WIDTH;
|
||||
return button;
|
||||
}
|
||||
|
||||
void AddMenuItem(NSMenu *menu, NSString* label, int idval) {
|
||||
NSMenuItem* item = [menu addItemWithTitle:label
|
||||
action:@selector(menuItemSelected:)
|
||||
keyEquivalent:@""];
|
||||
[item setTag:idval];
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Receives notifications from the application. Will delete itself when done.
|
||||
@interface ClientAppDelegate : NSObject
|
||||
- (void)createApplication:(id)object;
|
||||
@ -209,7 +233,7 @@ const int kWindowHeight = 600;
|
||||
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
|
||||
if (browser.get()) {
|
||||
if (CefCommandLine::GetGlobalCommandLine()->HasSwitch(
|
||||
cefclient::kOffScreenRenderingEnabled)) {
|
||||
client::switches::kOffScreenRenderingEnabled)) {
|
||||
browser->GetHost()->SendFocusEvent(true);
|
||||
} else {
|
||||
browser->GetHost()->SetFocus(true);
|
||||
@ -224,7 +248,7 @@ const int kWindowHeight = 600;
|
||||
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
|
||||
if (browser.get()) {
|
||||
if (CefCommandLine::GetGlobalCommandLine()->HasSwitch(
|
||||
cefclient::kOffScreenRenderingEnabled)) {
|
||||
client::switches::kOffScreenRenderingEnabled)) {
|
||||
browser->GetHost()->SendFocusEvent(false);
|
||||
} else {
|
||||
browser->GetHost()->SetFocus(false);
|
||||
@ -313,23 +337,6 @@ const int kWindowHeight = 600;
|
||||
@end
|
||||
|
||||
|
||||
NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) {
|
||||
NSButton* button = [[[NSButton alloc] initWithFrame:*rect] autorelease];
|
||||
[button setTitle:title];
|
||||
[button setBezelStyle:NSSmallSquareBezelStyle];
|
||||
[button setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)];
|
||||
[parent addSubview:button];
|
||||
rect->origin.x += BUTTON_WIDTH;
|
||||
return button;
|
||||
}
|
||||
|
||||
void AddMenuItem(NSMenu *menu, NSString* label, int idval) {
|
||||
NSMenuItem* item = [menu addItemWithTitle:label
|
||||
action:@selector(menuItemSelected:)
|
||||
keyEquivalent:@""];
|
||||
[item setTag:idval];
|
||||
}
|
||||
|
||||
@implementation ClientAppDelegate
|
||||
|
||||
// Create the application on the UI thread.
|
||||
@ -424,7 +431,7 @@ void AddMenuItem(NSMenu *menu, NSString* label, int idval) {
|
||||
[[editWnd cell] setScrollable:YES];
|
||||
|
||||
// Create the handler.
|
||||
g_handler = new ClientHandler();
|
||||
g_handler = new client::ClientHandler();
|
||||
g_handler->SetMainWindowHandle(contentView);
|
||||
g_handler->SetEditWindowHandle(editWnd);
|
||||
|
||||
@ -437,11 +444,11 @@ void AddMenuItem(NSMenu *menu, NSString* label, int idval) {
|
||||
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
if (command_line->HasSwitch(cefclient::kOffScreenRenderingEnabled)) {
|
||||
if (command_line->HasSwitch(client::switches::kOffScreenRenderingEnabled)) {
|
||||
const bool transparent =
|
||||
command_line->HasSwitch(cefclient::kTransparentPaintingEnabled);
|
||||
command_line->HasSwitch(client::switches::kTransparentPaintingEnabled);
|
||||
const bool show_update_rect =
|
||||
command_line->HasSwitch(cefclient::kShowUpdateRect);
|
||||
command_line->HasSwitch(client::switches::kShowUpdateRect);
|
||||
|
||||
CefRefPtr<client::OSRWindow> osr_window =
|
||||
client::OSRWindow::Create(&g_main_browser_provider, transparent,
|
||||
@ -486,7 +493,10 @@ void AddMenuItem(NSMenu *menu, NSString* label, int idval) {
|
||||
@end
|
||||
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
namespace client {
|
||||
namespace {
|
||||
|
||||
int RunMain(int argc, char* argv[]) {
|
||||
CefMainArgs main_args(argc, argv);
|
||||
CefRefPtr<ClientApp> app(new ClientApp);
|
||||
|
||||
@ -497,8 +507,7 @@ int main(int argc, char* argv[]) {
|
||||
[ClientApplication sharedApplication];
|
||||
|
||||
// Create the main context object.
|
||||
scoped_ptr<client::MainContextImpl> context(
|
||||
new client::MainContextImpl(argc, argv));
|
||||
scoped_ptr<MainContextImpl> context(new MainContextImpl(argc, argv));
|
||||
|
||||
CefSettings settings;
|
||||
|
||||
@ -506,14 +515,13 @@ int main(int argc, char* argv[]) {
|
||||
context->PopulateSettings(&settings);
|
||||
|
||||
// Create the main message loop object.
|
||||
scoped_ptr<client::MainMessageLoop> message_loop(
|
||||
new client::MainMessageLoopStd);
|
||||
scoped_ptr<MainMessageLoop> message_loop(new MainMessageLoopStd);
|
||||
|
||||
// Initialize CEF.
|
||||
CefInitialize(main_args, settings, app.get(), NULL);
|
||||
|
||||
// Register scheme handlers.
|
||||
client::test_runner::RegisterSchemeHandlers();
|
||||
test_runner::RegisterSchemeHandlers();
|
||||
|
||||
// Create the application delegate and window.
|
||||
NSObject* delegate = [[ClientAppDelegate alloc] init];
|
||||
@ -536,3 +544,12 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace client
|
||||
|
||||
|
||||
// Program entry point function.
|
||||
int main(int argc, char* argv[]) {
|
||||
return client::RunMain(argc, argv);
|
||||
}
|
||||
|
@ -40,6 +40,8 @@
|
||||
#pragma comment(lib, "cef_sandbox.lib")
|
||||
#endif
|
||||
|
||||
namespace client {
|
||||
namespace {
|
||||
|
||||
#define MAX_LOADSTRING 100
|
||||
#define MAX_URL_LENGTH 255
|
||||
@ -54,17 +56,18 @@ TCHAR szOSRWindowClass[MAX_LOADSTRING]; // the OSR window class name
|
||||
UINT uFindMsg; // Message identifier for find events.
|
||||
HWND hFindDlg = NULL; // Handle for the find dialog.
|
||||
|
||||
// Forward declarations of functions included in this code module:
|
||||
ATOM MyRegisterClass(HINSTANCE hInstance);
|
||||
BOOL InitInstance(HINSTANCE, int);
|
||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
LRESULT CALLBACK FindProc(HWND, UINT, WPARAM, LPARAM);
|
||||
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
||||
// Forward declarations of functions included in this code module.
|
||||
ATOM RegisterMainClass(HINSTANCE hInstance);
|
||||
BOOL CreateMainWindow(HINSTANCE, int);
|
||||
LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
LRESULT CALLBACK FindWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
INT_PTR CALLBACK AboutWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
// The global ClientHandler reference.
|
||||
CefRefPtr<ClientHandler> g_handler;
|
||||
|
||||
class MainBrowserProvider : public client::OSRBrowserProvider {
|
||||
// Used by off-screen rendering to find the associated CefBrowser.
|
||||
class MainBrowserProvider : public OSRBrowserProvider {
|
||||
virtual CefRefPtr<CefBrowser> GetBrowser() {
|
||||
if (g_handler.get())
|
||||
return g_handler->GetBrowser();
|
||||
@ -73,14 +76,8 @@ class MainBrowserProvider : public client::OSRBrowserProvider {
|
||||
}
|
||||
} g_main_browser_provider;
|
||||
|
||||
// Program entry point function.
|
||||
int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPTSTR lpCmdLine,
|
||||
int nCmdShow) {
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
int RunMain(HINSTANCE hInstance, int nCmdShow) {
|
||||
void* sandbox_info = NULL;
|
||||
|
||||
#if defined(CEF_USE_SANDBOX)
|
||||
@ -99,8 +96,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||
return exit_code;
|
||||
|
||||
// Create the main context object.
|
||||
scoped_ptr<client::MainContextImpl> context(
|
||||
new client::MainContextImpl(0, NULL));
|
||||
scoped_ptr<MainContextImpl> context(new MainContextImpl(0, NULL));
|
||||
|
||||
CefSettings settings;
|
||||
|
||||
@ -112,26 +108,26 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||
context->PopulateSettings(&settings);
|
||||
|
||||
// Create the main message loop object.
|
||||
scoped_ptr<client::MainMessageLoop> message_loop;
|
||||
scoped_ptr<MainMessageLoop> message_loop;
|
||||
if (settings.multi_threaded_message_loop)
|
||||
message_loop.reset(new client::MainMessageLoopMultithreadedWin);
|
||||
message_loop.reset(new MainMessageLoopMultithreadedWin);
|
||||
else
|
||||
message_loop.reset(new client::MainMessageLoopStd);
|
||||
message_loop.reset(new MainMessageLoopStd);
|
||||
|
||||
// Initialize CEF.
|
||||
CefInitialize(main_args, settings, app.get(), sandbox_info);
|
||||
|
||||
// Register scheme handlers.
|
||||
client::test_runner::RegisterSchemeHandlers();
|
||||
test_runner::RegisterSchemeHandlers();
|
||||
|
||||
// Initialize global strings
|
||||
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
||||
LoadString(hInstance, IDC_CEFCLIENT, szWindowClass, MAX_LOADSTRING);
|
||||
LoadString(hInstance, IDS_OSR_WIDGET_CLASS, szOSRWindowClass, MAX_LOADSTRING);
|
||||
MyRegisterClass(hInstance);
|
||||
RegisterMainClass(hInstance);
|
||||
|
||||
// Perform application initialization
|
||||
if (!InitInstance (hInstance, nCmdShow))
|
||||
if (!CreateMainWindow(hInstance, nCmdShow))
|
||||
return FALSE;
|
||||
|
||||
// Register the find event message.
|
||||
@ -150,26 +146,14 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// FUNCTION: MyRegisterClass()
|
||||
//
|
||||
// PURPOSE: Registers the window class.
|
||||
//
|
||||
// COMMENTS:
|
||||
//
|
||||
// This function and its usage are only necessary if you want this code
|
||||
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
|
||||
// function that was added to Windows 95. It is important to call this
|
||||
// function so that the application will get 'well formed' small icons
|
||||
// associated with it.
|
||||
//
|
||||
ATOM MyRegisterClass(HINSTANCE hInstance) {
|
||||
// Register the main window class.
|
||||
ATOM RegisterMainClass(HINSTANCE hInstance) {
|
||||
WNDCLASSEX wcex;
|
||||
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
|
||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcex.lpfnWndProc = WndProc;
|
||||
wcex.lpfnWndProc = MainWndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = hInstance;
|
||||
@ -183,17 +167,8 @@ ATOM MyRegisterClass(HINSTANCE hInstance) {
|
||||
return RegisterClassEx(&wcex);
|
||||
}
|
||||
|
||||
//
|
||||
// FUNCTION: InitInstance(HINSTANCE, int)
|
||||
//
|
||||
// PURPOSE: Saves instance handle and creates main window
|
||||
//
|
||||
// COMMENTS:
|
||||
//
|
||||
// In this function, we save the instance handle in a global variable and
|
||||
// create and display the main program window.
|
||||
//
|
||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) {
|
||||
// Create and show the main window.
|
||||
BOOL CreateMainWindow(HINSTANCE hInstance, int nCmdShow) {
|
||||
HWND hWnd;
|
||||
|
||||
hInst = hInstance; // Store instance handle in our global variable
|
||||
@ -223,10 +198,10 @@ static void SetFocusToBrowser(CefRefPtr<CefBrowser> browser) {
|
||||
return;
|
||||
|
||||
if (CefCommandLine::GetGlobalCommandLine()->HasSwitch(
|
||||
cefclient::kOffScreenRenderingEnabled)) {
|
||||
switches::kOffScreenRenderingEnabled)) {
|
||||
// Give focus to the OSR window.
|
||||
CefRefPtr<client::OSRWindow> osr_window =
|
||||
static_cast<client::OSRWindow*>(g_handler->GetOSRHandler().get());
|
||||
CefRefPtr<OSRWindow> osr_window =
|
||||
static_cast<OSRWindow*>(g_handler->GetOSRHandler().get());
|
||||
if (osr_window)
|
||||
::SetFocus(osr_window->hwnd());
|
||||
} else {
|
||||
@ -235,13 +210,9 @@ static void SetFocusToBrowser(CefRefPtr<CefBrowser> browser) {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
|
||||
//
|
||||
// PURPOSE: Processes messages for the main window.
|
||||
//
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
// Window procedure for the main window.
|
||||
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
static HWND backWnd = NULL, forwardWnd = NULL, reloadWnd = NULL,
|
||||
stopWnd = NULL, editWnd = NULL;
|
||||
static WNDPROC editWndOldProc = NULL;
|
||||
@ -370,7 +341,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
editWndOldProc =
|
||||
reinterpret_cast<WNDPROC>(GetWindowLongPtr(editWnd, GWLP_WNDPROC));
|
||||
SetWindowLongPtr(editWnd, GWLP_WNDPROC,
|
||||
reinterpret_cast<LONG_PTR>(WndProc));
|
||||
reinterpret_cast<LONG_PTR>(MainWndProc));
|
||||
g_handler->SetEditWindowHandle(editWnd);
|
||||
g_handler->SetButtonWindowHandles(
|
||||
backWnd, forwardWnd, reloadWnd, stopWnd);
|
||||
@ -381,19 +352,19 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
CefBrowserSettings settings;
|
||||
|
||||
// Populate the browser settings based on command line arguments.
|
||||
client::MainContext::Get()->PopulateBrowserSettings(&settings);
|
||||
MainContext::Get()->PopulateBrowserSettings(&settings);
|
||||
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
if (command_line->HasSwitch(cefclient::kOffScreenRenderingEnabled)) {
|
||||
if (command_line->HasSwitch(switches::kOffScreenRenderingEnabled)) {
|
||||
const bool transparent =
|
||||
command_line->HasSwitch(cefclient::kTransparentPaintingEnabled);
|
||||
command_line->HasSwitch(switches::kTransparentPaintingEnabled);
|
||||
const bool show_update_rect =
|
||||
command_line->HasSwitch(cefclient::kShowUpdateRect);
|
||||
command_line->HasSwitch(switches::kShowUpdateRect);
|
||||
|
||||
CefRefPtr<client::OSRWindow> osr_window =
|
||||
client::OSRWindow::Create(&g_main_browser_provider, transparent,
|
||||
show_update_rect);
|
||||
CefRefPtr<OSRWindow> osr_window =
|
||||
OSRWindow::Create(&g_main_browser_provider, transparent,
|
||||
show_update_rect);
|
||||
osr_window->CreateWidget(hWnd, rect, hInst, szOSRWindowClass);
|
||||
info.SetAsWindowless(osr_window->hwnd(), transparent);
|
||||
g_handler->SetOSRHandler(osr_window.get());
|
||||
@ -418,14 +389,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
wmEvent = HIWORD(wParam);
|
||||
|
||||
if (wmId >= ID_TESTS_FIRST && wmId <= ID_TESTS_LAST) {
|
||||
client::test_runner::RunTest(browser, wmId);
|
||||
test_runner::RunTest(browser, wmId);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Parse the menu selections:
|
||||
switch (wmId) {
|
||||
case IDM_ABOUT:
|
||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
|
||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, AboutWndProc);
|
||||
return 0;
|
||||
case IDM_EXIT:
|
||||
if (g_handler.get())
|
||||
@ -444,10 +415,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
hFindDlg = FindText(&fr);
|
||||
|
||||
// Override the dialog's window procedure.
|
||||
WNDPROC wndproc_old = client::SetWndProcPtr(hFindDlg, FindProc);
|
||||
WNDPROC wndproc_old = SetWndProcPtr(hFindDlg, FindWndProc);
|
||||
|
||||
// Associate |wndproc_old| with the dialog.
|
||||
client::SetUserDataPtr(hFindDlg, wndproc_old);
|
||||
SetUserDataPtr(hFindDlg, wndproc_old);
|
||||
} else {
|
||||
// Give focus to the existing find dialog.
|
||||
::SetFocus(hFindDlg);
|
||||
@ -493,10 +464,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
// For off-screen browsers when the frame window is minimized set the
|
||||
// browser as hidden to reduce resource usage.
|
||||
const bool offscreen = CefCommandLine::GetGlobalCommandLine()->HasSwitch(
|
||||
cefclient::kOffScreenRenderingEnabled);
|
||||
switches::kOffScreenRenderingEnabled);
|
||||
if (offscreen) {
|
||||
CefRefPtr<client::OSRWindow> osr_window =
|
||||
static_cast<client::OSRWindow*>(g_handler->GetOSRHandler().get());
|
||||
CefRefPtr<OSRWindow> osr_window =
|
||||
static_cast<OSRWindow*>(g_handler->GetOSRHandler().get());
|
||||
if (osr_window)
|
||||
osr_window->WasHidden(wParam == SIZE_MINIMIZED);
|
||||
}
|
||||
@ -593,31 +564,32 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
}
|
||||
}
|
||||
|
||||
// Message handler for the find dialog.
|
||||
LRESULT CALLBACK FindProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
// Window procedure for the find dialog.
|
||||
LRESULT CALLBACK FindWndProc(HWND hWnd, UINT message, WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
REQUIRE_MAIN_THREAD();
|
||||
|
||||
WNDPROC old_wndproc = client::GetUserDataPtr<WNDPROC>(hWnd);
|
||||
WNDPROC old_wndproc = GetUserDataPtr<WNDPROC>(hWnd);
|
||||
DCHECK(old_wndproc);
|
||||
|
||||
switch (message) {
|
||||
case WM_ACTIVATE:
|
||||
// Set this dialog as current when activated.
|
||||
client::MainMessageLoop::Get()->SetCurrentModelessDialog(
|
||||
MainMessageLoop::Get()->SetCurrentModelessDialog(
|
||||
wParam == 0 ? NULL : hWnd);
|
||||
return FALSE;
|
||||
case WM_NCDESTROY:
|
||||
// Clear the reference to |old_wndproc|.
|
||||
client::SetUserDataPtr(hWnd, NULL);
|
||||
SetUserDataPtr(hWnd, NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
return CallWindowProc(old_wndproc, hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
// Message handler for about box.
|
||||
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
|
||||
// Window procedure for the about dialog.
|
||||
INT_PTR CALLBACK AboutWndProc(HWND hDlg, UINT message, WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
UNREFERENCED_PARAMETER(lParam);
|
||||
switch (message) {
|
||||
case WM_INITDIALOG:
|
||||
@ -632,3 +604,17 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
|
||||
}
|
||||
return (INT_PTR)FALSE;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace client
|
||||
|
||||
|
||||
// Program entry point function.
|
||||
int APIENTRY wWinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPTSTR lpCmdLine,
|
||||
int nCmdShow) {
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
return client::RunMain(hInstance, nCmdShow);
|
||||
}
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "include/cef_v8.h"
|
||||
#include "include/wrapper/cef_helpers.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
ClientApp::ClientApp() {
|
||||
}
|
||||
|
||||
@ -158,3 +160,5 @@ bool ClientApp::OnProcessMessageReceived(
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include <vector>
|
||||
#include "include/cef_app.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
class ClientApp : public CefApp,
|
||||
public CefBrowserProcessHandler,
|
||||
public CefRenderProcessHandler {
|
||||
@ -184,4 +186,6 @@ class ClientApp : public CefApp,
|
||||
IMPLEMENT_REFCOUNTING(ClientApp);
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_CLIENT_APP_H_
|
||||
|
@ -11,21 +11,23 @@
|
||||
#include "cefclient/print_handler_gtk.h"
|
||||
#endif
|
||||
|
||||
namespace client {
|
||||
|
||||
// static
|
||||
void ClientApp::CreateBrowserDelegates(BrowserDelegateSet& delegates) {
|
||||
}
|
||||
|
||||
// static
|
||||
void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
||||
client_renderer::CreateRenderDelegates(delegates);
|
||||
client::performance_test::CreateRenderDelegates(delegates);
|
||||
renderer::CreateRenderDelegates(delegates);
|
||||
performance_test::CreateRenderDelegates(delegates);
|
||||
}
|
||||
|
||||
// static
|
||||
void ClientApp::RegisterCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar,
|
||||
std::vector<CefString>& cookiable_schemes) {
|
||||
client::scheme_test::RegisterCustomSchemes(registrar, cookiable_schemes);
|
||||
scheme_test::RegisterCustomSchemes(registrar, cookiable_schemes);
|
||||
}
|
||||
|
||||
// static
|
||||
@ -37,3 +39,4 @@ CefRefPtr<CefPrintHandler> ClientApp::CreatePrintHandler() {
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include "cefclient/resource_util.h"
|
||||
#include "cefclient/test_runner.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
#if defined(OS_WIN)
|
||||
#define NEWLINE "\r\n"
|
||||
#else
|
||||
@ -51,7 +53,7 @@ enum client_menu_ids {
|
||||
int ClientHandler::browser_count_ = 0;
|
||||
|
||||
ClientHandler::ClientHandler()
|
||||
: startup_url_(client::MainContext::Get()->GetMainURL()),
|
||||
: startup_url_(MainContext::Get()->GetMainURL()),
|
||||
browser_id_(0),
|
||||
is_closing_(false),
|
||||
main_handle_(NULL),
|
||||
@ -60,7 +62,7 @@ ClientHandler::ClientHandler()
|
||||
forward_handle_(NULL),
|
||||
stop_handle_(NULL),
|
||||
reload_handle_(NULL),
|
||||
console_log_file_(client::MainContext::Get()->GetConsoleLogPath()),
|
||||
console_log_file_(MainContext::Get()->GetConsoleLogPath()),
|
||||
first_console_message_(true),
|
||||
focus_on_editable_field_(false) {
|
||||
#if defined(OS_LINUX)
|
||||
@ -73,7 +75,7 @@ ClientHandler::ClientHandler()
|
||||
CefRefPtr<CefCommandLine> command_line =
|
||||
CefCommandLine::GetGlobalCommandLine();
|
||||
mouse_cursor_change_disabled_ =
|
||||
command_line->HasSwitch(cefclient::kMouseCursorChangeDisabled);
|
||||
command_line->HasSwitch(switches::kMouseCursorChangeDisabled);
|
||||
}
|
||||
|
||||
ClientHandler::~ClientHandler() {
|
||||
@ -92,7 +94,7 @@ bool ClientHandler::OnProcessMessageReceived(
|
||||
|
||||
// Check for messages from the client renderer.
|
||||
std::string message_name = message->GetName();
|
||||
if (message_name == client_renderer::kFocusedNodeChangedMessage) {
|
||||
if (message_name == renderer::kFocusedNodeChangedMessage) {
|
||||
// A message is sent from ClientRenderDelegate to tell us whether the
|
||||
// currently focused DOM node is editable. Use of |focus_on_editable_field_|
|
||||
// is redundant with CefKeyEvent.focus_on_editable_field in OnPreKeyEvent
|
||||
@ -183,7 +185,7 @@ bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
|
||||
fclose(file);
|
||||
|
||||
if (first_console_message_) {
|
||||
client::test_runner::Alert(
|
||||
test_runner::Alert(
|
||||
browser, "Console messages written to \"" + console_log_file_ + "\"");
|
||||
first_console_message_ = false;
|
||||
}
|
||||
@ -200,8 +202,7 @@ void ClientHandler::OnBeforeDownload(
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
// Continue the download and show the "Save As" dialog.
|
||||
callback->Continue(
|
||||
client::MainContext::Get()->GetDownloadPath(suggested_name), true);
|
||||
callback->Continue(MainContext::Get()->GetDownloadPath(suggested_name), true);
|
||||
}
|
||||
|
||||
void ClientHandler::OnDownloadUpdated(
|
||||
@ -211,7 +212,7 @@ void ClientHandler::OnDownloadUpdated(
|
||||
CEF_REQUIRE_UI_THREAD();
|
||||
|
||||
if (download_item->IsComplete()) {
|
||||
client::test_runner::Alert(
|
||||
test_runner::Alert(
|
||||
browser,
|
||||
"File \"" + download_item->GetFullPath().ToString() +
|
||||
"\" downloaded successfully.");
|
||||
@ -320,7 +321,7 @@ void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
|
||||
message_router_ = CefMessageRouterBrowserSide::Create(config);
|
||||
|
||||
// Register handlers with the router.
|
||||
client::test_runner::CreateMessageHandlers(message_handler_set_);
|
||||
test_runner::CreateMessageHandlers(message_handler_set_);
|
||||
MessageHandlerSet::const_iterator it = message_handler_set_.begin();
|
||||
for (; it != message_handler_set_.end(); ++it)
|
||||
message_router_->AddHandler(*(it), false);
|
||||
@ -404,7 +405,7 @@ void ClientHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
|
||||
message_router_ = NULL;
|
||||
|
||||
// Quit the application message loop.
|
||||
client::MainMessageLoop::Get()->Quit();
|
||||
MainMessageLoop::Get()->Quit();
|
||||
}
|
||||
}
|
||||
|
||||
@ -461,7 +462,7 @@ CefRefPtr<CefResourceHandler> ClientHandler::GetResourceHandler(
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request) {
|
||||
CEF_REQUIRE_IO_THREAD();
|
||||
return client::test_runner::GetResourceHandler(browser, frame, request);
|
||||
return test_runner::GetResourceHandler(browser, frame, request);
|
||||
}
|
||||
|
||||
bool ClientHandler::OnQuotaRequest(CefRefPtr<CefBrowser> browser,
|
||||
@ -765,3 +766,5 @@ bool ClientHandler::ExecuteTestMenu(int command_id) {
|
||||
// Allow default handling to proceed.
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
@ -28,6 +28,8 @@
|
||||
// window.
|
||||
// #define TEST_REDIRECT_POPUP_URLS
|
||||
|
||||
namespace client {
|
||||
|
||||
// ClientHandler implementation.
|
||||
class ClientHandler : public CefClient,
|
||||
public CefContextMenuHandler,
|
||||
@ -374,4 +376,6 @@ class ClientHandler : public CefClient,
|
||||
IMPLEMENT_REFCOUNTING(ClientHandler);
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_CLIENT_HANDLER_H_
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "include/cef_frame.h"
|
||||
#include "include/cef_url.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
namespace {
|
||||
|
||||
const char kPromptTextId[] = "cef_prompt_text";
|
||||
@ -478,3 +480,5 @@ void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) {
|
||||
else
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(forward_handle_), false);
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_frame.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& url) {
|
||||
@ -41,3 +43,5 @@ void ClientHandler::SetLoading(bool isLoading) {
|
||||
void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) {
|
||||
// TODO(port): Change button status.
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "include/cef_frame.h"
|
||||
#include "cefclient/resource.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
const CefString& url) {
|
||||
@ -48,3 +50,5 @@ void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) {
|
||||
EnableWindow(back_handle_, canGoBack);
|
||||
EnableWindow(forward_handle_, canGoForward);
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
@ -11,7 +11,8 @@
|
||||
#include "include/wrapper/cef_helpers.h"
|
||||
#include "include/wrapper/cef_message_router.h"
|
||||
|
||||
namespace client_renderer {
|
||||
namespace client {
|
||||
namespace renderer {
|
||||
|
||||
const char kFocusedNodeChangedMessage[] = "ClientRenderer.FocusedNodeChanged";
|
||||
|
||||
@ -82,4 +83,5 @@ void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates) {
|
||||
delegates.insert(new ClientRenderDelegate);
|
||||
}
|
||||
|
||||
} // namespace client_renderer
|
||||
} // namespace renderer
|
||||
} // namespace client
|
||||
|
@ -9,7 +9,8 @@
|
||||
#include "include/cef_base.h"
|
||||
#include "cefclient/client_app.h"
|
||||
|
||||
namespace client_renderer {
|
||||
namespace client {
|
||||
namespace renderer {
|
||||
|
||||
// Message sent when the focused node changes.
|
||||
extern const char kFocusedNodeChangedMessage[];
|
||||
@ -17,6 +18,7 @@ extern const char kFocusedNodeChangedMessage[];
|
||||
// Create the render delegate.
|
||||
void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates);
|
||||
|
||||
} // namespace client_renderer
|
||||
} // namespace renderer
|
||||
} // namespace client
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_CLIENT_RENDERER_H_
|
||||
|
@ -6,7 +6,8 @@
|
||||
// a qualified path.
|
||||
#include "client_switches.h" // NOLINT(build/include)
|
||||
|
||||
namespace cefclient {
|
||||
namespace client {
|
||||
namespace switches {
|
||||
|
||||
// CEF and Chromium support a wide range of command-line switches. This file
|
||||
// only contains command-line switches specific to the cefclient application.
|
||||
@ -27,4 +28,5 @@ const char kTransparentPaintingEnabled[] = "transparent-painting-enabled";
|
||||
const char kShowUpdateRect[] = "show-update-rect";
|
||||
const char kMouseCursorChangeDisabled[] = "mouse-cursor-change-disabled";
|
||||
|
||||
} // namespace cefclient
|
||||
} // namespace switches
|
||||
} // namespace client
|
||||
|
@ -8,7 +8,8 @@
|
||||
#define CEF_TESTS_CEFCLIENT_CEFCLIENT_SWITCHES_H_
|
||||
#pragma once
|
||||
|
||||
namespace cefclient {
|
||||
namespace client {
|
||||
namespace switches {
|
||||
|
||||
extern const char kMultiThreadedMessageLoop[];
|
||||
extern const char kCachePath[];
|
||||
@ -19,6 +20,7 @@ extern const char kTransparentPaintingEnabled[];
|
||||
extern const char kShowUpdateRect[];
|
||||
extern const char kMouseCursorChangeDisabled[];
|
||||
|
||||
} // namespace cefclient
|
||||
} // namespace switches
|
||||
} // namespace client
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_CEFCLIENT_SWITCHES_H_
|
||||
|
@ -26,8 +26,8 @@ MainContextImpl::MainContextImpl(int argc,
|
||||
#endif
|
||||
|
||||
// Set the main URL.
|
||||
if (command_line_->HasSwitch(cefclient::kUrl))
|
||||
main_url_ = command_line_->GetSwitchValue(cefclient::kUrl);
|
||||
if (command_line_->HasSwitch(switches::kUrl))
|
||||
main_url_ = command_line_->GetSwitchValue(switches::kUrl);
|
||||
if (main_url_.empty())
|
||||
main_url_ = kDefaultUrl;
|
||||
}
|
||||
@ -43,20 +43,20 @@ std::string MainContextImpl::GetMainURL() {
|
||||
void MainContextImpl::PopulateSettings(CefSettings* settings) {
|
||||
#if defined(OS_WIN)
|
||||
settings->multi_threaded_message_loop =
|
||||
command_line_->HasSwitch(cefclient::kMultiThreadedMessageLoop);
|
||||
command_line_->HasSwitch(switches::kMultiThreadedMessageLoop);
|
||||
#endif
|
||||
|
||||
CefString(&settings->cache_path) =
|
||||
command_line_->GetSwitchValue(cefclient::kCachePath);
|
||||
command_line_->GetSwitchValue(switches::kCachePath);
|
||||
|
||||
if (command_line_->HasSwitch(cefclient::kOffScreenRenderingEnabled))
|
||||
if (command_line_->HasSwitch(switches::kOffScreenRenderingEnabled))
|
||||
settings->windowless_rendering_enabled = true;
|
||||
}
|
||||
|
||||
void MainContextImpl::PopulateBrowserSettings(CefBrowserSettings* settings) {
|
||||
if (command_line_->HasSwitch(cefclient::kOffScreenFrameRate)) {
|
||||
if (command_line_->HasSwitch(switches::kOffScreenFrameRate)) {
|
||||
settings->windowless_frame_rate = atoi(command_line_->
|
||||
GetSwitchValue(cefclient::kOffScreenFrameRate).ToString().c_str());
|
||||
GetSwitchValue(switches::kOffScreenFrameRate).ToString().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1021,7 +1021,8 @@ void ClientOSRHandler::SetLoading(bool isLoading) {
|
||||
} else if ([type isEqualToString:(NSString*)fileUTI_]) {
|
||||
size_t size = current_drag_data_->GetFileContents(NULL);
|
||||
DCHECK_GT(size, 0U);
|
||||
CefRefPtr<BytesWriteHandler> handler = new BytesWriteHandler(size);
|
||||
CefRefPtr<client::BytesWriteHandler> handler =
|
||||
new client::BytesWriteHandler(size);
|
||||
CefRefPtr<CefStreamWriter> writer =
|
||||
CefStreamWriter::CreateForHandler(handler.get());
|
||||
current_drag_data_->GetFileContents(writer);
|
||||
|
@ -12,7 +12,7 @@
|
||||
int main(int argc, char* argv[]) {
|
||||
CefMainArgs main_args(argc, argv);
|
||||
|
||||
CefRefPtr<CefApp> app(new ClientApp);
|
||||
CefRefPtr<CefApp> app(new client::ClientApp);
|
||||
|
||||
// Execute the secondary process.
|
||||
return CefExecuteProcess(main_args, app, NULL);
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <string>
|
||||
#include "include/cef_stream.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
#if defined(OS_POSIX)
|
||||
// Returns the directory containing resource files.
|
||||
bool GetResourceDir(std::string& dir);
|
||||
@ -20,4 +22,6 @@ bool LoadBinaryResource(const char* resource_name, std::string& resource_data);
|
||||
// Retrieve a resource as a steam reader.
|
||||
CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name);
|
||||
|
||||
} // namespace client
|
||||
|
||||
#endif // CEF_TESTS_CEFCLIENT_RESOURCE_UTIL_H_
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace client {
|
||||
|
||||
bool GetResourceDir(std::string& dir) {
|
||||
char buff[1024];
|
||||
|
||||
@ -28,3 +30,5 @@ bool GetResourceDir(std::string& dir) {
|
||||
dir = std::string(buff);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
#include "include/base/cef_logging.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
namespace {
|
||||
|
||||
bool AmIBundled() {
|
||||
@ -59,3 +61,5 @@ bool GetResourceDir(std::string& dir) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "cefclient/resource_util.h"
|
||||
#include <stdio.h>
|
||||
|
||||
namespace client {
|
||||
|
||||
namespace {
|
||||
|
||||
bool FileExists(const char* path) {
|
||||
@ -57,3 +59,5 @@ CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name) {
|
||||
|
||||
return CefStreamReader::CreateForFile(path);
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "include/wrapper/cef_byte_read_handler.h"
|
||||
#include "cefclient/resource.h"
|
||||
|
||||
namespace client {
|
||||
|
||||
namespace {
|
||||
|
||||
bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes) {
|
||||
@ -89,3 +91,5 @@ CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name) {
|
||||
NOTREACHED(); // The resource should be found.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
@ -186,8 +186,7 @@ void EndTracing(CefRefPtr<CefBrowser> browser) {
|
||||
|
||||
void RunDialog() {
|
||||
static const char kDefaultFileName[] = "trace.txt";
|
||||
std::string path =
|
||||
client::MainContext::Get()->GetDownloadPath(kDefaultFileName);
|
||||
std::string path = MainContext::Get()->GetDownloadPath(kDefaultFileName);
|
||||
if (path.empty())
|
||||
path = kDefaultFileName;
|
||||
|
||||
|
@ -4,33 +4,39 @@
|
||||
|
||||
#include "tests/cefclient/client_app.h"
|
||||
|
||||
// static
|
||||
void ClientApp::CreateBrowserDelegates(BrowserDelegateSet& delegates) {
|
||||
using client::ClientApp;
|
||||
|
||||
void CreateBrowserDelegates(ClientApp::BrowserDelegateSet& delegates) {
|
||||
// Bring in the Frame tests.
|
||||
extern void CreateFrameBrowserTests(BrowserDelegateSet& delegates);
|
||||
extern void CreateFrameBrowserTests(
|
||||
ClientApp::BrowserDelegateSet& delegates);
|
||||
CreateFrameBrowserTests(delegates);
|
||||
|
||||
// Bring in the Navigation tests.
|
||||
extern void CreateNavigationBrowserTests(BrowserDelegateSet& delegates);
|
||||
extern void CreateNavigationBrowserTests(
|
||||
ClientApp::BrowserDelegateSet& delegates);
|
||||
CreateNavigationBrowserTests(delegates);
|
||||
|
||||
// Bring in the RequestHandler tests.
|
||||
extern void CreateRequestHandlerBrowserTests(BrowserDelegateSet& delegates);
|
||||
extern void CreateRequestHandlerBrowserTests(
|
||||
ClientApp::BrowserDelegateSet& delegates);
|
||||
CreateRequestHandlerBrowserTests(delegates);
|
||||
|
||||
// Bring in the V8 tests.
|
||||
extern void CreateV8BrowserTests(BrowserDelegateSet& delegates);
|
||||
extern void CreateV8BrowserTests(
|
||||
ClientApp::BrowserDelegateSet& delegates);
|
||||
CreateV8BrowserTests(delegates);
|
||||
}
|
||||
|
||||
// static
|
||||
void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
||||
void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates) {
|
||||
// Bring in the Frame tests.
|
||||
extern void CreateFrameRendererTests(RenderDelegateSet& delegates);
|
||||
extern void CreateFrameRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
CreateFrameRendererTests(delegates);
|
||||
|
||||
// Bring in the DOM tests.
|
||||
extern void CreateDOMRendererTests(RenderDelegateSet& delegates);
|
||||
extern void CreateDOMRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
CreateDOMRendererTests(delegates);
|
||||
|
||||
// Bring in the message router tests.
|
||||
@ -39,7 +45,8 @@ void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
||||
CreateMessageRouterRendererTests(delegates);
|
||||
|
||||
// Bring in the Navigation tests.
|
||||
extern void CreateNavigationRendererTests(RenderDelegateSet& delegates);
|
||||
extern void CreateNavigationRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
CreateNavigationRendererTests(delegates);
|
||||
|
||||
// Bring in the process message tests.
|
||||
@ -48,11 +55,13 @@ void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
||||
CreateProcessMessageRendererTests(delegates);
|
||||
|
||||
// Bring in the RequestHandler tests.
|
||||
extern void CreateRequestHandlerRendererTests(RenderDelegateSet& delegates);
|
||||
extern void CreateRequestHandlerRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
CreateRequestHandlerRendererTests(delegates);
|
||||
|
||||
// Bring in the Request tests.
|
||||
extern void CreateRequestRendererTests(RenderDelegateSet& delegates);
|
||||
extern void CreateRequestRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
CreateRequestRendererTests(delegates);
|
||||
|
||||
// Bring in the routing test handler delegate.
|
||||
@ -61,16 +70,17 @@ void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
||||
CreateRoutingTestHandlerDelegate(delegates);
|
||||
|
||||
// Bring in the URLRequest tests.
|
||||
extern void CreateURLRequestRendererTests(RenderDelegateSet& delegates);
|
||||
extern void CreateURLRequestRendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
CreateURLRequestRendererTests(delegates);
|
||||
|
||||
// Bring in the V8 tests.
|
||||
extern void CreateV8RendererTests(RenderDelegateSet& delegates);
|
||||
extern void CreateV8RendererTests(
|
||||
ClientApp::RenderDelegateSet& delegates);
|
||||
CreateV8RendererTests(delegates);
|
||||
}
|
||||
|
||||
// static
|
||||
void ClientApp::RegisterCustomSchemes(
|
||||
void RegisterCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar,
|
||||
std::vector<CefString>& cookiable_schemes) {
|
||||
// Bring in the scheme handler tests.
|
||||
@ -92,8 +102,30 @@ void ClientApp::RegisterCustomSchemes(
|
||||
RegisterURLRequestCustomSchemes(registrar, cookiable_schemes);
|
||||
}
|
||||
|
||||
|
||||
namespace client {
|
||||
|
||||
// static
|
||||
void ClientApp::CreateBrowserDelegates(BrowserDelegateSet& delegates) {
|
||||
::CreateBrowserDelegates(delegates);
|
||||
}
|
||||
|
||||
// static
|
||||
void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
|
||||
::CreateRenderDelegates(delegates);
|
||||
}
|
||||
|
||||
// static
|
||||
void ClientApp::RegisterCustomSchemes(
|
||||
CefRefPtr<CefSchemeRegistrar> registrar,
|
||||
std::vector<CefString>& cookiable_schemes) {
|
||||
::RegisterCustomSchemes(registrar, cookiable_schemes);
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefPrintHandler> ClientApp::CreatePrintHandler() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
} // namespace client
|
||||
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "tests/cefclient/client_app.h"
|
||||
#include "tests/unittests/test_handler.h"
|
||||
|
||||
using client::ClientApp;
|
||||
|
||||
namespace {
|
||||
|
||||
const char* kTestUrl = "http://tests/DOMTest.Test";
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include "tests/cefclient/client_app.h"
|
||||
#include "tests/unittests/test_handler.h"
|
||||
|
||||
using client::ClientApp;
|
||||
|
||||
namespace {
|
||||
|
||||
// The frame navigation test harness work as follows:
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include "tests/unittests/routing_test_handler.h"
|
||||
#include "tests/cefclient/client_app.h"
|
||||
|
||||
using client::ClientApp;
|
||||
|
||||
namespace {
|
||||
|
||||
const char kTestDomainRoot[] = "http://tests-mr";
|
||||
|
@ -17,6 +17,8 @@
|
||||
#include "tests/unittests/test_handler.h"
|
||||
#include "tests/unittests/test_util.h"
|
||||
|
||||
using client::ClientApp;
|
||||
|
||||
namespace {
|
||||
|
||||
const char kHNav1[] = "http://tests-hnav/nav1.html";
|
||||
|
@ -300,7 +300,7 @@ class OSRTestHandler : public RoutingTestHandler,
|
||||
if (url.find(kTestUrl) == 0) {
|
||||
// Show the osr test contents
|
||||
CefRefPtr<CefStreamReader> stream =
|
||||
GetBinaryResourceReader("osr_test.html");
|
||||
client::GetBinaryResourceReader("osr_test.html");
|
||||
return new CefStreamResourceHandler("text/html", stream);
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
#include "tests/unittests/test_handler.h"
|
||||
#include "tests/unittests/test_util.h"
|
||||
|
||||
using client::ClientApp;
|
||||
|
||||
namespace {
|
||||
|
||||
// Unique values for the SendRecv test.
|
||||
|
@ -14,6 +14,8 @@
|
||||
#include "tests/cefclient/client_app.h"
|
||||
#include "tests/unittests/test_handler.h"
|
||||
|
||||
using client::ClientApp;
|
||||
|
||||
namespace {
|
||||
|
||||
enum NetNotifyTestType {
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "tests/unittests/test_handler.h"
|
||||
#include "tests/unittests/test_util.h"
|
||||
|
||||
using client::ClientApp;
|
||||
|
||||
// Verify Set/Get methods for CefRequest, CefPostData and CefPostDataElement.
|
||||
TEST(RequestTest, SetGet) {
|
||||
// CefRequest CreateRequest
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "tests/unittests/routing_test_handler.h"
|
||||
#include "tests/cefclient/client_app.h"
|
||||
|
||||
using client::ClientApp;
|
||||
|
||||
namespace {
|
||||
|
||||
void SetRouterConfig(CefMessageRouterConfig& config) {
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include "include/cef_sandbox_win.h"
|
||||
#endif
|
||||
|
||||
using client::ClientApp;
|
||||
|
||||
namespace {
|
||||
|
||||
// Thread used to run the test suite.
|
||||
@ -107,7 +109,7 @@ int main(int argc, char* argv[]) {
|
||||
windows_sandbox_info = scoped_sandbox.sandbox_info();
|
||||
#endif
|
||||
|
||||
CefRefPtr<CefApp> app(new ClientApp);
|
||||
CefRefPtr<CefApp> app(new client::ClientApp);
|
||||
|
||||
// Execute the secondary process, if any.
|
||||
int exit_code = CefExecuteProcess(main_args, app, windows_sandbox_info);
|
||||
|
@ -48,11 +48,11 @@ void CefTestSuite::InitCommandLine(int argc, const char* const* argv) {
|
||||
void CefTestSuite::GetSettings(CefSettings& settings) {
|
||||
#if defined(OS_WIN)
|
||||
settings.multi_threaded_message_loop =
|
||||
commandline_->HasSwitch(cefclient::kMultiThreadedMessageLoop);
|
||||
commandline_->HasSwitch(client::switches::kMultiThreadedMessageLoop);
|
||||
#endif
|
||||
|
||||
CefString(&settings.cache_path) =
|
||||
commandline_->GetSwitchValueASCII(cefclient::kCachePath);
|
||||
commandline_->GetSwitchValueASCII(client::switches::kCachePath);
|
||||
|
||||
// Always expose the V8 gc() function to give tests finer-grained control over
|
||||
// memory management.
|
||||
@ -75,9 +75,9 @@ void CefTestSuite::GetSettings(CefSettings& settings) {
|
||||
bool CefTestSuite::GetCachePath(std::string& path) {
|
||||
DCHECK(commandline_);
|
||||
|
||||
if (commandline_->HasSwitch(cefclient::kCachePath)) {
|
||||
if (commandline_->HasSwitch(client::switches::kCachePath)) {
|
||||
// Set the cache_path value.
|
||||
path = commandline_->GetSwitchValueASCII(cefclient::kCachePath);
|
||||
path = commandline_->GetSwitchValueASCII(client::switches::kCachePath);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include "tests/unittests/test_handler.h"
|
||||
#include "tests/unittests/test_util.h"
|
||||
|
||||
using client::ClientApp;
|
||||
|
||||
// How to add a new test:
|
||||
// 1. Add a new value to the RequestTestMode enumeration.
|
||||
// 2. Add methods to set up and run the test in RequestTestRunner.
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "tests/unittests/test_handler.h"
|
||||
|
||||
using client::ClientApp;
|
||||
|
||||
// How to add a new test:
|
||||
// 1. Add a new value to the V8TestMode enumeration.
|
||||
// 2. Add a method that implements the test in V8RendererTest.
|
||||
|
Loading…
x
Reference in New Issue
Block a user