mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
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
This commit is contained in:
@@ -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 <atlcore.h>
|
||||
#include <atlbase.h>
|
||||
#include <commdlg.h>
|
||||
#include <atlbase.h>
|
||||
#include <commdlg.h>
|
||||
|
||||
#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<WebPluginInfo>* 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<BITMAPINFO*>(&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<WebPluginInfo>* 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<BITMAPINFO*>(&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
|
||||
|
Reference in New Issue
Block a user