win: Enable setting window icon in creation options.

This commit is contained in:
Cheng Zhao 2013-11-11 19:23:35 +08:00
parent d5ffa4dc77
commit baa6d9730c
4 changed files with 47 additions and 14 deletions

View file

@ -4,7 +4,6 @@
#include "browser/native_window_win.h"
#include "app/win/resource.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@ -33,8 +32,6 @@ namespace {
const int kResizeInsideBoundsSize = 5;
const int kResizeAreaCornerSize = 16;
HANDLE g_exe_icon = NULL;
// Wrapper of NativeWidgetWin to handle WM_MENUCOMMAND messages, which are
// triggered by window menus.
class MenuCommandNativeWidget : public views::NativeWidgetWin {
@ -220,16 +217,10 @@ NativeWindowWin::NativeWindowWin(content::WebContents* web_contents,
gfx::Size size(width, height);
window_->CenterWindow(size);
window_->UpdateWindowIcon();
web_view_->SetWebContents(web_contents);
OnViewWasResized();
if (g_exe_icon == NULL)
g_exe_icon = ::LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(1),
IMAGE_ICON, 0, 0, 0);
::SendMessage(window_->GetNativeWindow(),
WM_SETICON,
static_cast<WPARAM>(ICON_BIG),
reinterpret_cast<LPARAM>(g_exe_icon));
}
NativeWindowWin::~NativeWindowWin() {
@ -474,8 +465,15 @@ bool NativeWindowWin::ShouldHandleSystemCommands() const {
return true;
}
bool NativeWindowWin::ShouldShowWindowIcon() const {
return true;
gfx::ImageSkia NativeWindowWin::GetWindowAppIcon() {
if (icon_.IsEmpty())
return gfx::ImageSkia();
else
return *icon_.ToImageSkia();
}
gfx::ImageSkia NativeWindowWin::GetWindowIcon() {
return GetWindowAppIcon();
}
views::Widget* NativeWindowWin::GetWidget() {