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:
Marshall Greenblatt 2015-01-23 19:09:34 +00:00
parent 87c41bf99f
commit 68cb4b6213
40 changed files with 320 additions and 190 deletions

View File

@ -9,6 +9,8 @@
#include "include/wrapper/cef_helpers.h" #include "include/wrapper/cef_helpers.h"
namespace client {
BytesWriteHandler::BytesWriteHandler(size_t grow) BytesWriteHandler::BytesWriteHandler(size_t grow)
: grow_(grow), : grow_(grow),
datasize_(grow), datasize_(grow),
@ -92,3 +94,5 @@ size_t BytesWriteHandler::Grow(size_t size) {
return rv; return rv;
} }
} // namespace client

View File

@ -9,6 +9,8 @@
#include "include/base/cef_lock.h" #include "include/base/cef_lock.h"
#include "include/cef_stream.h" #include "include/cef_stream.h"
namespace client {
class BytesWriteHandler : public CefWriteHandler { class BytesWriteHandler : public CefWriteHandler {
public: public:
explicit BytesWriteHandler(size_t grow); explicit BytesWriteHandler(size_t grow);
@ -36,4 +38,6 @@ class BytesWriteHandler : public CefWriteHandler {
IMPLEMENT_REFCOUNTING(BytesWriteHandler); IMPLEMENT_REFCOUNTING(BytesWriteHandler);
}; };
} // namespace client
#endif // CEF_TESTS_CEFCLIENT_BYTES_WRITE_HANDLER_H_ #endif // CEF_TESTS_CEFCLIENT_BYTES_WRITE_HANDLER_H_

View File

@ -30,18 +30,21 @@
#include "cefclient/resource.h" #include "cefclient/resource.h"
#include "cefclient/test_runner.h" #include "cefclient/test_runner.h"
namespace client {
namespace {
// The global ClientHandler reference. // The global ClientHandler reference.
CefRefPtr<ClientHandler> g_handler; CefRefPtr<ClientHandler> g_handler;
namespace {
// Height of the buttons at the top of the GTK window. // Height of the buttons at the top of the GTK window.
int g_toolbar_height = 0; int g_toolbar_height = 0;
// Height of the integrated menu bar (if any) at the top of the GTK window. // Height of the integrated menu bar (if any) at the top of the GTK window.
int g_menubar_height = 0; 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() { virtual CefRefPtr<CefBrowser> GetBrowser() {
if (g_handler.get()) if (g_handler.get())
return g_handler->GetBrowser(); return g_handler->GetBrowser();
@ -50,6 +53,7 @@ class MainBrowserProvider : public client::OSRBrowserProvider {
} }
} g_main_browser_provider; } g_main_browser_provider;
int XErrorHandlerImpl(Display *display, XErrorEvent *event) { int XErrorHandlerImpl(Display *display, XErrorEvent *event) {
LOG(WARNING) LOG(WARNING)
<< "X error received: " << "X error received: "
@ -89,7 +93,7 @@ gboolean delete_event(GtkWidget* widget, GdkEvent* event,
} }
void TerminationSignalHandler(int signatl) { void TerminationSignalHandler(int signatl) {
client::MainMessageLoop::Get()->Quit(); MainMessageLoop::Get()->Quit();
} }
void VboxSizeAllocated(GtkWidget* widget, void VboxSizeAllocated(GtkWidget* widget,
@ -225,10 +229,8 @@ gboolean WindowConfigure(GtkWindow* window,
// Callback for Tests menu items. // Callback for Tests menu items.
gboolean MenuItemActivated(GtkWidget* widget, gpointer data) { gboolean MenuItemActivated(GtkWidget* widget, gpointer data) {
if (g_handler.get() && g_handler->GetBrowserId()) { if (g_handler.get() && g_handler->GetBrowserId())
client::test_runner::RunTest(g_handler->GetBrowser(), test_runner::RunTest(g_handler->GetBrowser(), GPOINTER_TO_INT(data));
GPOINTER_TO_INT(data));
}
return FALSE; // Don't stop this message. return FALSE; // Don't stop this message.
} }
@ -317,9 +319,7 @@ GtkWidget* CreateMenuBar() {
return menu_bar; return menu_bar;
} }
} // namespace int RunMain(int argc, char* argv[]) {
int main(int argc, char* argv[]) {
// Create a copy of |argv| on Linux because Chromium mangles the value // Create a copy of |argv| on Linux because Chromium mangles the value
// internally (see issue #620). // internally (see issue #620).
CefScopedArgArray scoped_arg_array(argc, argv); CefScopedArgArray scoped_arg_array(argc, argv);
@ -334,8 +334,7 @@ int main(int argc, char* argv[]) {
return exit_code; return exit_code;
// Create the main context object. // Create the main context object.
scoped_ptr<client::MainContextImpl> context( scoped_ptr<MainContextImpl> context(new MainContextImpl(argc, argv));
new client::MainContextImpl(argc, argv));
CefSettings settings; CefSettings settings;
@ -348,8 +347,7 @@ int main(int argc, char* argv[]) {
XSetIOErrorHandler(XIOErrorHandlerImpl); XSetIOErrorHandler(XIOErrorHandlerImpl);
// Create the main message loop object. // Create the main message loop object.
scoped_ptr<client::MainMessageLoop> message_loop( scoped_ptr<MainMessageLoop> message_loop(new MainMessageLoopStd);
new client::MainMessageLoopStd);
// Initialize CEF. // Initialize CEF.
CefInitialize(main_args, settings, app.get(), NULL); CefInitialize(main_args, settings, app.get(), NULL);
@ -362,7 +360,7 @@ int main(int argc, char* argv[]) {
gtk_gl_init(&argc, &argv_copy); gtk_gl_init(&argc, &argv_copy);
// Register scheme handlers. // Register scheme handlers.
client::test_runner::RegisterSchemeHandlers(); test_runner::RegisterSchemeHandlers();
GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(window), 800, 600); gtk_window_set_default_size(GTK_WINDOW(window), 800, 600);
@ -443,16 +441,16 @@ int main(int argc, char* argv[]) {
CefRefPtr<CefCommandLine> command_line = CefRefPtr<CefCommandLine> command_line =
CefCommandLine::GetGlobalCommandLine(); CefCommandLine::GetGlobalCommandLine();
if (command_line->HasSwitch(cefclient::kOffScreenRenderingEnabled)) { if (command_line->HasSwitch(switches::kOffScreenRenderingEnabled)) {
const bool transparent = const bool transparent =
command_line->HasSwitch(cefclient::kTransparentPaintingEnabled); command_line->HasSwitch(switches::kTransparentPaintingEnabled);
const bool show_update_rect = const bool show_update_rect =
command_line->HasSwitch(cefclient::kShowUpdateRect); command_line->HasSwitch(switches::kShowUpdateRect);
// Create the GTKGL surface. // Create the GTKGL surface.
CefRefPtr<client::OSRWindow> osr_window = CefRefPtr<OSRWindow> osr_window =
client::OSRWindow::Create(&g_main_browser_provider, transparent, OSRWindow::Create(&g_main_browser_provider, transparent,
show_update_rect, vbox); show_update_rect, vbox);
// Show the GTK window. // Show the GTK window.
gtk_widget_show_all(GTK_WIDGET(window)); gtk_widget_show_all(GTK_WIDGET(window));
@ -493,3 +491,12 @@ int main(int argc, char* argv[]) {
return result; return result;
} }
} // namespace
} // namespace client
// Program entry point function.
int main(int argc, char* argv[]) {
return client::RunMain(argc, argv);
}

View File

@ -19,9 +19,12 @@
#include "cefclient/resource_util.h" #include "cefclient/resource_util.h"
#include "cefclient/test_runner.h" #include "cefclient/test_runner.h"
// The global ClientHandler reference. namespace {
CefRefPtr<ClientHandler> g_handler;
// The global ClientHandler reference.
CefRefPtr<client::ClientHandler> g_handler;
// Used by off-screen rendering to find the associated CefBrowser.
class MainBrowserProvider : public client::OSRBrowserProvider { class MainBrowserProvider : public client::OSRBrowserProvider {
virtual CefRefPtr<CefBrowser> GetBrowser() { virtual CefRefPtr<CefBrowser> GetBrowser() {
if (g_handler.get()) if (g_handler.get())
@ -31,6 +34,7 @@ class MainBrowserProvider : public client::OSRBrowserProvider {
} }
} g_main_browser_provider; } g_main_browser_provider;
// Sizes for URL bar layout // Sizes for URL bar layout
#define BUTTON_HEIGHT 22 #define BUTTON_HEIGHT 22
#define BUTTON_WIDTH 72 #define BUTTON_WIDTH 72
@ -41,6 +45,26 @@ class MainBrowserProvider : public client::OSRBrowserProvider {
const int kWindowWidth = 800; const int kWindowWidth = 800;
const int kWindowHeight = 600; 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. // Receives notifications from the application. Will delete itself when done.
@interface ClientAppDelegate : NSObject @interface ClientAppDelegate : NSObject
- (void)createApplication:(id)object; - (void)createApplication:(id)object;
@ -209,7 +233,7 @@ const int kWindowHeight = 600;
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser(); CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
if (browser.get()) { if (browser.get()) {
if (CefCommandLine::GetGlobalCommandLine()->HasSwitch( if (CefCommandLine::GetGlobalCommandLine()->HasSwitch(
cefclient::kOffScreenRenderingEnabled)) { client::switches::kOffScreenRenderingEnabled)) {
browser->GetHost()->SendFocusEvent(true); browser->GetHost()->SendFocusEvent(true);
} else { } else {
browser->GetHost()->SetFocus(true); browser->GetHost()->SetFocus(true);
@ -224,7 +248,7 @@ const int kWindowHeight = 600;
CefRefPtr<CefBrowser> browser = g_handler->GetBrowser(); CefRefPtr<CefBrowser> browser = g_handler->GetBrowser();
if (browser.get()) { if (browser.get()) {
if (CefCommandLine::GetGlobalCommandLine()->HasSwitch( if (CefCommandLine::GetGlobalCommandLine()->HasSwitch(
cefclient::kOffScreenRenderingEnabled)) { client::switches::kOffScreenRenderingEnabled)) {
browser->GetHost()->SendFocusEvent(false); browser->GetHost()->SendFocusEvent(false);
} else { } else {
browser->GetHost()->SetFocus(false); browser->GetHost()->SetFocus(false);
@ -313,23 +337,6 @@ const int kWindowHeight = 600;
@end @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 @implementation ClientAppDelegate
// Create the application on the UI thread. // Create the application on the UI thread.
@ -424,7 +431,7 @@ void AddMenuItem(NSMenu *menu, NSString* label, int idval) {
[[editWnd cell] setScrollable:YES]; [[editWnd cell] setScrollable:YES];
// Create the handler. // Create the handler.
g_handler = new ClientHandler(); g_handler = new client::ClientHandler();
g_handler->SetMainWindowHandle(contentView); g_handler->SetMainWindowHandle(contentView);
g_handler->SetEditWindowHandle(editWnd); g_handler->SetEditWindowHandle(editWnd);
@ -437,11 +444,11 @@ void AddMenuItem(NSMenu *menu, NSString* label, int idval) {
CefRefPtr<CefCommandLine> command_line = CefRefPtr<CefCommandLine> command_line =
CefCommandLine::GetGlobalCommandLine(); CefCommandLine::GetGlobalCommandLine();
if (command_line->HasSwitch(cefclient::kOffScreenRenderingEnabled)) { if (command_line->HasSwitch(client::switches::kOffScreenRenderingEnabled)) {
const bool transparent = const bool transparent =
command_line->HasSwitch(cefclient::kTransparentPaintingEnabled); command_line->HasSwitch(client::switches::kTransparentPaintingEnabled);
const bool show_update_rect = const bool show_update_rect =
command_line->HasSwitch(cefclient::kShowUpdateRect); command_line->HasSwitch(client::switches::kShowUpdateRect);
CefRefPtr<client::OSRWindow> osr_window = CefRefPtr<client::OSRWindow> osr_window =
client::OSRWindow::Create(&g_main_browser_provider, transparent, client::OSRWindow::Create(&g_main_browser_provider, transparent,
@ -486,7 +493,10 @@ void AddMenuItem(NSMenu *menu, NSString* label, int idval) {
@end @end
int main(int argc, char* argv[]) { namespace client {
namespace {
int RunMain(int argc, char* argv[]) {
CefMainArgs main_args(argc, argv); CefMainArgs main_args(argc, argv);
CefRefPtr<ClientApp> app(new ClientApp); CefRefPtr<ClientApp> app(new ClientApp);
@ -497,8 +507,7 @@ int main(int argc, char* argv[]) {
[ClientApplication sharedApplication]; [ClientApplication sharedApplication];
// Create the main context object. // Create the main context object.
scoped_ptr<client::MainContextImpl> context( scoped_ptr<MainContextImpl> context(new MainContextImpl(argc, argv));
new client::MainContextImpl(argc, argv));
CefSettings settings; CefSettings settings;
@ -506,14 +515,13 @@ int main(int argc, char* argv[]) {
context->PopulateSettings(&settings); context->PopulateSettings(&settings);
// Create the main message loop object. // Create the main message loop object.
scoped_ptr<client::MainMessageLoop> message_loop( scoped_ptr<MainMessageLoop> message_loop(new MainMessageLoopStd);
new client::MainMessageLoopStd);
// Initialize CEF. // Initialize CEF.
CefInitialize(main_args, settings, app.get(), NULL); CefInitialize(main_args, settings, app.get(), NULL);
// Register scheme handlers. // Register scheme handlers.
client::test_runner::RegisterSchemeHandlers(); test_runner::RegisterSchemeHandlers();
// Create the application delegate and window. // Create the application delegate and window.
NSObject* delegate = [[ClientAppDelegate alloc] init]; NSObject* delegate = [[ClientAppDelegate alloc] init];
@ -536,3 +544,12 @@ int main(int argc, char* argv[]) {
return result; return result;
} }
} // namespace
} // namespace client
// Program entry point function.
int main(int argc, char* argv[]) {
return client::RunMain(argc, argv);
}

View File

@ -40,6 +40,8 @@
#pragma comment(lib, "cef_sandbox.lib") #pragma comment(lib, "cef_sandbox.lib")
#endif #endif
namespace client {
namespace {
#define MAX_LOADSTRING 100 #define MAX_LOADSTRING 100
#define MAX_URL_LENGTH 255 #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. UINT uFindMsg; // Message identifier for find events.
HWND hFindDlg = NULL; // Handle for the find dialog. HWND hFindDlg = NULL; // Handle for the find dialog.
// Forward declarations of functions included in this code module: // Forward declarations of functions included in this code module.
ATOM MyRegisterClass(HINSTANCE hInstance); ATOM RegisterMainClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int); BOOL CreateMainWindow(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK FindProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK FindWndProc(HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); INT_PTR CALLBACK AboutWndProc(HWND, UINT, WPARAM, LPARAM);
// The global ClientHandler reference. // The global ClientHandler reference.
CefRefPtr<ClientHandler> g_handler; 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() { virtual CefRefPtr<CefBrowser> GetBrowser() {
if (g_handler.get()) if (g_handler.get())
return g_handler->GetBrowser(); return g_handler->GetBrowser();
@ -73,14 +76,8 @@ class MainBrowserProvider : public client::OSRBrowserProvider {
} }
} g_main_browser_provider; } 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; void* sandbox_info = NULL;
#if defined(CEF_USE_SANDBOX) #if defined(CEF_USE_SANDBOX)
@ -99,8 +96,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
return exit_code; return exit_code;
// Create the main context object. // Create the main context object.
scoped_ptr<client::MainContextImpl> context( scoped_ptr<MainContextImpl> context(new MainContextImpl(0, NULL));
new client::MainContextImpl(0, NULL));
CefSettings settings; CefSettings settings;
@ -112,26 +108,26 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
context->PopulateSettings(&settings); context->PopulateSettings(&settings);
// Create the main message loop object. // Create the main message loop object.
scoped_ptr<client::MainMessageLoop> message_loop; scoped_ptr<MainMessageLoop> message_loop;
if (settings.multi_threaded_message_loop) if (settings.multi_threaded_message_loop)
message_loop.reset(new client::MainMessageLoopMultithreadedWin); message_loop.reset(new MainMessageLoopMultithreadedWin);
else else
message_loop.reset(new client::MainMessageLoopStd); message_loop.reset(new MainMessageLoopStd);
// Initialize CEF. // Initialize CEF.
CefInitialize(main_args, settings, app.get(), sandbox_info); CefInitialize(main_args, settings, app.get(), sandbox_info);
// Register scheme handlers. // Register scheme handlers.
client::test_runner::RegisterSchemeHandlers(); test_runner::RegisterSchemeHandlers();
// Initialize global strings // Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_CEFCLIENT, szWindowClass, MAX_LOADSTRING); LoadString(hInstance, IDC_CEFCLIENT, szWindowClass, MAX_LOADSTRING);
LoadString(hInstance, IDS_OSR_WIDGET_CLASS, szOSRWindowClass, MAX_LOADSTRING); LoadString(hInstance, IDS_OSR_WIDGET_CLASS, szOSRWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance); RegisterMainClass(hInstance);
// Perform application initialization // Perform application initialization
if (!InitInstance (hInstance, nCmdShow)) if (!CreateMainWindow(hInstance, nCmdShow))
return FALSE; return FALSE;
// Register the find event message. // Register the find event message.
@ -150,26 +146,14 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
return result; return result;
} }
// // Register the main window class.
// FUNCTION: MyRegisterClass() ATOM RegisterMainClass(HINSTANCE hInstance) {
//
// 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) {
WNDCLASSEX wcex; WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX); wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc; wcex.lpfnWndProc = MainWndProc;
wcex.cbClsExtra = 0; wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0; wcex.cbWndExtra = 0;
wcex.hInstance = hInstance; wcex.hInstance = hInstance;
@ -183,17 +167,8 @@ ATOM MyRegisterClass(HINSTANCE hInstance) {
return RegisterClassEx(&wcex); return RegisterClassEx(&wcex);
} }
// // Create and show the main window.
// FUNCTION: InitInstance(HINSTANCE, int) BOOL CreateMainWindow(HINSTANCE hInstance, int nCmdShow) {
//
// 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) {
HWND hWnd; HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable hInst = hInstance; // Store instance handle in our global variable
@ -223,10 +198,10 @@ static void SetFocusToBrowser(CefRefPtr<CefBrowser> browser) {
return; return;
if (CefCommandLine::GetGlobalCommandLine()->HasSwitch( if (CefCommandLine::GetGlobalCommandLine()->HasSwitch(
cefclient::kOffScreenRenderingEnabled)) { switches::kOffScreenRenderingEnabled)) {
// Give focus to the OSR window. // Give focus to the OSR window.
CefRefPtr<client::OSRWindow> osr_window = CefRefPtr<OSRWindow> osr_window =
static_cast<client::OSRWindow*>(g_handler->GetOSRHandler().get()); static_cast<OSRWindow*>(g_handler->GetOSRHandler().get());
if (osr_window) if (osr_window)
::SetFocus(osr_window->hwnd()); ::SetFocus(osr_window->hwnd());
} else { } else {
@ -235,13 +210,9 @@ static void SetFocusToBrowser(CefRefPtr<CefBrowser> browser) {
} }
} }
// // Window procedure for the main window.
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) LRESULT CALLBACK MainWndProc(HWND hWnd, UINT message, WPARAM wParam,
// LPARAM lParam) {
// PURPOSE: Processes messages for the main window.
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam) {
static HWND backWnd = NULL, forwardWnd = NULL, reloadWnd = NULL, static HWND backWnd = NULL, forwardWnd = NULL, reloadWnd = NULL,
stopWnd = NULL, editWnd = NULL; stopWnd = NULL, editWnd = NULL;
static WNDPROC editWndOldProc = NULL; static WNDPROC editWndOldProc = NULL;
@ -370,7 +341,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
editWndOldProc = editWndOldProc =
reinterpret_cast<WNDPROC>(GetWindowLongPtr(editWnd, GWLP_WNDPROC)); reinterpret_cast<WNDPROC>(GetWindowLongPtr(editWnd, GWLP_WNDPROC));
SetWindowLongPtr(editWnd, GWLP_WNDPROC, SetWindowLongPtr(editWnd, GWLP_WNDPROC,
reinterpret_cast<LONG_PTR>(WndProc)); reinterpret_cast<LONG_PTR>(MainWndProc));
g_handler->SetEditWindowHandle(editWnd); g_handler->SetEditWindowHandle(editWnd);
g_handler->SetButtonWindowHandles( g_handler->SetButtonWindowHandles(
backWnd, forwardWnd, reloadWnd, stopWnd); backWnd, forwardWnd, reloadWnd, stopWnd);
@ -381,19 +352,19 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
CefBrowserSettings settings; CefBrowserSettings settings;
// Populate the browser settings based on command line arguments. // Populate the browser settings based on command line arguments.
client::MainContext::Get()->PopulateBrowserSettings(&settings); MainContext::Get()->PopulateBrowserSettings(&settings);
CefRefPtr<CefCommandLine> command_line = CefRefPtr<CefCommandLine> command_line =
CefCommandLine::GetGlobalCommandLine(); CefCommandLine::GetGlobalCommandLine();
if (command_line->HasSwitch(cefclient::kOffScreenRenderingEnabled)) { if (command_line->HasSwitch(switches::kOffScreenRenderingEnabled)) {
const bool transparent = const bool transparent =
command_line->HasSwitch(cefclient::kTransparentPaintingEnabled); command_line->HasSwitch(switches::kTransparentPaintingEnabled);
const bool show_update_rect = const bool show_update_rect =
command_line->HasSwitch(cefclient::kShowUpdateRect); command_line->HasSwitch(switches::kShowUpdateRect);
CefRefPtr<client::OSRWindow> osr_window = CefRefPtr<OSRWindow> osr_window =
client::OSRWindow::Create(&g_main_browser_provider, transparent, OSRWindow::Create(&g_main_browser_provider, transparent,
show_update_rect); show_update_rect);
osr_window->CreateWidget(hWnd, rect, hInst, szOSRWindowClass); osr_window->CreateWidget(hWnd, rect, hInst, szOSRWindowClass);
info.SetAsWindowless(osr_window->hwnd(), transparent); info.SetAsWindowless(osr_window->hwnd(), transparent);
g_handler->SetOSRHandler(osr_window.get()); g_handler->SetOSRHandler(osr_window.get());
@ -418,14 +389,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
wmEvent = HIWORD(wParam); wmEvent = HIWORD(wParam);
if (wmId >= ID_TESTS_FIRST && wmId <= ID_TESTS_LAST) { if (wmId >= ID_TESTS_FIRST && wmId <= ID_TESTS_LAST) {
client::test_runner::RunTest(browser, wmId); test_runner::RunTest(browser, wmId);
return 0; return 0;
} }
// Parse the menu selections: // Parse the menu selections:
switch (wmId) { switch (wmId) {
case IDM_ABOUT: case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, AboutWndProc);
return 0; return 0;
case IDM_EXIT: case IDM_EXIT:
if (g_handler.get()) if (g_handler.get())
@ -444,10 +415,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
hFindDlg = FindText(&fr); hFindDlg = FindText(&fr);
// Override the dialog's window procedure. // 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. // Associate |wndproc_old| with the dialog.
client::SetUserDataPtr(hFindDlg, wndproc_old); SetUserDataPtr(hFindDlg, wndproc_old);
} else { } else {
// Give focus to the existing find dialog. // Give focus to the existing find dialog.
::SetFocus(hFindDlg); ::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 // For off-screen browsers when the frame window is minimized set the
// browser as hidden to reduce resource usage. // browser as hidden to reduce resource usage.
const bool offscreen = CefCommandLine::GetGlobalCommandLine()->HasSwitch( const bool offscreen = CefCommandLine::GetGlobalCommandLine()->HasSwitch(
cefclient::kOffScreenRenderingEnabled); switches::kOffScreenRenderingEnabled);
if (offscreen) { if (offscreen) {
CefRefPtr<client::OSRWindow> osr_window = CefRefPtr<OSRWindow> osr_window =
static_cast<client::OSRWindow*>(g_handler->GetOSRHandler().get()); static_cast<OSRWindow*>(g_handler->GetOSRHandler().get());
if (osr_window) if (osr_window)
osr_window->WasHidden(wParam == SIZE_MINIMIZED); 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. // Window procedure for the find dialog.
LRESULT CALLBACK FindProc(HWND hWnd, UINT message, WPARAM wParam, LRESULT CALLBACK FindWndProc(HWND hWnd, UINT message, WPARAM wParam,
LPARAM lParam) { LPARAM lParam) {
REQUIRE_MAIN_THREAD(); REQUIRE_MAIN_THREAD();
WNDPROC old_wndproc = client::GetUserDataPtr<WNDPROC>(hWnd); WNDPROC old_wndproc = GetUserDataPtr<WNDPROC>(hWnd);
DCHECK(old_wndproc); DCHECK(old_wndproc);
switch (message) { switch (message) {
case WM_ACTIVATE: case WM_ACTIVATE:
// Set this dialog as current when activated. // Set this dialog as current when activated.
client::MainMessageLoop::Get()->SetCurrentModelessDialog( MainMessageLoop::Get()->SetCurrentModelessDialog(
wParam == 0 ? NULL : hWnd); wParam == 0 ? NULL : hWnd);
return FALSE; return FALSE;
case WM_NCDESTROY: case WM_NCDESTROY:
// Clear the reference to |old_wndproc|. // Clear the reference to |old_wndproc|.
client::SetUserDataPtr(hWnd, NULL); SetUserDataPtr(hWnd, NULL);
break; break;
} }
return CallWindowProc(old_wndproc, hWnd, message, wParam, lParam); return CallWindowProc(old_wndproc, hWnd, message, wParam, lParam);
} }
// Message handler for about box. // Window procedure for the about dialog.
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { INT_PTR CALLBACK AboutWndProc(HWND hDlg, UINT message, WPARAM wParam,
LPARAM lParam) {
UNREFERENCED_PARAMETER(lParam); UNREFERENCED_PARAMETER(lParam);
switch (message) { switch (message) {
case WM_INITDIALOG: case WM_INITDIALOG:
@ -632,3 +604,17 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) {
} }
return (INT_PTR)FALSE; 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);
}

View File

@ -14,6 +14,8 @@
#include "include/cef_v8.h" #include "include/cef_v8.h"
#include "include/wrapper/cef_helpers.h" #include "include/wrapper/cef_helpers.h"
namespace client {
ClientApp::ClientApp() { ClientApp::ClientApp() {
} }
@ -158,3 +160,5 @@ bool ClientApp::OnProcessMessageReceived(
return handled; return handled;
} }
} // namespace client

View File

@ -13,6 +13,8 @@
#include <vector> #include <vector>
#include "include/cef_app.h" #include "include/cef_app.h"
namespace client {
class ClientApp : public CefApp, class ClientApp : public CefApp,
public CefBrowserProcessHandler, public CefBrowserProcessHandler,
public CefRenderProcessHandler { public CefRenderProcessHandler {
@ -184,4 +186,6 @@ class ClientApp : public CefApp,
IMPLEMENT_REFCOUNTING(ClientApp); IMPLEMENT_REFCOUNTING(ClientApp);
}; };
} // namespace client
#endif // CEF_TESTS_CEFCLIENT_CLIENT_APP_H_ #endif // CEF_TESTS_CEFCLIENT_CLIENT_APP_H_

View File

@ -11,21 +11,23 @@
#include "cefclient/print_handler_gtk.h" #include "cefclient/print_handler_gtk.h"
#endif #endif
namespace client {
// static // static
void ClientApp::CreateBrowserDelegates(BrowserDelegateSet& delegates) { void ClientApp::CreateBrowserDelegates(BrowserDelegateSet& delegates) {
} }
// static // static
void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) { void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
client_renderer::CreateRenderDelegates(delegates); renderer::CreateRenderDelegates(delegates);
client::performance_test::CreateRenderDelegates(delegates); performance_test::CreateRenderDelegates(delegates);
} }
// static // static
void ClientApp::RegisterCustomSchemes( void ClientApp::RegisterCustomSchemes(
CefRefPtr<CefSchemeRegistrar> registrar, CefRefPtr<CefSchemeRegistrar> registrar,
std::vector<CefString>& cookiable_schemes) { std::vector<CefString>& cookiable_schemes) {
client::scheme_test::RegisterCustomSchemes(registrar, cookiable_schemes); scheme_test::RegisterCustomSchemes(registrar, cookiable_schemes);
} }
// static // static
@ -37,3 +39,4 @@ CefRefPtr<CefPrintHandler> ClientApp::CreatePrintHandler() {
#endif #endif
} }
} // namespace client

View File

@ -26,6 +26,8 @@
#include "cefclient/resource_util.h" #include "cefclient/resource_util.h"
#include "cefclient/test_runner.h" #include "cefclient/test_runner.h"
namespace client {
#if defined(OS_WIN) #if defined(OS_WIN)
#define NEWLINE "\r\n" #define NEWLINE "\r\n"
#else #else
@ -51,7 +53,7 @@ enum client_menu_ids {
int ClientHandler::browser_count_ = 0; int ClientHandler::browser_count_ = 0;
ClientHandler::ClientHandler() ClientHandler::ClientHandler()
: startup_url_(client::MainContext::Get()->GetMainURL()), : startup_url_(MainContext::Get()->GetMainURL()),
browser_id_(0), browser_id_(0),
is_closing_(false), is_closing_(false),
main_handle_(NULL), main_handle_(NULL),
@ -60,7 +62,7 @@ ClientHandler::ClientHandler()
forward_handle_(NULL), forward_handle_(NULL),
stop_handle_(NULL), stop_handle_(NULL),
reload_handle_(NULL), reload_handle_(NULL),
console_log_file_(client::MainContext::Get()->GetConsoleLogPath()), console_log_file_(MainContext::Get()->GetConsoleLogPath()),
first_console_message_(true), first_console_message_(true),
focus_on_editable_field_(false) { focus_on_editable_field_(false) {
#if defined(OS_LINUX) #if defined(OS_LINUX)
@ -73,7 +75,7 @@ ClientHandler::ClientHandler()
CefRefPtr<CefCommandLine> command_line = CefRefPtr<CefCommandLine> command_line =
CefCommandLine::GetGlobalCommandLine(); CefCommandLine::GetGlobalCommandLine();
mouse_cursor_change_disabled_ = mouse_cursor_change_disabled_ =
command_line->HasSwitch(cefclient::kMouseCursorChangeDisabled); command_line->HasSwitch(switches::kMouseCursorChangeDisabled);
} }
ClientHandler::~ClientHandler() { ClientHandler::~ClientHandler() {
@ -92,7 +94,7 @@ bool ClientHandler::OnProcessMessageReceived(
// Check for messages from the client renderer. // Check for messages from the client renderer.
std::string message_name = message->GetName(); 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 // A message is sent from ClientRenderDelegate to tell us whether the
// currently focused DOM node is editable. Use of |focus_on_editable_field_| // currently focused DOM node is editable. Use of |focus_on_editable_field_|
// is redundant with CefKeyEvent.focus_on_editable_field in OnPreKeyEvent // is redundant with CefKeyEvent.focus_on_editable_field in OnPreKeyEvent
@ -183,7 +185,7 @@ bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
fclose(file); fclose(file);
if (first_console_message_) { if (first_console_message_) {
client::test_runner::Alert( test_runner::Alert(
browser, "Console messages written to \"" + console_log_file_ + "\""); browser, "Console messages written to \"" + console_log_file_ + "\"");
first_console_message_ = false; first_console_message_ = false;
} }
@ -200,8 +202,7 @@ void ClientHandler::OnBeforeDownload(
CEF_REQUIRE_UI_THREAD(); CEF_REQUIRE_UI_THREAD();
// Continue the download and show the "Save As" dialog. // Continue the download and show the "Save As" dialog.
callback->Continue( callback->Continue(MainContext::Get()->GetDownloadPath(suggested_name), true);
client::MainContext::Get()->GetDownloadPath(suggested_name), true);
} }
void ClientHandler::OnDownloadUpdated( void ClientHandler::OnDownloadUpdated(
@ -211,7 +212,7 @@ void ClientHandler::OnDownloadUpdated(
CEF_REQUIRE_UI_THREAD(); CEF_REQUIRE_UI_THREAD();
if (download_item->IsComplete()) { if (download_item->IsComplete()) {
client::test_runner::Alert( test_runner::Alert(
browser, browser,
"File \"" + download_item->GetFullPath().ToString() + "File \"" + download_item->GetFullPath().ToString() +
"\" downloaded successfully."); "\" downloaded successfully.");
@ -320,7 +321,7 @@ void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
message_router_ = CefMessageRouterBrowserSide::Create(config); message_router_ = CefMessageRouterBrowserSide::Create(config);
// Register handlers with the router. // 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(); MessageHandlerSet::const_iterator it = message_handler_set_.begin();
for (; it != message_handler_set_.end(); ++it) for (; it != message_handler_set_.end(); ++it)
message_router_->AddHandler(*(it), false); message_router_->AddHandler(*(it), false);
@ -404,7 +405,7 @@ void ClientHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
message_router_ = NULL; message_router_ = NULL;
// Quit the application message loop. // Quit the application message loop.
client::MainMessageLoop::Get()->Quit(); MainMessageLoop::Get()->Quit();
} }
} }
@ -461,7 +462,7 @@ CefRefPtr<CefResourceHandler> ClientHandler::GetResourceHandler(
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) { CefRefPtr<CefRequest> request) {
CEF_REQUIRE_IO_THREAD(); 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, bool ClientHandler::OnQuotaRequest(CefRefPtr<CefBrowser> browser,
@ -765,3 +766,5 @@ bool ClientHandler::ExecuteTestMenu(int command_id) {
// Allow default handling to proceed. // Allow default handling to proceed.
return false; return false;
} }
} // namespace client

View File

@ -28,6 +28,8 @@
// window. // window.
// #define TEST_REDIRECT_POPUP_URLS // #define TEST_REDIRECT_POPUP_URLS
namespace client {
// ClientHandler implementation. // ClientHandler implementation.
class ClientHandler : public CefClient, class ClientHandler : public CefClient,
public CefContextMenuHandler, public CefContextMenuHandler,
@ -374,4 +376,6 @@ class ClientHandler : public CefClient,
IMPLEMENT_REFCOUNTING(ClientHandler); IMPLEMENT_REFCOUNTING(ClientHandler);
}; };
} // namespace client
#endif // CEF_TESTS_CEFCLIENT_CLIENT_HANDLER_H_ #endif // CEF_TESTS_CEFCLIENT_CLIENT_HANDLER_H_

View File

@ -15,6 +15,8 @@
#include "include/cef_frame.h" #include "include/cef_frame.h"
#include "include/cef_url.h" #include "include/cef_url.h"
namespace client {
namespace { namespace {
const char kPromptTextId[] = "cef_prompt_text"; const char kPromptTextId[] = "cef_prompt_text";
@ -478,3 +480,5 @@ void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) {
else else
gtk_widget_set_sensitive(GTK_WIDGET(forward_handle_), false); gtk_widget_set_sensitive(GTK_WIDGET(forward_handle_), false);
} }
} // namespace client

View File

@ -8,6 +8,8 @@
#include "include/cef_browser.h" #include "include/cef_browser.h"
#include "include/cef_frame.h" #include "include/cef_frame.h"
namespace client {
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser, void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
const CefString& url) { const CefString& url) {
@ -41,3 +43,5 @@ void ClientHandler::SetLoading(bool isLoading) {
void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) { void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) {
// TODO(port): Change button status. // TODO(port): Change button status.
} }
} // namespace client

View File

@ -11,6 +11,8 @@
#include "include/cef_frame.h" #include "include/cef_frame.h"
#include "cefclient/resource.h" #include "cefclient/resource.h"
namespace client {
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser, void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame, CefRefPtr<CefFrame> frame,
const CefString& url) { const CefString& url) {
@ -48,3 +50,5 @@ void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) {
EnableWindow(back_handle_, canGoBack); EnableWindow(back_handle_, canGoBack);
EnableWindow(forward_handle_, canGoForward); EnableWindow(forward_handle_, canGoForward);
} }
} // namespace client

View File

@ -11,7 +11,8 @@
#include "include/wrapper/cef_helpers.h" #include "include/wrapper/cef_helpers.h"
#include "include/wrapper/cef_message_router.h" #include "include/wrapper/cef_message_router.h"
namespace client_renderer { namespace client {
namespace renderer {
const char kFocusedNodeChangedMessage[] = "ClientRenderer.FocusedNodeChanged"; const char kFocusedNodeChangedMessage[] = "ClientRenderer.FocusedNodeChanged";
@ -82,4 +83,5 @@ void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates) {
delegates.insert(new ClientRenderDelegate); delegates.insert(new ClientRenderDelegate);
} }
} // namespace client_renderer } // namespace renderer
} // namespace client

View File

@ -9,7 +9,8 @@
#include "include/cef_base.h" #include "include/cef_base.h"
#include "cefclient/client_app.h" #include "cefclient/client_app.h"
namespace client_renderer { namespace client {
namespace renderer {
// Message sent when the focused node changes. // Message sent when the focused node changes.
extern const char kFocusedNodeChangedMessage[]; extern const char kFocusedNodeChangedMessage[];
@ -17,6 +18,7 @@ extern const char kFocusedNodeChangedMessage[];
// Create the render delegate. // Create the render delegate.
void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates); void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates);
} // namespace client_renderer } // namespace renderer
} // namespace client
#endif // CEF_TESTS_CEFCLIENT_CLIENT_RENDERER_H_ #endif // CEF_TESTS_CEFCLIENT_CLIENT_RENDERER_H_

View File

@ -6,7 +6,8 @@
// a qualified path. // a qualified path.
#include "client_switches.h" // NOLINT(build/include) #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 // CEF and Chromium support a wide range of command-line switches. This file
// only contains command-line switches specific to the cefclient application. // 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 kShowUpdateRect[] = "show-update-rect";
const char kMouseCursorChangeDisabled[] = "mouse-cursor-change-disabled"; const char kMouseCursorChangeDisabled[] = "mouse-cursor-change-disabled";
} // namespace cefclient } // namespace switches
} // namespace client

View File

@ -8,7 +8,8 @@
#define CEF_TESTS_CEFCLIENT_CEFCLIENT_SWITCHES_H_ #define CEF_TESTS_CEFCLIENT_CEFCLIENT_SWITCHES_H_
#pragma once #pragma once
namespace cefclient { namespace client {
namespace switches {
extern const char kMultiThreadedMessageLoop[]; extern const char kMultiThreadedMessageLoop[];
extern const char kCachePath[]; extern const char kCachePath[];
@ -19,6 +20,7 @@ extern const char kTransparentPaintingEnabled[];
extern const char kShowUpdateRect[]; extern const char kShowUpdateRect[];
extern const char kMouseCursorChangeDisabled[]; extern const char kMouseCursorChangeDisabled[];
} // namespace cefclient } // namespace switches
} // namespace client
#endif // CEF_TESTS_CEFCLIENT_CEFCLIENT_SWITCHES_H_ #endif // CEF_TESTS_CEFCLIENT_CEFCLIENT_SWITCHES_H_

View File

@ -26,8 +26,8 @@ MainContextImpl::MainContextImpl(int argc,
#endif #endif
// Set the main URL. // Set the main URL.
if (command_line_->HasSwitch(cefclient::kUrl)) if (command_line_->HasSwitch(switches::kUrl))
main_url_ = command_line_->GetSwitchValue(cefclient::kUrl); main_url_ = command_line_->GetSwitchValue(switches::kUrl);
if (main_url_.empty()) if (main_url_.empty())
main_url_ = kDefaultUrl; main_url_ = kDefaultUrl;
} }
@ -43,20 +43,20 @@ std::string MainContextImpl::GetMainURL() {
void MainContextImpl::PopulateSettings(CefSettings* settings) { void MainContextImpl::PopulateSettings(CefSettings* settings) {
#if defined(OS_WIN) #if defined(OS_WIN)
settings->multi_threaded_message_loop = settings->multi_threaded_message_loop =
command_line_->HasSwitch(cefclient::kMultiThreadedMessageLoop); command_line_->HasSwitch(switches::kMultiThreadedMessageLoop);
#endif #endif
CefString(&settings->cache_path) = 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; settings->windowless_rendering_enabled = true;
} }
void MainContextImpl::PopulateBrowserSettings(CefBrowserSettings* settings) { void MainContextImpl::PopulateBrowserSettings(CefBrowserSettings* settings) {
if (command_line_->HasSwitch(cefclient::kOffScreenFrameRate)) { if (command_line_->HasSwitch(switches::kOffScreenFrameRate)) {
settings->windowless_frame_rate = atoi(command_line_-> settings->windowless_frame_rate = atoi(command_line_->
GetSwitchValue(cefclient::kOffScreenFrameRate).ToString().c_str()); GetSwitchValue(switches::kOffScreenFrameRate).ToString().c_str());
} }
} }

View File

@ -1021,7 +1021,8 @@ void ClientOSRHandler::SetLoading(bool isLoading) {
} else if ([type isEqualToString:(NSString*)fileUTI_]) { } else if ([type isEqualToString:(NSString*)fileUTI_]) {
size_t size = current_drag_data_->GetFileContents(NULL); size_t size = current_drag_data_->GetFileContents(NULL);
DCHECK_GT(size, 0U); DCHECK_GT(size, 0U);
CefRefPtr<BytesWriteHandler> handler = new BytesWriteHandler(size); CefRefPtr<client::BytesWriteHandler> handler =
new client::BytesWriteHandler(size);
CefRefPtr<CefStreamWriter> writer = CefRefPtr<CefStreamWriter> writer =
CefStreamWriter::CreateForHandler(handler.get()); CefStreamWriter::CreateForHandler(handler.get());
current_drag_data_->GetFileContents(writer); current_drag_data_->GetFileContents(writer);

View File

@ -12,7 +12,7 @@
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
CefMainArgs main_args(argc, argv); CefMainArgs main_args(argc, argv);
CefRefPtr<CefApp> app(new ClientApp); CefRefPtr<CefApp> app(new client::ClientApp);
// Execute the secondary process. // Execute the secondary process.
return CefExecuteProcess(main_args, app, NULL); return CefExecuteProcess(main_args, app, NULL);

View File

@ -9,6 +9,8 @@
#include <string> #include <string>
#include "include/cef_stream.h" #include "include/cef_stream.h"
namespace client {
#if defined(OS_POSIX) #if defined(OS_POSIX)
// Returns the directory containing resource files. // Returns the directory containing resource files.
bool GetResourceDir(std::string& dir); 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. // Retrieve a resource as a steam reader.
CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name); CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name);
} // namespace client
#endif // CEF_TESTS_CEFCLIENT_RESOURCE_UTIL_H_ #endif // CEF_TESTS_CEFCLIENT_RESOURCE_UTIL_H_

View File

@ -8,6 +8,8 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
namespace client {
bool GetResourceDir(std::string& dir) { bool GetResourceDir(std::string& dir) {
char buff[1024]; char buff[1024];
@ -28,3 +30,5 @@ bool GetResourceDir(std::string& dir) {
dir = std::string(buff); dir = std::string(buff);
return true; return true;
} }
} // namespace client

View File

@ -11,6 +11,8 @@
#include "include/base/cef_logging.h" #include "include/base/cef_logging.h"
namespace client {
namespace { namespace {
bool AmIBundled() { bool AmIBundled() {
@ -59,3 +61,5 @@ bool GetResourceDir(std::string& dir) {
return false; return false;
} }
} }
} // namespace client

View File

@ -5,6 +5,8 @@
#include "cefclient/resource_util.h" #include "cefclient/resource_util.h"
#include <stdio.h> #include <stdio.h>
namespace client {
namespace { namespace {
bool FileExists(const char* path) { bool FileExists(const char* path) {
@ -57,3 +59,5 @@ CefRefPtr<CefStreamReader> GetBinaryResourceReader(const char* resource_name) {
return CefStreamReader::CreateForFile(path); return CefStreamReader::CreateForFile(path);
} }
} // namespace client

View File

@ -8,6 +8,8 @@
#include "include/wrapper/cef_byte_read_handler.h" #include "include/wrapper/cef_byte_read_handler.h"
#include "cefclient/resource.h" #include "cefclient/resource.h"
namespace client {
namespace { namespace {
bool LoadBinaryResource(int binaryId, DWORD &dwSize, LPBYTE &pBytes) { 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. NOTREACHED(); // The resource should be found.
return NULL; return NULL;
} }
} // namespace client

View File

@ -186,8 +186,7 @@ void EndTracing(CefRefPtr<CefBrowser> browser) {
void RunDialog() { void RunDialog() {
static const char kDefaultFileName[] = "trace.txt"; static const char kDefaultFileName[] = "trace.txt";
std::string path = std::string path = MainContext::Get()->GetDownloadPath(kDefaultFileName);
client::MainContext::Get()->GetDownloadPath(kDefaultFileName);
if (path.empty()) if (path.empty())
path = kDefaultFileName; path = kDefaultFileName;

View File

@ -4,33 +4,39 @@
#include "tests/cefclient/client_app.h" #include "tests/cefclient/client_app.h"
// static using client::ClientApp;
void ClientApp::CreateBrowserDelegates(BrowserDelegateSet& delegates) {
void CreateBrowserDelegates(ClientApp::BrowserDelegateSet& delegates) {
// Bring in the Frame tests. // Bring in the Frame tests.
extern void CreateFrameBrowserTests(BrowserDelegateSet& delegates); extern void CreateFrameBrowserTests(
ClientApp::BrowserDelegateSet& delegates);
CreateFrameBrowserTests(delegates); CreateFrameBrowserTests(delegates);
// Bring in the Navigation tests. // Bring in the Navigation tests.
extern void CreateNavigationBrowserTests(BrowserDelegateSet& delegates); extern void CreateNavigationBrowserTests(
ClientApp::BrowserDelegateSet& delegates);
CreateNavigationBrowserTests(delegates); CreateNavigationBrowserTests(delegates);
// Bring in the RequestHandler tests. // Bring in the RequestHandler tests.
extern void CreateRequestHandlerBrowserTests(BrowserDelegateSet& delegates); extern void CreateRequestHandlerBrowserTests(
ClientApp::BrowserDelegateSet& delegates);
CreateRequestHandlerBrowserTests(delegates); CreateRequestHandlerBrowserTests(delegates);
// Bring in the V8 tests. // Bring in the V8 tests.
extern void CreateV8BrowserTests(BrowserDelegateSet& delegates); extern void CreateV8BrowserTests(
ClientApp::BrowserDelegateSet& delegates);
CreateV8BrowserTests(delegates); CreateV8BrowserTests(delegates);
} }
// static void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates) {
void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
// Bring in the Frame tests. // Bring in the Frame tests.
extern void CreateFrameRendererTests(RenderDelegateSet& delegates); extern void CreateFrameRendererTests(
ClientApp::RenderDelegateSet& delegates);
CreateFrameRendererTests(delegates); CreateFrameRendererTests(delegates);
// Bring in the DOM tests. // Bring in the DOM tests.
extern void CreateDOMRendererTests(RenderDelegateSet& delegates); extern void CreateDOMRendererTests(
ClientApp::RenderDelegateSet& delegates);
CreateDOMRendererTests(delegates); CreateDOMRendererTests(delegates);
// Bring in the message router tests. // Bring in the message router tests.
@ -39,7 +45,8 @@ void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
CreateMessageRouterRendererTests(delegates); CreateMessageRouterRendererTests(delegates);
// Bring in the Navigation tests. // Bring in the Navigation tests.
extern void CreateNavigationRendererTests(RenderDelegateSet& delegates); extern void CreateNavigationRendererTests(
ClientApp::RenderDelegateSet& delegates);
CreateNavigationRendererTests(delegates); CreateNavigationRendererTests(delegates);
// Bring in the process message tests. // Bring in the process message tests.
@ -48,11 +55,13 @@ void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
CreateProcessMessageRendererTests(delegates); CreateProcessMessageRendererTests(delegates);
// Bring in the RequestHandler tests. // Bring in the RequestHandler tests.
extern void CreateRequestHandlerRendererTests(RenderDelegateSet& delegates); extern void CreateRequestHandlerRendererTests(
ClientApp::RenderDelegateSet& delegates);
CreateRequestHandlerRendererTests(delegates); CreateRequestHandlerRendererTests(delegates);
// Bring in the Request tests. // Bring in the Request tests.
extern void CreateRequestRendererTests(RenderDelegateSet& delegates); extern void CreateRequestRendererTests(
ClientApp::RenderDelegateSet& delegates);
CreateRequestRendererTests(delegates); CreateRequestRendererTests(delegates);
// Bring in the routing test handler delegate. // Bring in the routing test handler delegate.
@ -61,16 +70,17 @@ void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) {
CreateRoutingTestHandlerDelegate(delegates); CreateRoutingTestHandlerDelegate(delegates);
// Bring in the URLRequest tests. // Bring in the URLRequest tests.
extern void CreateURLRequestRendererTests(RenderDelegateSet& delegates); extern void CreateURLRequestRendererTests(
ClientApp::RenderDelegateSet& delegates);
CreateURLRequestRendererTests(delegates); CreateURLRequestRendererTests(delegates);
// Bring in the V8 tests. // Bring in the V8 tests.
extern void CreateV8RendererTests(RenderDelegateSet& delegates); extern void CreateV8RendererTests(
ClientApp::RenderDelegateSet& delegates);
CreateV8RendererTests(delegates); CreateV8RendererTests(delegates);
} }
// static void RegisterCustomSchemes(
void ClientApp::RegisterCustomSchemes(
CefRefPtr<CefSchemeRegistrar> registrar, CefRefPtr<CefSchemeRegistrar> registrar,
std::vector<CefString>& cookiable_schemes) { std::vector<CefString>& cookiable_schemes) {
// Bring in the scheme handler tests. // Bring in the scheme handler tests.
@ -92,8 +102,30 @@ void ClientApp::RegisterCustomSchemes(
RegisterURLRequestCustomSchemes(registrar, cookiable_schemes); 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 // static
CefRefPtr<CefPrintHandler> ClientApp::CreatePrintHandler() { CefRefPtr<CefPrintHandler> ClientApp::CreatePrintHandler() {
return NULL; return NULL;
} }
} // namespace client

View File

@ -10,6 +10,8 @@
#include "tests/cefclient/client_app.h" #include "tests/cefclient/client_app.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
using client::ClientApp;
namespace { namespace {
const char* kTestUrl = "http://tests/DOMTest.Test"; const char* kTestUrl = "http://tests/DOMTest.Test";

View File

@ -13,6 +13,8 @@
#include "tests/cefclient/client_app.h" #include "tests/cefclient/client_app.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
using client::ClientApp;
namespace { namespace {
// The frame navigation test harness work as follows: // The frame navigation test harness work as follows:

View File

@ -19,6 +19,8 @@
#include "tests/unittests/routing_test_handler.h" #include "tests/unittests/routing_test_handler.h"
#include "tests/cefclient/client_app.h" #include "tests/cefclient/client_app.h"
using client::ClientApp;
namespace { namespace {
const char kTestDomainRoot[] = "http://tests-mr"; const char kTestDomainRoot[] = "http://tests-mr";

View File

@ -17,6 +17,8 @@
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
#include "tests/unittests/test_util.h" #include "tests/unittests/test_util.h"
using client::ClientApp;
namespace { namespace {
const char kHNav1[] = "http://tests-hnav/nav1.html"; const char kHNav1[] = "http://tests-hnav/nav1.html";

View File

@ -300,7 +300,7 @@ class OSRTestHandler : public RoutingTestHandler,
if (url.find(kTestUrl) == 0) { if (url.find(kTestUrl) == 0) {
// Show the osr test contents // Show the osr test contents
CefRefPtr<CefStreamReader> stream = CefRefPtr<CefStreamReader> stream =
GetBinaryResourceReader("osr_test.html"); client::GetBinaryResourceReader("osr_test.html");
return new CefStreamResourceHandler("text/html", stream); return new CefStreamResourceHandler("text/html", stream);
} }

View File

@ -12,6 +12,8 @@
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
#include "tests/unittests/test_util.h" #include "tests/unittests/test_util.h"
using client::ClientApp;
namespace { namespace {
// Unique values for the SendRecv test. // Unique values for the SendRecv test.

View File

@ -14,6 +14,8 @@
#include "tests/cefclient/client_app.h" #include "tests/cefclient/client_app.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
using client::ClientApp;
namespace { namespace {
enum NetNotifyTestType { enum NetNotifyTestType {

View File

@ -15,6 +15,8 @@
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
#include "tests/unittests/test_util.h" #include "tests/unittests/test_util.h"
using client::ClientApp;
// Verify Set/Get methods for CefRequest, CefPostData and CefPostDataElement. // Verify Set/Get methods for CefRequest, CefPostData and CefPostDataElement.
TEST(RequestTest, SetGet) { TEST(RequestTest, SetGet) {
// CefRequest CreateRequest // CefRequest CreateRequest

View File

@ -8,6 +8,8 @@
#include "tests/unittests/routing_test_handler.h" #include "tests/unittests/routing_test_handler.h"
#include "tests/cefclient/client_app.h" #include "tests/cefclient/client_app.h"
using client::ClientApp;
namespace { namespace {
void SetRouterConfig(CefMessageRouterConfig& config) { void SetRouterConfig(CefMessageRouterConfig& config) {

View File

@ -27,6 +27,8 @@
#include "include/cef_sandbox_win.h" #include "include/cef_sandbox_win.h"
#endif #endif
using client::ClientApp;
namespace { namespace {
// Thread used to run the test suite. // Thread used to run the test suite.
@ -107,7 +109,7 @@ int main(int argc, char* argv[]) {
windows_sandbox_info = scoped_sandbox.sandbox_info(); windows_sandbox_info = scoped_sandbox.sandbox_info();
#endif #endif
CefRefPtr<CefApp> app(new ClientApp); CefRefPtr<CefApp> app(new client::ClientApp);
// Execute the secondary process, if any. // Execute the secondary process, if any.
int exit_code = CefExecuteProcess(main_args, app, windows_sandbox_info); int exit_code = CefExecuteProcess(main_args, app, windows_sandbox_info);

View File

@ -48,11 +48,11 @@ void CefTestSuite::InitCommandLine(int argc, const char* const* argv) {
void CefTestSuite::GetSettings(CefSettings& settings) { void CefTestSuite::GetSettings(CefSettings& settings) {
#if defined(OS_WIN) #if defined(OS_WIN)
settings.multi_threaded_message_loop = settings.multi_threaded_message_loop =
commandline_->HasSwitch(cefclient::kMultiThreadedMessageLoop); commandline_->HasSwitch(client::switches::kMultiThreadedMessageLoop);
#endif #endif
CefString(&settings.cache_path) = 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 // Always expose the V8 gc() function to give tests finer-grained control over
// memory management. // memory management.
@ -75,9 +75,9 @@ void CefTestSuite::GetSettings(CefSettings& settings) {
bool CefTestSuite::GetCachePath(std::string& path) { bool CefTestSuite::GetCachePath(std::string& path) {
DCHECK(commandline_); DCHECK(commandline_);
if (commandline_->HasSwitch(cefclient::kCachePath)) { if (commandline_->HasSwitch(client::switches::kCachePath)) {
// Set the cache_path value. // Set the cache_path value.
path = commandline_->GetSwitchValueASCII(cefclient::kCachePath); path = commandline_->GetSwitchValueASCII(client::switches::kCachePath);
return true; return true;
} }

View File

@ -23,6 +23,8 @@
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
#include "tests/unittests/test_util.h" #include "tests/unittests/test_util.h"
using client::ClientApp;
// How to add a new test: // How to add a new test:
// 1. Add a new value to the RequestTestMode enumeration. // 1. Add a new value to the RequestTestMode enumeration.
// 2. Add methods to set up and run the test in RequestTestRunner. // 2. Add methods to set up and run the test in RequestTestRunner.

View File

@ -15,6 +15,8 @@
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "tests/unittests/test_handler.h" #include "tests/unittests/test_handler.h"
using client::ClientApp;
// How to add a new test: // How to add a new test:
// 1. Add a new value to the V8TestMode enumeration. // 1. Add a new value to the V8TestMode enumeration.
// 2. Add a method that implements the test in V8RendererTest. // 2. Add a method that implements the test in V8RendererTest.