From d0639c9f4e35e78b223ee9daaf20ed727ab918fc Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Sat, 13 Dec 2008 18:42:19 +0000 Subject: [PATCH] libcef: Modifications due to underlying chromium changes. - Change gfx::WindowHandle to gfx::NativeWindow and gfx::ViewHandle to gfx::NativeView. - Add proxy support to BrowserWebViewDelegate. - Add webkit\port\platform\graphics\skia path to libcef_webkit_includes.vsprops due to relocation of PlatformContextSkia.h. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@4 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- CHROMIUM_BUILD_COMPATIBILITY.txt | 1 + libcef/browser_request_context.cc | 20 ++- libcef/browser_request_context.h | 6 +- libcef/browser_webkit_glue_win.cc | 182 +++++++++++++------------- libcef/browser_webview_delegate.cc | 2 +- libcef/browser_webview_delegate.h | 4 +- libcef/context.cc | 2 +- libcef/libcef_webkit_includes.vsprops | 2 +- libcef/webview_host.cc | 2 +- libcef/webview_host.h | 2 +- libcef/webwidget_host.cc | 4 +- libcef/webwidget_host.h | 12 +- 12 files changed, 125 insertions(+), 114 deletions(-) diff --git a/CHROMIUM_BUILD_COMPATIBILITY.txt b/CHROMIUM_BUILD_COMPATIBILITY.txt index 6737d51a8..3efdeff68 100644 --- a/CHROMIUM_BUILD_COMPATIBILITY.txt +++ b/CHROMIUM_BUILD_COMPATIBILITY.txt @@ -9,3 +9,4 @@ Date | CEF Revision | Chromium Revision ------------------------------------------------------------------------------- 2008-12-02 | /trunk@2 | /trunk@6213 2008-12-05 | /trunk@3 | /trunk@6430 +2008-12-13 | /trunk@4 | /trunk@6968 diff --git a/libcef/browser_request_context.cc b/libcef/browser_request_context.cc index 3f8b90bae..009ad30cd 100644 --- a/libcef/browser_request_context.cc +++ b/libcef/browser_request_context.cc @@ -7,21 +7,24 @@ #include "browser_request_context.h" #include "net/base/cookie_monster.h" +#include "net/proxy/proxy_service.h" #include "webkit/glue/webkit_glue.h" BrowserRequestContext::BrowserRequestContext() { - Init(std::wstring(), net::HttpCache::NORMAL); + Init(std::wstring(), net::HttpCache::NORMAL, false); } BrowserRequestContext::BrowserRequestContext( const std::wstring& cache_path, - net::HttpCache::Mode cache_mode) { - Init(cache_path, cache_mode); + net::HttpCache::Mode cache_mode, + bool no_proxy) { + Init(cache_path, cache_mode, no_proxy); } void BrowserRequestContext::Init( const std::wstring& cache_path, - net::HttpCache::Mode cache_mode) { + net::HttpCache::Mode cache_mode, + bool no_proxy) { cookie_store_ = new net::CookieMonster(); user_agent_ = webkit_glue::GetUserAgent(); @@ -30,11 +33,15 @@ void BrowserRequestContext::Init( accept_language_ = "en-us,en"; accept_charset_ = "iso-8859-1,*,utf-8"; + net::ProxyInfo proxy_info; + proxy_info.UseDirect(); + proxy_service_ = net::ProxyService::Create(no_proxy ? &proxy_info : NULL); + net::HttpCache *cache; if (cache_path.empty()) { - cache = new net::HttpCache(NULL, 0); + cache = new net::HttpCache(proxy_service_, 0); } else { - cache = new net::HttpCache(NULL, cache_path, 0); + cache = new net::HttpCache(proxy_service_, cache_path, 0); } cache->set_mode(cache_mode); http_transaction_factory_ = cache; @@ -43,5 +50,6 @@ void BrowserRequestContext::Init( BrowserRequestContext::~BrowserRequestContext() { delete cookie_store_; delete http_transaction_factory_; + delete proxy_service_; } diff --git a/libcef/browser_request_context.h b/libcef/browser_request_context.h index a1a3c85d4..ec68aa33a 100644 --- a/libcef/browser_request_context.h +++ b/libcef/browser_request_context.h @@ -18,12 +18,14 @@ class BrowserRequestContext : public URLRequestContext { // Use an on-disk cache at the specified location. Optionally, use the cache // in playback or record mode. BrowserRequestContext(const std::wstring& cache_path, - net::HttpCache::Mode cache_mode); + net::HttpCache::Mode cache_mode, + bool no_proxy); ~BrowserRequestContext(); private: - void Init(const std::wstring& cache_path, net::HttpCache::Mode cache_mode); + void Init(const std::wstring& cache_path, net::HttpCache::Mode cache_mode, + bool no_proxy); }; #endif // _BROWSER_REQUEST_CONTEXT_H diff --git a/libcef/browser_webkit_glue_win.cc b/libcef/browser_webkit_glue_win.cc index 6705434ee..95aa2f74d 100644 --- a/libcef/browser_webkit_glue_win.cc +++ b/libcef/browser_webkit_glue_win.cc @@ -1,106 +1,106 @@ -// Copyright (c) 2008 The Chromium Embedded Framework Authors. -// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - +// Copyright (c) 2008 The Chromium Embedded Framework Authors. +// Portions copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + #include "precompiled_libcef.h" #include "browser_webkit_glue.h" #include -#include -#include +#include +#include #include "base/compiler_specific.h" - -#include "config.h" -#include "webkit_version.h" -MSVC_PUSH_WARNING_LEVEL(0); + +#include "config.h" +#include "webkit_version.h" +MSVC_PUSH_WARNING_LEVEL(0); #include "PlatformContextSkia.h" MSVC_POP_WARNING(); #undef LOG -#include "base/gfx/gdi_util.h" +#include "base/gfx/gdi_util.h" #include "base/logging.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webview.h" #include "webkit/glue/plugins/plugin_list.h" - -namespace webkit_glue { - -std::wstring GetLocalizedString(int message_id) { - const ATLSTRINGRESOURCEIMAGE* image = - AtlGetStringResourceImage(_AtlBaseModule.GetModuleInstance(), - message_id); - // TODO(cef): Need to provide strings for common resources. - if (!image) { - NOTREACHED(); - return L"No string for this identifier!"; - } - return std::wstring(image->achString, image->nLength); -} - -HCURSOR LoadCursor(int cursor_id) { - return NULL; -} - -bool GetPlugins(bool refresh, std::vector* plugins) { - return NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins); -} - -bool EnsureFontLoaded(HFONT font) { - return true; -} - -bool DownloadUrl(const std::string& url, HWND caller_window) { - return false; -} - -ScreenInfo GetScreenInfo(gfx::ViewHandle window) { - return GetScreenInfoHelper(window); -} - -void CaptureWebViewBitmap(HWND mainWnd, WebView* webview, HBITMAP& bitmap, SIZE& size) -{ - gfx::Size webSize = webview->GetSize(); - size.cx = webSize.width(); - size.cy = webSize.height(); - - gfx::PlatformCanvasWin canvas(size.cx, size.cy, true); - canvas.drawARGB(255, 255, 255, 255, SkPorterDuff::kSrc_Mode); - PlatformContextSkia context(&canvas); - gfx::Rect rect(size.cx, size.cy); - webview->Layout(); - webview->Paint(&canvas, rect); - - HDC hRefDC = GetDC(mainWnd); - HDC hDC = CreateCompatibleDC(hRefDC); - bitmap = CreateCompatibleBitmap(hRefDC, size.cx, size.cy); - DCHECK(bitmap != NULL); - HBITMAP hOldBmp = (HBITMAP)SelectObject(hDC, bitmap); - - // Create a BMP v4 header that we can serialize. - BITMAPV4HEADER bitmap_header; - gfx::CreateBitmapV4Header(size.cx, size.cy, &bitmap_header); - const SkBitmap& src_bmp = canvas.getDevice()->accessBitmap(true); - SkAutoLockPixels src_lock(src_bmp); - int retval = StretchDIBits(hDC, - 0, - 0, - size.cx, size.cy, - 0, 0, - size.cx, size.cy, - src_bmp.getPixels(), - reinterpret_cast(&bitmap_header), - DIB_RGB_COLORS, - SRCCOPY); - DCHECK(retval != GDI_ERROR); - - SelectObject(hDC, hOldBmp); - DeleteDC(hDC); - ReleaseDC(mainWnd, hRefDC); -} - + +namespace webkit_glue { + +std::wstring GetLocalizedString(int message_id) { + const ATLSTRINGRESOURCEIMAGE* image = + AtlGetStringResourceImage(_AtlBaseModule.GetModuleInstance(), + message_id); + // TODO(cef): Need to provide strings for common resources. + if (!image) { + NOTREACHED(); + return L"No string for this identifier!"; + } + return std::wstring(image->achString, image->nLength); +} + +HCURSOR LoadCursor(int cursor_id) { + return NULL; +} + +bool GetPlugins(bool refresh, std::vector* plugins) { + return NPAPI::PluginList::Singleton()->GetPlugins(refresh, plugins); +} + +bool EnsureFontLoaded(HFONT font) { + return true; +} + +bool DownloadUrl(const std::string& url, HWND caller_window) { + return false; +} + +ScreenInfo GetScreenInfo(gfx::NativeView window) { + return GetScreenInfoHelper(window); +} + +void CaptureWebViewBitmap(HWND mainWnd, WebView* webview, HBITMAP& bitmap, SIZE& size) +{ + gfx::Size webSize = webview->GetSize(); + size.cx = webSize.width(); + size.cy = webSize.height(); + + gfx::PlatformCanvasWin canvas(size.cx, size.cy, true); + canvas.drawARGB(255, 255, 255, 255, SkPorterDuff::kSrc_Mode); + PlatformContextSkia context(&canvas); + gfx::Rect rect(size.cx, size.cy); + webview->Layout(); + webview->Paint(&canvas, rect); + + HDC hRefDC = GetDC(mainWnd); + HDC hDC = CreateCompatibleDC(hRefDC); + bitmap = CreateCompatibleBitmap(hRefDC, size.cx, size.cy); + DCHECK(bitmap != NULL); + HBITMAP hOldBmp = (HBITMAP)SelectObject(hDC, bitmap); + + // Create a BMP v4 header that we can serialize. + BITMAPV4HEADER bitmap_header; + gfx::CreateBitmapV4Header(size.cx, size.cy, &bitmap_header); + const SkBitmap& src_bmp = canvas.getDevice()->accessBitmap(true); + SkAutoLockPixels src_lock(src_bmp); + int retval = StretchDIBits(hDC, + 0, + 0, + size.cx, size.cy, + 0, 0, + size.cx, size.cy, + src_bmp.getPixels(), + reinterpret_cast(&bitmap_header), + DIB_RGB_COLORS, + SRCCOPY); + DCHECK(retval != GDI_ERROR); + + SelectObject(hDC, hOldBmp); + DeleteDC(hDC); + ReleaseDC(mainWnd, hRefDC); +} + static PBITMAPINFO BmpCreateInfo(HBITMAP hBmp) { @@ -286,6 +286,6 @@ BOOL SaveBitmapToFile(HBITMAP hBmp, HDC hDC, LPCTSTR file, LPBYTE lpBits) LocalFree(pbmi); } return ret; -} - -} // namespace webkit_glue +} + +} // namespace webkit_glue diff --git a/libcef/browser_webview_delegate.cc b/libcef/browser_webview_delegate.cc index 546635526..7e53952cc 100644 --- a/libcef/browser_webview_delegate.cc +++ b/libcef/browser_webview_delegate.cc @@ -468,7 +468,7 @@ void BrowserWebViewDelegate::SetUserStyleSheetLocation(const GURL& location) { // WebWidgetDelegate --------------------------------------------------------- -gfx::ViewHandle BrowserWebViewDelegate::GetContainingWindow(WebWidget* webwidget) { +gfx::NativeView BrowserWebViewDelegate::GetContainingWindow(WebWidget* webwidget) { if (WebWidgetHost* host = GetHostForWidget(webwidget)) return host->window_handle(); diff --git a/libcef/browser_webview_delegate.h b/libcef/browser_webview_delegate.h index c22145e17..75cead084 100644 --- a/libcef/browser_webview_delegate.h +++ b/libcef/browser_webview_delegate.h @@ -179,7 +179,7 @@ class BrowserWebViewDelegate : public base::RefCounted, virtual int GetHistoryForwardListCount(); // WebWidgetDelegate - virtual gfx::ViewHandle GetContainingWindow(WebWidget* webwidget); + virtual gfx::NativeView GetContainingWindow(WebWidget* webwidget); virtual void DidInvalidateRect(WebWidget* webwidget, const gfx::Rect& rect); virtual void DidScrollRect(WebWidget* webwidget, int dx, int dy, const gfx::Rect& clip_rect); @@ -192,7 +192,7 @@ class BrowserWebViewDelegate : public base::RefCounted, virtual void GetWindowRect(WebWidget* webwidget, gfx::Rect* rect); virtual void SetWindowRect(WebWidget* webwidget, const gfx::Rect& rect); virtual void GetRootWindowRect(WebWidget *,gfx::Rect *); - virtual void GetRootWindowResizerRect(WebWidget* webwidget, gfx::Rect* rect); + virtual void GetRootWindowResizerRect(WebWidget* webwidget, gfx::Rect* rect); virtual void DidMove(WebWidget* webwidget, const WebPluginGeometry& move); virtual void RunModal(WebWidget* webwidget); virtual bool IsHidden(); diff --git a/libcef/context.cc b/libcef/context.cc index 2b87fcbc5..98ae29241 100644 --- a/libcef/context.cc +++ b/libcef/context.cc @@ -98,7 +98,7 @@ DWORD WINAPI ThreadHandlerUI(LPVOID lpParam) std::wstring cache_path; PathService::Get(base::DIR_EXE, &cache_path); BrowserResourceLoaderBridge::Init( - new BrowserRequestContext(cache_path, net::HttpCache::NORMAL)); + new BrowserRequestContext(cache_path, net::HttpCache::NORMAL, false)); // Load ICU data tables. bool ret = icu_util::Initialize(); diff --git a/libcef/libcef_webkit_includes.vsprops b/libcef/libcef_webkit_includes.vsprops index 2092a56a4..0f7e1bdcd 100644 --- a/libcef/libcef_webkit_includes.vsprops +++ b/libcef/libcef_webkit_includes.vsprops @@ -6,6 +6,6 @@ > diff --git a/libcef/webview_host.cc b/libcef/webview_host.cc index 51c300092..1980ea7dd 100644 --- a/libcef/webview_host.cc +++ b/libcef/webview_host.cc @@ -15,7 +15,7 @@ static const wchar_t kWindowClassName[] = L"WebViewHost"; /*static*/ -WebViewHost* WebViewHost::Create(gfx::WindowHandle parent_window, +WebViewHost* WebViewHost::Create(gfx::NativeWindow parent_window, WebViewDelegate* delegate, const WebPreferences& prefs) { WebViewHost* host = new WebViewHost(); diff --git a/libcef/webview_host.h b/libcef/webview_host.h index bd7103ec6..d54d99361 100644 --- a/libcef/webview_host.h +++ b/libcef/webview_host.h @@ -21,7 +21,7 @@ class WebViewHost : public WebWidgetHost { // The new instance is deleted once the associated ViewHandle is destroyed. // The newly created window should be resized after it is created, using the // MoveWindow (or equivalent) function. - static WebViewHost* Create(gfx::WindowHandle parent_window, + static WebViewHost* Create(gfx::NativeWindow parent_window, WebViewDelegate* delegate, const WebPreferences& prefs); diff --git a/libcef/webwidget_host.cc b/libcef/webwidget_host.cc index d73f39eee..93eed9ce4 100644 --- a/libcef/webwidget_host.cc +++ b/libcef/webwidget_host.cc @@ -15,7 +15,7 @@ static const wchar_t kWindowClassName[] = L"WebWidgetHost"; /*static*/ -WebWidgetHost* WebWidgetHost::Create(gfx::WindowHandle parent_window, +WebWidgetHost* WebWidgetHost::Create(gfx::NativeWindow parent_window, WebWidgetDelegate* delegate) { WebWidgetHost* host = new WebWidgetHost(); @@ -45,7 +45,7 @@ WebWidgetHost* WebWidgetHost::Create(gfx::WindowHandle parent_window, } /*static*/ -WebWidgetHost* WebWidgetHost::FromWindow(gfx::WindowHandle hwnd) { +WebWidgetHost* WebWidgetHost::FromWindow(gfx::NativeWindow hwnd) { return reinterpret_cast(win_util::GetWindowUserData(hwnd)); } diff --git a/libcef/webwidget_host.h b/libcef/webwidget_host.h index 9fe303bbe..42c5ebcb4 100644 --- a/libcef/webwidget_host.h +++ b/libcef/webwidget_host.h @@ -24,15 +24,15 @@ class WebWidgetHost { // The new instance is deleted once the associated ViewHandle is destroyed. // The newly created window should be resized after it is created, using the // MoveWindow (or equivalent) function. - static WebWidgetHost* Create(gfx::WindowHandle parent_window, + static WebWidgetHost* Create(gfx::NativeWindow parent_window, WebWidgetDelegate* delegate); - static WebWidgetHost* FromWindow(gfx::WindowHandle view); + static WebWidgetHost* FromWindow(gfx::NativeWindow view); #if defined(OS_MACOSX) - static void HandleEvent(gfx::WindowHandle window, NSEvent *event); + static void HandleEvent(gfx::NativeWindow window, NSEvent *event); #endif - gfx::ViewHandle window_handle() const { return view_; } + gfx::NativeView window_handle() const { return view_; } WebWidget* webwidget() const { return webwidget_; } void DidInvalidateRect(const gfx::Rect& rect); @@ -83,7 +83,7 @@ class WebWidgetHost { // parent: a GtkBox to pack the new widget at the end of // host: a pointer to a WebWidgetHost (or subclass thereof) // --------------------------------------------------------------------------- - static gfx::WindowHandle CreateWindow(gfx::WindowHandle parent, void* host); + static gfx::NativeWindow CreateWindow(gfx::NativeWindow parent, void* host); void WindowDestroyed(); void Resize(const gfx::Size& size); #endif @@ -98,7 +98,7 @@ class WebWidgetHost { #endif } - gfx::ViewHandle view_; + gfx::NativeView view_; WebWidget* webwidget_; scoped_ptr canvas_;