88#include < string>
99
1010#include " ../executable.h"
11- #include " ../log .h"
11+ #include " ../logger .h"
1212#include " ../settings.h"
1313#include " ../string_utils.h"
1414#include " ../fatal_error.h"
@@ -55,24 +55,24 @@ BrowserWindow* GetBrowserWindow(HWND hwnd) {
5555 }
5656 // GetBrowserWindow() may fail during window creation, so log
5757 // severity is only DEBUG.
58- LOG_DEBUG << " GetBrowserWindow(): not found, hwnd = " << (int )hwnd;
58+ LOGGER_DEBUG << " GetBrowserWindow(): not found, hwnd = " << (char * )hwnd;
5959 return NULL ;
6060}
6161void StoreBrowserWindow (HWND hwnd, BrowserWindow* browser) {
62- LOG_DEBUG << " StoreBrowserWindow(): hwnd = " << (int )hwnd;
62+ LOGGER_DEBUG << " StoreBrowserWindow(): hwnd = " << (char * )hwnd;
6363 std::map<HWND, BrowserWindow*>::iterator it;
6464 it = g_browserWindows.find (hwnd);
6565 if (it == g_browserWindows.end ()) {
6666 g_browserWindows[hwnd] = browser;
6767 } else {
68- LOG_WARNING << " StoreBrowserWindow() failed: already stored" ;
68+ LOGGER_WARNING << " StoreBrowserWindow() failed: already stored" ;
6969 }
7070}
7171void RemoveBrowserWindow (HWND hwnd) {
72- LOG_DEBUG << " RemoveBrowserWindow(): hwnd = " << (int )hwnd;
72+ LOGGER_DEBUG << " RemoveBrowserWindow(): hwnd = " << (char * )hwnd;
7373 BrowserWindow* browser = GetBrowserWindow (hwnd);
7474 if (!browser) {
75- LOG_WARNING << " RemoveBrowserWindow() failed: "
75+ LOGGER_WARNING << " RemoveBrowserWindow() failed: "
7676 << " GetBrowserWindow() failed" ;
7777 return ;
7878 }
@@ -83,28 +83,28 @@ void RemoveBrowserWindow(HWND hwnd) {
8383 g_browserWindows.erase (it);
8484 delete browser;
8585 } else {
86- LOG_WARNING << " RemoveBrowserWindow() failed: not found" ;
86+ LOGGER_WARNING << " RemoveBrowserWindow() failed: not found" ;
8787 }
8888}
8989
90- int CountBrowserWindows ()
90+ size_t CountBrowserWindows ()
9191{
9292 return g_browserWindows.size ();
9393}
9494
9595BrowserWindow::BrowserWindow (HWND inWindowHandle, bool isPopup)
9696 : windowHandle_(inWindowHandle),
9797 isPopup_(isPopup),
98- cefBrowser_(NULL ),
99- fullscreen_(NULL )
98+ cefBrowser_(nullptr ),
99+ fullscreen_(nullptr )
100100{
101101 _ASSERT (windowHandle_);
102102
103103 SetTitleFromSettings ();
104104 SetIconFromSettings ();
105105
106106 if (IsPopup ()) {
107- LOG_DEBUG << " BrowserWindow::BrowserWindow() created for Popup" ;
107+ LOGGER_DEBUG << " BrowserWindow::BrowserWindow() created for Popup" ;
108108 } else {
109109 if (!CreateBrowserControl (Utf8ToWide (GetWebServerUrl ()).c_str ())) {
110110 FatalError (windowHandle_, " Could not create Browser control.\n "
@@ -124,7 +124,7 @@ void BrowserWindow::SetCefBrowser(CefRefPtr<CefBrowser> cefBrowser) {
124124 // Called from ClientHandler::OnAfterCreated().
125125 _ASSERT (!cefBrowser_);
126126 if (cefBrowser_) {
127- LOG_ERROR << " BrowserWindow::SetCefBrowser() called, "
127+ LOGGER_ERROR << " BrowserWindow::SetCefBrowser() called, "
128128 << " but it is already set" ;
129129 return ;
130130 }
@@ -138,7 +138,7 @@ void BrowserWindow::SetCefBrowser(CefRefPtr<CefBrowser> cefBrowser) {
138138 CefRefPtr<CefProcessMessage> message = \
139139 CefProcessMessage::Create (" SetIsFullscreen" );
140140 message->GetArgumentList ()->SetBool (0 , fullscreen_->IsFullscreen ());
141- cefBrowser->SendProcessMessage (PID_RENDERER, message);
141+ cefBrowser->GetMainFrame ()-> SendProcessMessage (PID_RENDERER, message);
142142 }
143143 }
144144
@@ -147,28 +147,31 @@ void BrowserWindow::SetCefBrowser(CefRefPtr<CefBrowser> cefBrowser) {
147147 this ->OnSize ();
148148}
149149bool BrowserWindow::CreateBrowserControl (const wchar_t * navigateUrl) {
150- LOG_DEBUG << " BrowserWindow::CreateBrowserControl()" ;
150+ LOGGER_DEBUG << " BrowserWindow::CreateBrowserControl()" ;
151151 // This is called only for the main window.
152152 // Popup cef browsers are created internally by CEF,
153153 // see OnBeforePopup, OnAfterCreated.
154154 RECT rect;
155155 BOOL b = GetWindowRect (windowHandle_, &rect);
156156 if (!b) {
157- LOG_ERROR << " GetWindowRect() failed in "
157+ LOGGER_ERROR << " GetWindowRect() failed in "
158158 " BrowserWindow::CreateBrowserControl()" ;
159159 }
160160
161161 // Information used when creating the native window.
162162 CefWindowInfo window_info;
163- window_info.SetAsChild (windowHandle_, rect);
163+ int width = rect.right - rect.left ;
164+ int height = rect.bottom - rect.top ;
165+ CefRect cef_rect (rect.left , rect.top , width, height);
166+ window_info.SetAsChild (windowHandle_, cef_rect);
164167 // SimpleHandler implements browser-level callbacks.
165168 CefRefPtr<ClientHandler> handler (new ClientHandler ());
166169 // Specify CEF browser settings here.
167170 CefBrowserSettings browser_settings;
168171 // Create the first browser window.
169172 CefBrowserHost::CreateBrowser (
170173 window_info, handler.get (),
171- GetWebServerUrl (), browser_settings, NULL );
174+ GetWebServerUrl (), browser_settings, nullptr , nullptr );
172175
173176 return true ;
174177}
@@ -227,7 +230,7 @@ void BrowserWindow::OnSize() {
227230 SWP_NOZORDER);
228231 EndDeferWindowPos (hdwp);
229232 } else {
230- LOG_DEBUG << " BrowserWindow::OnSize(): "
233+ LOGGER_DEBUG << " BrowserWindow::OnSize(): "
231234 " CefBrowser object not yet created" ;
232235 }
233236}
@@ -260,7 +263,7 @@ void BrowserWindow::SetIconFromSettings() {
260263 if (bigIcon) {
261264 SendMessage (windowHandle_, WM_SETICON, ICON_BIG, (LPARAM)bigIcon);
262265 } else {
263- LOG_WARNING << " Setting icon from settings file failed "
266+ LOGGER_WARNING << " Setting icon from settings file failed "
264267 " (ICON_BIG)" ;
265268 }
266269 int smallX = GetSystemMetrics (SM_CXSMICON);
@@ -270,7 +273,7 @@ void BrowserWindow::SetIconFromSettings() {
270273 if (smallIcon) {
271274 SendMessage (windowHandle_, WM_SETICON, ICON_SMALL, (LPARAM)smallIcon);
272275 } else {
273- LOG_WARNING << " Setting icon from settings file failed "
276+ LOGGER_WARNING << " Setting icon from settings file failed "
274277 " (ICON_SMALL)" ;
275278 }
276279 } else if (IsPopup ()) {
@@ -280,7 +283,7 @@ void BrowserWindow::SetIconFromSettings() {
280283 if (smallIcon) {
281284 SendMessage (windowHandle_, WM_SETICON, ICON_SMALL, (LPARAM)smallIcon);
282285 } else {
283- LOG_WARNING << " LoadIcon(IDR_MAINWINDOW) failed "
286+ LOGGER_WARNING << " LoadIcon(IDR_MAINWINDOW) failed "
284287 << " in BrowserWindow::SetIconFromSettings()" ;
285288 }
286289 }
0 commit comments