Make CEF compliant with Google/Chromium style (issue #473).

- Add a new check_style tool based on Google's cpplint that can be used to verify compliance of pending changes and specific files/directories.
- Update existing CEF source code to be compliant with the style requirements.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@463 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-01-09 23:46:23 +00:00
parent 9cc61f448b
commit 1073577d03
558 changed files with 9002 additions and 10977 deletions

View File

@ -2,16 +2,16 @@
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
#include "client_handler.h"
#include "cefclient/client_handler.h"
#include <stdio.h>
#include <sstream>
#include <string>
#include "include/cef_browser.h"
#include "include/cef_frame.h"
#include "binding_test.h"
#include "cefclient.h"
#include "download_handler.h"
#include "string_util.h"
#include <sstream>
#include <stdio.h>
#include <string>
#include "cefclient/binding_test.h"
#include "cefclient/cefclient.h"
#include "cefclient/download_handler.h"
#include "cefclient/string_util.h"
ClientHandler::ClientHandler()
@ -22,30 +22,25 @@ ClientHandler::ClientHandler()
m_ForwardHwnd(NULL),
m_StopHwnd(NULL),
m_ReloadHwnd(NULL),
m_bFormElementHasFocus(false)
{
m_bFormElementHasFocus(false) {
}
ClientHandler::~ClientHandler()
{
ClientHandler::~ClientHandler() {
}
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser)
{
void ClientHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
REQUIRE_UI_THREAD();
AutoLock lock_scope(this);
if(!m_Browser.get())
{
if (!m_Browser.get()) {
// We need to keep the main child window, but not popup windows
m_Browser = browser;
m_BrowserHwnd = browser->GetWindowHandle();
}
}
bool ClientHandler::DoClose(CefRefPtr<CefBrowser> browser)
{
bool ClientHandler::DoClose(CefRefPtr<CefBrowser> browser) {
REQUIRE_UI_THREAD();
if (m_BrowserHwnd == browser->GetWindowHandle()) {
@ -53,7 +48,7 @@ bool ClientHandler::DoClose(CefRefPtr<CefBrowser> browser)
// the parent window instead of the browser window.
CloseMainWindow();
// Return true here so that we can skip closing the browser window
// Return true here so that we can skip closing the browser window
// in this pass. (It will be destroyed due to the call to close
// the parent above.)
return true;
@ -64,22 +59,20 @@ bool ClientHandler::DoClose(CefRefPtr<CefBrowser> browser)
return false;
}
void ClientHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser)
{
void ClientHandler::OnBeforeClose(CefRefPtr<CefBrowser> browser) {
REQUIRE_UI_THREAD();
if(m_BrowserHwnd == browser->GetWindowHandle()) {
if (m_BrowserHwnd == browser->GetWindowHandle()) {
// Free the browser pointer so that the browser can be destroyed
m_Browser = NULL;
}
}
void ClientHandler::OnLoadStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame)
{
CefRefPtr<CefFrame> frame) {
REQUIRE_UI_THREAD();
if(m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) {
if (m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) {
// We've just started loading a page
SetLoading(true);
}
@ -87,16 +80,15 @@ void ClientHandler::OnLoadStart(CefRefPtr<CefBrowser> browser,
void ClientHandler::OnLoadEnd(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int httpStatusCode)
{
int httpStatusCode) {
REQUIRE_UI_THREAD();
if(m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) {
if (m_BrowserHwnd == browser->GetWindowHandle() && frame->IsMain()) {
// We've just finished loading a page
SetLoading(false);
CefRefPtr<CefDOMVisitor> visitor = GetDOMVisitor(frame->GetURL());
if(visitor.get())
if (visitor.get())
frame->VisitDOM(visitor);
}
}
@ -105,11 +97,10 @@ bool ClientHandler::OnLoadError(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
ErrorCode errorCode,
const CefString& failedUrl,
CefString& errorText)
{
CefString& errorText) {
REQUIRE_UI_THREAD();
if(errorCode == ERR_CACHE_MISS) {
if (errorCode == ERR_CACHE_MISS) {
// Usually caused by navigating to a page with POST data via back or
// forward buttons.
errorText = "<html><head><title>Expired Form Data</title></head>"
@ -136,8 +127,7 @@ bool ClientHandler::GetDownloadHandler(CefRefPtr<CefBrowser> browser,
const CefString& mimeType,
const CefString& fileName,
int64 contentLength,
CefRefPtr<CefDownloadHandler>& handler)
{
CefRefPtr<CefDownloadHandler>& handler) {
REQUIRE_UI_THREAD();
// Create the handler for the file download.
@ -152,8 +142,7 @@ bool ClientHandler::GetDownloadHandler(CefRefPtr<CefBrowser> browser,
void ClientHandler::OnNavStateChange(CefRefPtr<CefBrowser> browser,
bool canGoBack,
bool canGoForward)
{
bool canGoForward) {
REQUIRE_UI_THREAD();
SetNavState(canGoBack, canGoForward);
@ -162,8 +151,7 @@ void ClientHandler::OnNavStateChange(CefRefPtr<CefBrowser> browser,
bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
const CefString& message,
const CefString& source,
int line)
{
int line) {
REQUIRE_UI_THREAD();
bool first_message;
@ -171,9 +159,9 @@ bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
{
AutoLock lock_scope(this);
first_message = m_LogFile.empty();
if(first_message) {
if (first_message) {
std::stringstream ss;
ss << AppGetWorkingDirectory();
#if defined(OS_WIN)
@ -185,10 +173,10 @@ bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
m_LogFile = ss.str();
}
logFile = m_LogFile;
}
}
FILE* file = fopen(logFile.c_str(), "a");
if(file) {
if (file) {
std::stringstream ss;
ss << "Message: " << std::string(message) << "\r\nSource: " <<
std::string(source) << "\r\nLine: " << line <<
@ -196,7 +184,7 @@ bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
fputs(ss.str().c_str(), file);
fclose(file);
if(first_message)
if (first_message)
SendNotification(NOTIFY_CONSOLE_MESSAGE);
}
@ -205,8 +193,7 @@ bool ClientHandler::OnConsoleMessage(CefRefPtr<CefBrowser> browser,
void ClientHandler::OnFocusedNodeChanged(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefDOMNode> node)
{
CefRefPtr<CefDOMNode> node) {
REQUIRE_UI_THREAD();
// Set to true if a form element has focus.
@ -218,8 +205,7 @@ bool ClientHandler::OnKeyEvent(CefRefPtr<CefBrowser> browser,
int code,
int modifiers,
bool isSystemKey,
bool isAfterJavaScript)
{
bool isAfterJavaScript) {
REQUIRE_UI_THREAD();
if (isAfterJavaScript && !m_bFormElementHasFocus && code == 0x20) {
@ -247,15 +233,14 @@ bool ClientHandler::GetPrintHeaderFooter(CefRefPtr<CefBrowser> browser,
CefString& topRight,
CefString& bottomLeft,
CefString& bottomCenter,
CefString& bottomRight)
{
CefString& bottomRight) {
REQUIRE_UI_THREAD();
// Place the page title at top left
topLeft = title;
// Place the page URL at top right
topRight = url;
// Place "Page X of Y" at bottom center
std::stringstream strstream;
strstream << "Page " << currentPage << " of " << maxPages;
@ -266,8 +251,7 @@ bool ClientHandler::GetPrintHeaderFooter(CefRefPtr<CefBrowser> browser,
void ClientHandler::OnContextCreated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefV8Context> context)
{
CefRefPtr<CefV8Context> context) {
REQUIRE_UI_THREAD();
// Add the V8 bindings.
@ -276,8 +260,7 @@ void ClientHandler::OnContextCreated(CefRefPtr<CefBrowser> browser,
bool ClientHandler::OnDragStart(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> dragData,
DragOperationsMask mask)
{
DragOperationsMask mask) {
REQUIRE_UI_THREAD();
// Forbid dragging of image files.
@ -292,8 +275,7 @@ bool ClientHandler::OnDragStart(CefRefPtr<CefBrowser> browser,
bool ClientHandler::OnDragEnter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> dragData,
DragOperationsMask mask)
{
DragOperationsMask mask) {
REQUIRE_UI_THREAD();
// Forbid dragging of link URLs.
@ -303,33 +285,29 @@ bool ClientHandler::OnDragEnter(CefRefPtr<CefBrowser> browser,
return false;
}
bool ClientHandler::OnBeforeScriptExtensionLoad(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& extensionName)
{
bool ClientHandler::OnBeforeScriptExtensionLoad(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& extensionName) {
return false;
}
void ClientHandler::NotifyDownloadComplete(const CefString& fileName)
{
void ClientHandler::NotifyDownloadComplete(const CefString& fileName) {
SetLastDownloadFile(fileName);
SendNotification(NOTIFY_DOWNLOAD_COMPLETE);
}
void ClientHandler::NotifyDownloadError(const CefString& fileName)
{
void ClientHandler::NotifyDownloadError(const CefString& fileName) {
SetLastDownloadFile(fileName);
SendNotification(NOTIFY_DOWNLOAD_ERROR);
}
void ClientHandler::SetMainHwnd(CefWindowHandle hwnd)
{
void ClientHandler::SetMainHwnd(CefWindowHandle hwnd) {
AutoLock lock_scope(this);
m_MainHwnd = hwnd;
}
void ClientHandler::SetEditHwnd(CefWindowHandle hwnd)
{
void ClientHandler::SetEditHwnd(CefWindowHandle hwnd) {
AutoLock lock_scope(this);
m_EditHwnd = hwnd;
}
@ -337,8 +315,7 @@ void ClientHandler::SetEditHwnd(CefWindowHandle hwnd)
void ClientHandler::SetButtonHwnds(CefWindowHandle backHwnd,
CefWindowHandle forwardHwnd,
CefWindowHandle reloadHwnd,
CefWindowHandle stopHwnd)
{
CefWindowHandle stopHwnd) {
AutoLock lock_scope(this);
m_BackHwnd = backHwnd;
m_ForwardHwnd = forwardHwnd;
@ -346,27 +323,23 @@ void ClientHandler::SetButtonHwnds(CefWindowHandle backHwnd,
m_StopHwnd = stopHwnd;
}
std::string ClientHandler::GetLogFile()
{
std::string ClientHandler::GetLogFile() {
AutoLock lock_scope(this);
return m_LogFile;
}
void ClientHandler::SetLastDownloadFile(const std::string& fileName)
{
void ClientHandler::SetLastDownloadFile(const std::string& fileName) {
AutoLock lock_scope(this);
m_LastDownloadFile = fileName;
}
std::string ClientHandler::GetLastDownloadFile()
{
std::string ClientHandler::GetLastDownloadFile() {
AutoLock lock_scope(this);
return m_LastDownloadFile;
}
void ClientHandler::AddDOMVisitor(const std::string& path,
CefRefPtr<CefDOMVisitor> visitor)
{
CefRefPtr<CefDOMVisitor> visitor) {
AutoLock lock_scope(this);
DOMVisitorMap::iterator it = m_DOMVisitors.find(path);
if (it == m_DOMVisitors.end())
@ -375,8 +348,7 @@ void ClientHandler::AddDOMVisitor(const std::string& path,
it->second = visitor;
}
CefRefPtr<CefDOMVisitor> ClientHandler::GetDOMVisitor(const std::string& path)
{
CefRefPtr<CefDOMVisitor> ClientHandler::GetDOMVisitor(const std::string& path) {
AutoLock lock_scope(this);
DOMVisitorMap::iterator it = m_DOMVisitors.find(path);
if (it != m_DOMVisitors.end())