mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Apply clang-format to all C, C++ and ObjC files (issue #2171)
This commit is contained in:
@@ -14,8 +14,7 @@ CefBrowserPlatformDelegateNative::CefBrowserPlatformDelegateNative(
|
||||
SkColor background_color)
|
||||
: window_info_(window_info),
|
||||
background_color_(background_color),
|
||||
windowless_handler_(nullptr) {
|
||||
}
|
||||
windowless_handler_(nullptr) {}
|
||||
|
||||
SkColor CefBrowserPlatformDelegateNative::GetBackgroundColor() const {
|
||||
return background_color_;
|
||||
|
@@ -48,8 +48,7 @@ CefBrowserPlatformDelegateNativeLinux::CefBrowserPlatformDelegateNativeLinux(
|
||||
: CefBrowserPlatformDelegateNative(window_info, background_color),
|
||||
host_window_created_(false),
|
||||
window_widget_(nullptr),
|
||||
window_x11_(nullptr) {
|
||||
}
|
||||
window_x11_(nullptr) {}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::BrowserDestroyed(
|
||||
CefBrowserHostImpl* browser) {
|
||||
@@ -70,8 +69,8 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
|
||||
if (window_info_.height == 0)
|
||||
window_info_.height = 600;
|
||||
|
||||
gfx::Rect rect(window_info_.x, window_info_.y,
|
||||
window_info_.width, window_info_.height);
|
||||
gfx::Rect rect(window_info_.x, window_info_.y, window_info_.width,
|
||||
window_info_.height);
|
||||
|
||||
// Create a new window object. It will delete itself when the associated X11
|
||||
// window is destroyed.
|
||||
@@ -85,8 +84,7 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
|
||||
|
||||
CefWindowDelegateView* delegate_view =
|
||||
new CefWindowDelegateView(GetBackgroundColor());
|
||||
delegate_view->Init(window_info_.window,
|
||||
browser_->web_contents(),
|
||||
delegate_view->Init(window_info_.window, browser_->web_contents(),
|
||||
gfx::Rect(gfx::Point(), rect.size()));
|
||||
|
||||
window_widget_ = delegate_view->GetWidget();
|
||||
@@ -109,7 +107,8 @@ bool CefBrowserPlatformDelegateNativeLinux::CreateHostWindow() {
|
||||
prefs->inactive_selection_fg_color = SkColorSetRGB(50, 50, 50);
|
||||
|
||||
// Set font-related attributes.
|
||||
CR_DEFINE_STATIC_LOCAL(const gfx::FontRenderParams, params,
|
||||
CR_DEFINE_STATIC_LOCAL(
|
||||
const gfx::FontRenderParams, params,
|
||||
(gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(), NULL)));
|
||||
prefs->should_antialias_text = params.antialiasing;
|
||||
prefs->use_subpixel_positioning = params.subpixel_positioning;
|
||||
@@ -128,8 +127,8 @@ void CefBrowserPlatformDelegateNativeLinux::CloseHostWindow() {
|
||||
window_x11_->Close();
|
||||
}
|
||||
|
||||
CefWindowHandle
|
||||
CefBrowserPlatformDelegateNativeLinux::GetHostWindowHandle() const {
|
||||
CefWindowHandle CefBrowserPlatformDelegateNativeLinux::GetHostWindowHandle()
|
||||
const {
|
||||
if (windowless_handler_)
|
||||
return windowless_handler_->GetParentWindowHandle();
|
||||
return window_info_.window;
|
||||
@@ -176,8 +175,8 @@ void CefBrowserPlatformDelegateNativeLinux::NotifyMoveOrResizeStarted() {
|
||||
// Send updated screen rectangle information to the renderer process so that
|
||||
// popups are displayed in the correct location.
|
||||
content::RenderWidgetHostImpl::From(
|
||||
browser_->web_contents()->GetRenderViewHost()->GetWidget())->
|
||||
SendScreenRects();
|
||||
browser_->web_contents()->GetRenderViewHost()->GetWidget())
|
||||
->SendScreenRects();
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::SizeTo(int width, int height) {
|
||||
@@ -239,8 +238,7 @@ void CefBrowserPlatformDelegateNativeLinux::HandleKeyboardEvent(
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::HandleExternalProtocol(
|
||||
const GURL& url) {
|
||||
}
|
||||
const GURL& url) {}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
|
||||
content::NativeWebKeyboardEvent& result,
|
||||
@@ -249,25 +247,24 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
|
||||
result.native_key_code = key_event.native_key_code;
|
||||
result.is_system_key = key_event.is_system_key ? 1 : 0;
|
||||
switch (key_event.type) {
|
||||
case KEYEVENT_RAWKEYDOWN:
|
||||
case KEYEVENT_KEYDOWN:
|
||||
result.SetType(blink::WebInputEvent::kRawKeyDown);
|
||||
break;
|
||||
case KEYEVENT_KEYUP:
|
||||
result.SetType(blink::WebInputEvent::kKeyUp);
|
||||
break;
|
||||
case KEYEVENT_CHAR:
|
||||
result.SetType(blink::WebInputEvent::kChar);
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
case KEYEVENT_RAWKEYDOWN:
|
||||
case KEYEVENT_KEYDOWN:
|
||||
result.SetType(blink::WebInputEvent::kRawKeyDown);
|
||||
break;
|
||||
case KEYEVENT_KEYUP:
|
||||
result.SetType(blink::WebInputEvent::kKeyUp);
|
||||
break;
|
||||
case KEYEVENT_CHAR:
|
||||
result.SetType(blink::WebInputEvent::kChar);
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
// Populate DOM values that will be passed to JavaScript handlers via
|
||||
// KeyboardEvent.
|
||||
result.dom_code =
|
||||
static_cast<int>(ui::KeycodeConverter::NativeKeycodeToDomCode(
|
||||
key_event.native_key_code));
|
||||
result.dom_code = static_cast<int>(
|
||||
ui::KeycodeConverter::NativeKeycodeToDomCode(key_event.native_key_code));
|
||||
int keysym = ui::XKeysymForWindowsKeyCode(
|
||||
static_cast<ui::KeyboardCode>(key_event.windows_key_code),
|
||||
!!(key_event.modifiers & EVENTFLAG_SHIFT_DOWN));
|
||||
@@ -277,35 +274,36 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateKeyEvent(
|
||||
result.text[0] = key_event.character;
|
||||
result.unmodified_text[0] = key_event.unmodified_character;
|
||||
|
||||
result.SetModifiers(
|
||||
result.GetModifiers() | TranslateModifiers(key_event.modifiers));
|
||||
result.SetModifiers(result.GetModifiers() |
|
||||
TranslateModifiers(key_event.modifiers));
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeLinux::TranslateClickEvent(
|
||||
blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp, int clickCount) const {
|
||||
bool mouseUp,
|
||||
int clickCount) const {
|
||||
TranslateMouseEvent(result, mouse_event);
|
||||
|
||||
switch (type) {
|
||||
case MBT_LEFT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kLeft;
|
||||
break;
|
||||
case MBT_MIDDLE:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kMiddle;
|
||||
break;
|
||||
case MBT_RIGHT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kRight;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
case MBT_LEFT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kLeft;
|
||||
break;
|
||||
case MBT_MIDDLE:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kMiddle;
|
||||
break;
|
||||
case MBT_RIGHT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kRight;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
result.click_count = clickCount;
|
||||
@@ -338,7 +336,8 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateMoveEvent(
|
||||
void CefBrowserPlatformDelegateNativeLinux::TranslateWheelEvent(
|
||||
blink::WebMouseWheelEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
int deltaX, int deltaY) const {
|
||||
int deltaX,
|
||||
int deltaY) const {
|
||||
result = blink::WebMouseWheelEvent();
|
||||
TranslateMouseEvent(result, mouse_event);
|
||||
|
||||
@@ -374,7 +373,7 @@ CefEventHandle CefBrowserPlatformDelegateNativeLinux::GetEventHandle(
|
||||
}
|
||||
|
||||
std::unique_ptr<CefMenuRunner>
|
||||
CefBrowserPlatformDelegateNativeLinux::CreateMenuRunner() {
|
||||
CefBrowserPlatformDelegateNativeLinux::CreateMenuRunner() {
|
||||
return base::WrapUnique(new CefMenuRunnerLinux);
|
||||
}
|
||||
|
||||
@@ -389,10 +388,9 @@ void CefBrowserPlatformDelegateNativeLinux::TranslateMouseEvent(
|
||||
result.SetPositionInScreen(screen_pt.x(), screen_pt.y());
|
||||
|
||||
// modifiers
|
||||
result.SetModifiers(
|
||||
result.GetModifiers() | TranslateModifiers(mouse_event.modifiers));
|
||||
result.SetModifiers(result.GetModifiers() |
|
||||
TranslateModifiers(mouse_event.modifiers));
|
||||
|
||||
// timestamp
|
||||
result.SetTimeStampSeconds(GetSystemUptime());
|
||||
}
|
||||
|
||||
|
@@ -10,8 +10,8 @@
|
||||
class CefWindowX11;
|
||||
|
||||
// Windowed browser implementation for Linux.
|
||||
class CefBrowserPlatformDelegateNativeLinux :
|
||||
public CefBrowserPlatformDelegateNative {
|
||||
class CefBrowserPlatformDelegateNativeLinux
|
||||
: public CefBrowserPlatformDelegateNative {
|
||||
public:
|
||||
CefBrowserPlatformDelegateNativeLinux(const CefWindowInfo& window_info,
|
||||
SkColor background_color);
|
||||
@@ -35,13 +35,15 @@ class CefBrowserPlatformDelegateNativeLinux :
|
||||
void TranslateClickEvent(blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp, int clickCount) const override;
|
||||
bool mouseUp,
|
||||
int clickCount) const override;
|
||||
void TranslateMoveEvent(blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
bool mouseLeave) const override;
|
||||
void TranslateWheelEvent(blink::WebMouseWheelEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
int deltaX, int deltaY) const override;
|
||||
int deltaX,
|
||||
int deltaY) const override;
|
||||
CefEventHandle GetEventHandle(
|
||||
const content::NativeWebKeyboardEvent& event) const override;
|
||||
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
|
||||
|
@@ -8,8 +8,8 @@
|
||||
#include "libcef/browser/native/browser_platform_delegate_native.h"
|
||||
|
||||
// Windowed browser implementation for Mac OS X.
|
||||
class CefBrowserPlatformDelegateNativeMac :
|
||||
public CefBrowserPlatformDelegateNative {
|
||||
class CefBrowserPlatformDelegateNativeMac
|
||||
: public CefBrowserPlatformDelegateNative {
|
||||
public:
|
||||
CefBrowserPlatformDelegateNativeMac(const CefWindowInfo& window_info,
|
||||
SkColor background_color);
|
||||
@@ -30,13 +30,15 @@ class CefBrowserPlatformDelegateNativeMac :
|
||||
void TranslateClickEvent(blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp, int clickCount) const override;
|
||||
bool mouseUp,
|
||||
int clickCount) const override;
|
||||
void TranslateMoveEvent(blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
bool mouseLeave) const override;
|
||||
void TranslateWheelEvent(blink::WebMouseWheelEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
int deltaX, int deltaY) const override;
|
||||
int deltaX,
|
||||
int deltaY) const override;
|
||||
CefEventHandle GetEventHandle(
|
||||
const content::NativeWebKeyboardEvent& event) const override;
|
||||
std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override;
|
||||
|
@@ -23,8 +23,8 @@
|
||||
#include "third_party/WebKit/public/platform/WebInputEvent.h"
|
||||
#include "third_party/WebKit/public/platform/WebMouseEvent.h"
|
||||
#include "third_party/WebKit/public/platform/WebMouseWheelEvent.h"
|
||||
#import "ui/base/cocoa/cocoa_base_utils.h"
|
||||
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
|
||||
#import "ui/base/cocoa/cocoa_base_utils.h"
|
||||
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
|
||||
#include "ui/events/keycodes/keyboard_codes_posix.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
CefBrowserHostImpl* browser_; // weak
|
||||
}
|
||||
|
||||
@property (nonatomic, assign) CefBrowserHostImpl* browser;
|
||||
@property(nonatomic, assign) CefBrowserHostImpl* browser;
|
||||
|
||||
@end
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
@synthesize browser = browser_;
|
||||
|
||||
- (void) dealloc {
|
||||
- (void)dealloc {
|
||||
if (browser_) {
|
||||
// Force the browser to be destroyed and release the reference added in
|
||||
// PlatformCreateWindow().
|
||||
@@ -56,7 +56,7 @@
|
||||
@end
|
||||
|
||||
// Receives notifications from the browser window. Will delete itself when done.
|
||||
@interface CefWindowDelegate : NSObject <NSWindowDelegate> {
|
||||
@interface CefWindowDelegate : NSObject<NSWindowDelegate> {
|
||||
@private
|
||||
CefBrowserHostImpl* browser_; // weak
|
||||
NSWindow* window_;
|
||||
@@ -144,8 +144,7 @@ CefBrowserPlatformDelegateNativeMac::CefBrowserPlatformDelegateNativeMac(
|
||||
const CefWindowInfo& window_info,
|
||||
SkColor background_color)
|
||||
: CefBrowserPlatformDelegateNative(window_info, background_color),
|
||||
host_window_created_(false) {
|
||||
}
|
||||
host_window_created_(false) {}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeMac::BrowserDestroyed(
|
||||
CefBrowserHostImpl* browser) {
|
||||
@@ -168,9 +167,9 @@ bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
|
||||
if (parentView == nil) {
|
||||
// Create a new window.
|
||||
NSRect screen_rect = [[NSScreen mainScreen] visibleFrame];
|
||||
NSRect window_rect = {{window_info_.x,
|
||||
screen_rect.size.height - window_info_.y},
|
||||
{window_info_.width, window_info_.height}};
|
||||
NSRect window_rect = {
|
||||
{window_info_.x, screen_rect.size.height - window_info_.y},
|
||||
{window_info_.width, window_info_.height}};
|
||||
if (window_rect.size.width == 0)
|
||||
window_rect.size.width = 750;
|
||||
if (window_rect.size.height == 0)
|
||||
@@ -182,14 +181,13 @@ bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
|
||||
contentRect.size.height = window_rect.size.height;
|
||||
|
||||
newWnd = [[UnderlayOpenGLHostingWindow alloc]
|
||||
initWithContentRect:window_rect
|
||||
styleMask:(NSTitledWindowMask |
|
||||
NSClosableWindowMask |
|
||||
NSMiniaturizableWindowMask |
|
||||
NSResizableWindowMask |
|
||||
NSUnifiedTitleAndToolbarWindowMask )
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
initWithContentRect:window_rect
|
||||
styleMask:(NSTitledWindowMask | NSClosableWindowMask |
|
||||
NSMiniaturizableWindowMask |
|
||||
NSResizableWindowMask |
|
||||
NSUnifiedTitleAndToolbarWindowMask)
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
|
||||
// Create the delegate for control and browser window events.
|
||||
[[CefWindowDelegate alloc] initWithWindow:newWnd andBrowser:browser_];
|
||||
@@ -229,7 +227,7 @@ bool CefBrowserPlatformDelegateNativeMac::CreateHostWindow() {
|
||||
|
||||
if (newWnd != nil && !window_info_.hidden) {
|
||||
// Show the window.
|
||||
[newWnd makeKeyAndOrderFront: nil];
|
||||
[newWnd makeKeyAndOrderFront:nil];
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -244,8 +242,8 @@ void CefBrowserPlatformDelegateNativeMac::CloseHostWindow() {
|
||||
}
|
||||
}
|
||||
|
||||
CefWindowHandle
|
||||
CefBrowserPlatformDelegateNativeMac::GetHostWindowHandle() const {
|
||||
CefWindowHandle CefBrowserPlatformDelegateNativeMac::GetHostWindowHandle()
|
||||
const {
|
||||
if (windowless_handler_)
|
||||
return windowless_handler_->GetParentWindowHandle();
|
||||
return window_info_.view;
|
||||
@@ -296,8 +294,7 @@ void CefBrowserPlatformDelegateNativeMac::HandleKeyboardEvent(
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeMac::HandleExternalProtocol(
|
||||
const GURL& url) {
|
||||
}
|
||||
const GURL& url) {}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeMac::TranslateKeyEvent(
|
||||
content::NativeWebKeyboardEvent& result,
|
||||
@@ -328,23 +325,24 @@ void CefBrowserPlatformDelegateNativeMac::TranslateKeyEvent(
|
||||
}
|
||||
}
|
||||
|
||||
NSString* charactersIgnoringModifiers = [[[NSString alloc]
|
||||
initWithCharacters:&key_event.unmodified_character length:1]
|
||||
autorelease];
|
||||
NSString* characters = [[[NSString alloc]
|
||||
initWithCharacters:&key_event.character length:1] autorelease];
|
||||
NSString* charactersIgnoringModifiers =
|
||||
[[[NSString alloc] initWithCharacters:&key_event.unmodified_character
|
||||
length:1] autorelease];
|
||||
NSString* characters =
|
||||
[[[NSString alloc] initWithCharacters:&key_event.character length:1]
|
||||
autorelease];
|
||||
|
||||
NSEvent* synthetic_event =
|
||||
[NSEvent keyEventWithType:event_type
|
||||
location:NSMakePoint(0, 0)
|
||||
modifierFlags:NativeModifiers(key_event.modifiers)
|
||||
timestamp:currentEventTimestamp()
|
||||
windowNumber:0
|
||||
context:nil
|
||||
characters:characters
|
||||
charactersIgnoringModifiers:charactersIgnoringModifiers
|
||||
isARepeat:NO
|
||||
keyCode:key_event.native_key_code];
|
||||
[NSEvent keyEventWithType:event_type
|
||||
location:NSMakePoint(0, 0)
|
||||
modifierFlags:NativeModifiers(key_event.modifiers)
|
||||
timestamp:currentEventTimestamp()
|
||||
windowNumber:0
|
||||
context:nil
|
||||
characters:characters
|
||||
charactersIgnoringModifiers:charactersIgnoringModifiers
|
||||
isARepeat:NO
|
||||
keyCode:key_event.native_key_code];
|
||||
|
||||
result = content::NativeWebKeyboardEvent(synthetic_event);
|
||||
if (key_event.type == KEYEVENT_CHAR)
|
||||
@@ -357,27 +355,28 @@ void CefBrowserPlatformDelegateNativeMac::TranslateClickEvent(
|
||||
blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp, int clickCount) const {
|
||||
bool mouseUp,
|
||||
int clickCount) const {
|
||||
TranslateMouseEvent(result, mouse_event);
|
||||
|
||||
switch (type) {
|
||||
case MBT_LEFT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kLeft;
|
||||
break;
|
||||
case MBT_MIDDLE:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kMiddle;
|
||||
break;
|
||||
case MBT_RIGHT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kRight;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
case MBT_LEFT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kLeft;
|
||||
break;
|
||||
case MBT_MIDDLE:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kMiddle;
|
||||
break;
|
||||
case MBT_RIGHT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kRight;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
result.click_count = clickCount;
|
||||
@@ -410,7 +409,8 @@ void CefBrowserPlatformDelegateNativeMac::TranslateMoveEvent(
|
||||
void CefBrowserPlatformDelegateNativeMac::TranslateWheelEvent(
|
||||
blink::WebMouseWheelEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
int deltaX, int deltaY) const {
|
||||
int deltaX,
|
||||
int deltaY) const {
|
||||
result = blink::WebMouseWheelEvent();
|
||||
TranslateMouseEvent(result, mouse_event);
|
||||
|
||||
@@ -444,17 +444,17 @@ CefEventHandle CefBrowserPlatformDelegateNativeMac::GetEventHandle(
|
||||
}
|
||||
|
||||
std::unique_ptr<CefFileDialogRunner>
|
||||
CefBrowserPlatformDelegateNativeMac::CreateFileDialogRunner() {
|
||||
CefBrowserPlatformDelegateNativeMac::CreateFileDialogRunner() {
|
||||
return base::WrapUnique(new CefFileDialogRunnerMac);
|
||||
}
|
||||
|
||||
std::unique_ptr<CefJavaScriptDialogRunner>
|
||||
CefBrowserPlatformDelegateNativeMac::CreateJavaScriptDialogRunner() {
|
||||
CefBrowserPlatformDelegateNativeMac::CreateJavaScriptDialogRunner() {
|
||||
return base::WrapUnique(new CefJavaScriptDialogRunnerMac);
|
||||
}
|
||||
|
||||
std::unique_ptr<CefMenuRunner>
|
||||
CefBrowserPlatformDelegateNativeMac::CreateMenuRunner() {
|
||||
CefBrowserPlatformDelegateNativeMac::CreateMenuRunner() {
|
||||
return base::WrapUnique(new CefMenuRunnerMac);
|
||||
}
|
||||
|
||||
@@ -469,10 +469,9 @@ void CefBrowserPlatformDelegateNativeMac::TranslateMouseEvent(
|
||||
result.SetPositionInScreen(screen_pt.x(), screen_pt.y());
|
||||
|
||||
// modifiers
|
||||
result.SetModifiers(
|
||||
result.GetModifiers() | TranslateModifiers(mouse_event.modifiers));
|
||||
result.SetModifiers(result.GetModifiers() |
|
||||
TranslateModifiers(mouse_event.modifiers));
|
||||
|
||||
// timestamp - Mac OSX specific
|
||||
result.SetTimeStampSeconds(currentEventTimestamp());
|
||||
}
|
||||
|
||||
|
@@ -73,9 +73,9 @@ bool HasExternalHandler(const std::string& scheme) {
|
||||
DWORD size = 0;
|
||||
key.ReadValue(NULL, NULL, &size, NULL);
|
||||
if (size > 2) {
|
||||
// ShellExecute crashes the process when the command is empty.
|
||||
// We check for "2" because it always returns the trailing NULL.
|
||||
return true;
|
||||
// ShellExecute crashes the process when the command is empty.
|
||||
// We check for "2" because it always returns the trailing NULL.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,8 +119,7 @@ CefBrowserPlatformDelegateNativeWin::CefBrowserPlatformDelegateNativeWin(
|
||||
SkColor background_color)
|
||||
: CefBrowserPlatformDelegateNative(window_info, background_color),
|
||||
host_window_created_(false),
|
||||
window_widget_(nullptr) {
|
||||
}
|
||||
window_widget_(nullptr) {}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeWin::BrowserDestroyed(
|
||||
CefBrowserHostImpl* browser) {
|
||||
@@ -138,9 +137,9 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
|
||||
std::wstring windowName(CefString(&window_info_.window_name));
|
||||
|
||||
// Create the new browser window.
|
||||
window_info_.window = CreateWindowEx(window_info_.ex_style,
|
||||
GetWndClass(), windowName.c_str(), window_info_.style,
|
||||
window_info_.x, window_info_.y, window_info_.width,
|
||||
window_info_.window = CreateWindowEx(
|
||||
window_info_.ex_style, GetWndClass(), windowName.c_str(),
|
||||
window_info_.style, window_info_.x, window_info_.y, window_info_.width,
|
||||
window_info_.height, window_info_.parent_window, window_info_.menu,
|
||||
::GetModuleHandle(NULL), NULL);
|
||||
|
||||
@@ -166,15 +165,15 @@ bool CefBrowserPlatformDelegateNativeWin::CreateHostWindow() {
|
||||
|
||||
// Adjust for potential display scaling.
|
||||
gfx::Point point = gfx::Point(cr.right, cr.bottom);
|
||||
float scale = display::Screen::GetScreen()->
|
||||
GetDisplayNearestPoint(point).device_scale_factor();
|
||||
point = gfx::ToFlooredPoint(
|
||||
gfx::ScalePoint(gfx::PointF(point), 1.0f / scale));
|
||||
float scale = display::Screen::GetScreen()
|
||||
->GetDisplayNearestPoint(point)
|
||||
.device_scale_factor();
|
||||
point =
|
||||
gfx::ToFlooredPoint(gfx::ScalePoint(gfx::PointF(point), 1.0f / scale));
|
||||
|
||||
CefWindowDelegateView* delegate_view =
|
||||
new CefWindowDelegateView(GetBackgroundColor());
|
||||
delegate_view->Init(window_info_.window,
|
||||
browser_->web_contents(),
|
||||
delegate_view->Init(window_info_.window, browser_->web_contents(),
|
||||
gfx::Rect(0, 0, point.x(), point.y()));
|
||||
|
||||
window_widget_ = delegate_view->GetWidget();
|
||||
@@ -190,8 +189,8 @@ void CefBrowserPlatformDelegateNativeWin::CloseHostWindow() {
|
||||
}
|
||||
}
|
||||
|
||||
CefWindowHandle
|
||||
CefBrowserPlatformDelegateNativeWin::GetHostWindowHandle() const {
|
||||
CefWindowHandle CefBrowserPlatformDelegateNativeWin::GetHostWindowHandle()
|
||||
const {
|
||||
if (windowless_handler_)
|
||||
return windowless_handler_->GetParentWindowHandle();
|
||||
return window_info_.window;
|
||||
@@ -278,8 +277,8 @@ void CefBrowserPlatformDelegateNativeWin::SizeTo(int width, int height) {
|
||||
AdjustWindowRectEx(&rect, style, has_menu, ex_style);
|
||||
|
||||
// Size the window.
|
||||
SetWindowPos(window, NULL, 0, 0, rect.right,
|
||||
rect.bottom, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
|
||||
SetWindowPos(window, NULL, 0, 0, rect.right, rect.bottom,
|
||||
SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE);
|
||||
}
|
||||
|
||||
gfx::Point CefBrowserPlatformDelegateNativeWin::GetScreenPoint(
|
||||
@@ -296,10 +295,10 @@ gfx::Point CefBrowserPlatformDelegateNativeWin::GetScreenPoint(
|
||||
bounds_in_screen.y() + view.y());
|
||||
|
||||
// Adjust for potential display scaling.
|
||||
float scale = display::Screen::GetScreen()->
|
||||
GetDisplayNearestPoint(screen_point).device_scale_factor();
|
||||
return gfx::ToFlooredPoint(
|
||||
gfx::ScalePoint(gfx::PointF(screen_point), scale));
|
||||
float scale = display::Screen::GetScreen()
|
||||
->GetDisplayNearestPoint(screen_point)
|
||||
.device_scale_factor();
|
||||
return gfx::ToFlooredPoint(gfx::ScalePoint(gfx::PointF(screen_point), scale));
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeWin::ViewText(const std::string& text) {
|
||||
@@ -331,7 +330,7 @@ void CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent(
|
||||
msg.message = event.is_system_key ? WM_SYSKEYUP : WM_KEYUP;
|
||||
break;
|
||||
case blink::WebInputEvent::kChar:
|
||||
msg.message = event.is_system_key ? WM_SYSCHAR: WM_CHAR;
|
||||
msg.message = event.is_system_key ? WM_SYSCHAR : WM_CHAR;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
@@ -342,7 +341,7 @@ void CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent(
|
||||
|
||||
UINT scan_code = ::MapVirtualKeyW(event.windows_key_code, MAPVK_VK_TO_VSC);
|
||||
msg.lParam = (scan_code << 16) | // key scan code
|
||||
1; // key repeat count
|
||||
1; // key repeat count
|
||||
if (event.GetModifiers() & content::NativeWebKeyboardEvent::kAltKey)
|
||||
msg.lParam |= (1 << 29);
|
||||
|
||||
@@ -353,8 +352,7 @@ void CefBrowserPlatformDelegateNativeWin::HandleKeyboardEvent(
|
||||
void CefBrowserPlatformDelegateNativeWin::HandleExternalProtocol(
|
||||
const GURL& url) {
|
||||
// Execute on the FILE thread.
|
||||
CEF_POST_TASK(CEF_FILET,
|
||||
base::Bind(ExecuteExternalProtocol, url));
|
||||
CEF_POST_TASK(CEF_FILET, base::Bind(ExecuteExternalProtocol, url));
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeWin::TranslateKeyEvent(
|
||||
@@ -364,25 +362,24 @@ void CefBrowserPlatformDelegateNativeWin::TranslateKeyEvent(
|
||||
result.native_key_code = key_event.native_key_code;
|
||||
result.is_system_key = key_event.is_system_key ? 1 : 0;
|
||||
switch (key_event.type) {
|
||||
case KEYEVENT_RAWKEYDOWN:
|
||||
case KEYEVENT_KEYDOWN:
|
||||
result.SetType(blink::WebInputEvent::kRawKeyDown);
|
||||
break;
|
||||
case KEYEVENT_KEYUP:
|
||||
result.SetType(blink::WebInputEvent::kKeyUp);
|
||||
break;
|
||||
case KEYEVENT_CHAR:
|
||||
result.SetType(blink::WebInputEvent::kChar);
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
case KEYEVENT_RAWKEYDOWN:
|
||||
case KEYEVENT_KEYDOWN:
|
||||
result.SetType(blink::WebInputEvent::kRawKeyDown);
|
||||
break;
|
||||
case KEYEVENT_KEYUP:
|
||||
result.SetType(blink::WebInputEvent::kKeyUp);
|
||||
break;
|
||||
case KEYEVENT_CHAR:
|
||||
result.SetType(blink::WebInputEvent::kChar);
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
// Populate DOM values that will be passed to JavaScript handlers via
|
||||
// KeyboardEvent.
|
||||
result.dom_code =
|
||||
static_cast<int>(ui::KeycodeConverter::NativeKeycodeToDomCode(
|
||||
key_event.native_key_code));
|
||||
result.dom_code = static_cast<int>(
|
||||
ui::KeycodeConverter::NativeKeycodeToDomCode(key_event.native_key_code));
|
||||
if (result.GetType() == blink::WebInputEvent::kChar) {
|
||||
result.dom_key = ui::DomKey::FromCharacter(key_event.windows_key_code);
|
||||
} else {
|
||||
@@ -399,35 +396,36 @@ void CefBrowserPlatformDelegateNativeWin::TranslateKeyEvent(
|
||||
result.unmodified_text[0] = result.windows_key_code;
|
||||
}
|
||||
|
||||
result.SetModifiers(
|
||||
result.GetModifiers() | TranslateModifiers(key_event.modifiers));
|
||||
result.SetModifiers(result.GetModifiers() |
|
||||
TranslateModifiers(key_event.modifiers));
|
||||
}
|
||||
|
||||
void CefBrowserPlatformDelegateNativeWin::TranslateClickEvent(
|
||||
blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp, int clickCount) const {
|
||||
bool mouseUp,
|
||||
int clickCount) const {
|
||||
TranslateMouseEvent(result, mouse_event);
|
||||
|
||||
switch (type) {
|
||||
case MBT_LEFT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kLeft;
|
||||
break;
|
||||
case MBT_MIDDLE:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kMiddle;
|
||||
break;
|
||||
case MBT_RIGHT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp :
|
||||
blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kRight;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
case MBT_LEFT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kLeft;
|
||||
break;
|
||||
case MBT_MIDDLE:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kMiddle;
|
||||
break;
|
||||
case MBT_RIGHT:
|
||||
result.SetType(mouseUp ? blink::WebInputEvent::kMouseUp
|
||||
: blink::WebInputEvent::kMouseDown);
|
||||
result.button = blink::WebMouseEvent::Button::kRight;
|
||||
break;
|
||||
default:
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
result.click_count = clickCount;
|
||||
@@ -460,7 +458,8 @@ void CefBrowserPlatformDelegateNativeWin::TranslateMoveEvent(
|
||||
void CefBrowserPlatformDelegateNativeWin::TranslateWheelEvent(
|
||||
blink::WebMouseWheelEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
int deltaX, int deltaY) const {
|
||||
int deltaX,
|
||||
int deltaY) const {
|
||||
TranslateMouseEvent(result, mouse_event);
|
||||
|
||||
result.SetType(blink::WebInputEvent::kMouseWheel);
|
||||
@@ -510,17 +509,17 @@ CefEventHandle CefBrowserPlatformDelegateNativeWin::GetEventHandle(
|
||||
}
|
||||
|
||||
std::unique_ptr<CefFileDialogRunner>
|
||||
CefBrowserPlatformDelegateNativeWin::CreateFileDialogRunner() {
|
||||
CefBrowserPlatformDelegateNativeWin::CreateFileDialogRunner() {
|
||||
return base::WrapUnique(new CefFileDialogRunnerWin);
|
||||
}
|
||||
|
||||
std::unique_ptr<CefJavaScriptDialogRunner>
|
||||
CefBrowserPlatformDelegateNativeWin::CreateJavaScriptDialogRunner() {
|
||||
CefBrowserPlatformDelegateNativeWin::CreateJavaScriptDialogRunner() {
|
||||
return base::WrapUnique(new CefJavaScriptDialogRunnerWin);
|
||||
}
|
||||
|
||||
std::unique_ptr<CefMenuRunner>
|
||||
CefBrowserPlatformDelegateNativeWin::CreateMenuRunner() {
|
||||
CefBrowserPlatformDelegateNativeWin::CreateMenuRunner() {
|
||||
return base::WrapUnique(new CefMenuRunnerWin);
|
||||
}
|
||||
|
||||
@@ -535,8 +534,8 @@ void CefBrowserPlatformDelegateNativeWin::TranslateMouseEvent(
|
||||
result.SetPositionInScreen(screen_pt.x(), screen_pt.y());
|
||||
|
||||
// modifiers
|
||||
result.SetModifiers(
|
||||
result.GetModifiers() | TranslateModifiers(mouse_event.modifiers));
|
||||
result.SetModifiers(result.GetModifiers() |
|
||||
TranslateModifiers(mouse_event.modifiers));
|
||||
|
||||
// timestamp
|
||||
result.SetTimeStampSeconds(GetMessageTime() / 1000.0);
|
||||
@@ -550,18 +549,18 @@ void CefBrowserPlatformDelegateNativeWin::RegisterWindowClass() {
|
||||
|
||||
// Register the window class
|
||||
WNDCLASSEX wcex = {
|
||||
/* cbSize = */ sizeof(WNDCLASSEX),
|
||||
/* style = */ CS_HREDRAW | CS_VREDRAW,
|
||||
/* lpfnWndProc = */ CefBrowserPlatformDelegateNativeWin::WndProc,
|
||||
/* cbClsExtra = */ 0,
|
||||
/* cbWndExtra = */ 0,
|
||||
/* hInstance = */ ::GetModuleHandle(NULL),
|
||||
/* hIcon = */ NULL,
|
||||
/* hCursor = */ LoadCursor(NULL, IDC_ARROW),
|
||||
/* hbrBackground = */ 0,
|
||||
/* lpszMenuName = */ NULL,
|
||||
/* lpszClassName = */ CefBrowserPlatformDelegateNativeWin::GetWndClass(),
|
||||
/* hIconSm = */ NULL,
|
||||
/* cbSize = */ sizeof(WNDCLASSEX),
|
||||
/* style = */ CS_HREDRAW | CS_VREDRAW,
|
||||
/* lpfnWndProc = */ CefBrowserPlatformDelegateNativeWin::WndProc,
|
||||
/* cbClsExtra = */ 0,
|
||||
/* cbWndExtra = */ 0,
|
||||
/* hInstance = */ ::GetModuleHandle(NULL),
|
||||
/* hIcon = */ NULL,
|
||||
/* hCursor = */ LoadCursor(NULL, IDC_ARROW),
|
||||
/* hbrBackground = */ 0,
|
||||
/* lpszMenuName = */ NULL,
|
||||
/* lpszClassName = */ CefBrowserPlatformDelegateNativeWin::GetWndClass(),
|
||||
/* hIconSm = */ NULL,
|
||||
};
|
||||
RegisterClassEx(&wcex);
|
||||
|
||||
@@ -574,64 +573,65 @@ LPCTSTR CefBrowserPlatformDelegateNativeWin::GetWndClass() {
|
||||
}
|
||||
|
||||
// static
|
||||
LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(
|
||||
HWND hwnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam) {
|
||||
LRESULT CALLBACK CefBrowserPlatformDelegateNativeWin::WndProc(HWND hwnd,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam) {
|
||||
CefBrowserPlatformDelegateNativeWin* platform_delegate =
|
||||
static_cast<CefBrowserPlatformDelegateNativeWin*>(
|
||||
gfx::GetWindowUserData(hwnd));
|
||||
CefBrowserHostImpl* browser = nullptr;
|
||||
if (platform_delegate)
|
||||
browser = platform_delegate->browser_;
|
||||
browser = platform_delegate->browser_;
|
||||
|
||||
switch (message) {
|
||||
case WM_CLOSE:
|
||||
if (browser && !browser->TryCloseBrowser()) {
|
||||
// Cancel the close.
|
||||
case WM_CLOSE:
|
||||
if (browser && !browser->TryCloseBrowser()) {
|
||||
// Cancel the close.
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Allow the close.
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
if (platform_delegate) {
|
||||
// Clear the user data pointer.
|
||||
gfx::SetWindowUserData(hwnd, NULL);
|
||||
|
||||
// Force the browser to be destroyed. This will result in a call to
|
||||
// BrowserDestroyed() that will release the reference added in
|
||||
// CreateHostWindow().
|
||||
browser->WindowDestroyed();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Allow the close.
|
||||
break;
|
||||
case WM_SIZE:
|
||||
if (platform_delegate && platform_delegate->window_widget_) {
|
||||
// Pass window resize events to the HWND for the DesktopNativeWidgetAura
|
||||
// root window. Passing size 0x0 (wParam == SIZE_MINIMIZED, for example)
|
||||
// will cause the widget to be hidden which reduces resource usage.
|
||||
RECT rc;
|
||||
GetClientRect(hwnd, &rc);
|
||||
SetWindowPos(HWNDForWidget(platform_delegate->window_widget_), NULL,
|
||||
rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
|
||||
SWP_NOZORDER);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_DESTROY:
|
||||
if (platform_delegate) {
|
||||
// Clear the user data pointer.
|
||||
gfx::SetWindowUserData(hwnd, NULL);
|
||||
case WM_MOVING:
|
||||
case WM_MOVE:
|
||||
if (browser)
|
||||
browser->NotifyMoveOrResizeStarted();
|
||||
return 0;
|
||||
|
||||
// Force the browser to be destroyed. This will result in a call to
|
||||
// BrowserDestroyed() that will release the reference added in
|
||||
// CreateHostWindow().
|
||||
browser->WindowDestroyed();
|
||||
}
|
||||
return 0;
|
||||
case WM_SETFOCUS:
|
||||
if (browser)
|
||||
browser->SetFocus(true);
|
||||
return 0;
|
||||
|
||||
case WM_SIZE:
|
||||
if (platform_delegate && platform_delegate->window_widget_) {
|
||||
// Pass window resize events to the HWND for the DesktopNativeWidgetAura
|
||||
// root window. Passing size 0x0 (wParam == SIZE_MINIMIZED, for example)
|
||||
// will cause the widget to be hidden which reduces resource usage.
|
||||
RECT rc;
|
||||
GetClientRect(hwnd, &rc);
|
||||
SetWindowPos(HWNDForWidget(platform_delegate->window_widget_), NULL,
|
||||
rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
|
||||
SWP_NOZORDER);
|
||||
}
|
||||
return 0;
|
||||
|
||||
case WM_MOVING:
|
||||
case WM_MOVE:
|
||||
if (browser)
|
||||
browser->NotifyMoveOrResizeStarted();
|
||||
return 0;
|
||||
|
||||
case WM_SETFOCUS:
|
||||
if (browser)
|
||||
browser->SetFocus(true);
|
||||
return 0;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
return 0;
|
||||
case WM_ERASEBKGND:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return DefWindowProc(hwnd, message, wParam, lParam);
|
||||
|
@@ -10,8 +10,8 @@
|
||||
#include "libcef/browser/native/browser_platform_delegate_native.h"
|
||||
|
||||
// Windowed browser implementation for Windows.
|
||||
class CefBrowserPlatformDelegateNativeWin :
|
||||
public CefBrowserPlatformDelegateNative {
|
||||
class CefBrowserPlatformDelegateNativeWin
|
||||
: public CefBrowserPlatformDelegateNative {
|
||||
public:
|
||||
CefBrowserPlatformDelegateNativeWin(const CefWindowInfo& window_info,
|
||||
SkColor background_color);
|
||||
@@ -35,17 +35,20 @@ class CefBrowserPlatformDelegateNativeWin :
|
||||
void TranslateClickEvent(blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
CefBrowserHost::MouseButtonType type,
|
||||
bool mouseUp, int clickCount) const override;
|
||||
bool mouseUp,
|
||||
int clickCount) const override;
|
||||
void TranslateMoveEvent(blink::WebMouseEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
bool mouseLeave) const override;
|
||||
void TranslateWheelEvent(blink::WebMouseWheelEvent& result,
|
||||
const CefMouseEvent& mouse_event,
|
||||
int deltaX, int deltaY) const override;
|
||||
int deltaX,
|
||||
int deltaY) const override;
|
||||
CefEventHandle GetEventHandle(
|
||||
const content::NativeWebKeyboardEvent& event) const override;
|
||||
std::unique_ptr<CefFileDialogRunner> CreateFileDialogRunner() override;
|
||||
std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner() override;
|
||||
std::unique_ptr<CefJavaScriptDialogRunner> CreateJavaScriptDialogRunner()
|
||||
override;
|
||||
std::unique_ptr<CefMenuRunner> CreateMenuRunner() override;
|
||||
|
||||
private:
|
||||
@@ -54,8 +57,10 @@ class CefBrowserPlatformDelegateNativeWin :
|
||||
|
||||
static void RegisterWindowClass();
|
||||
static LPCTSTR GetWndClass();
|
||||
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
||||
WPARAM wParam, LPARAM lParam);
|
||||
static LRESULT CALLBACK WndProc(HWND hwnd,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
|
||||
// True if the host window has been created.
|
||||
bool host_window_created_;
|
||||
|
@@ -31,10 +31,10 @@ base::string16 GetDescriptionFromMimeType(const std::string& mime_type) {
|
||||
const char* mime_type;
|
||||
int string_id;
|
||||
} kWildCardMimeTypes[] = {
|
||||
{ "audio", IDS_AUDIO_FILES },
|
||||
{ "image", IDS_IMAGE_FILES },
|
||||
{ "text", IDS_TEXT_FILES },
|
||||
{ "video", IDS_VIDEO_FILES },
|
||||
{"audio", IDS_AUDIO_FILES},
|
||||
{"image", IDS_IMAGE_FILES},
|
||||
{"text", IDS_TEXT_FILES},
|
||||
{"video", IDS_VIDEO_FILES},
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < arraysize(kWildCardMimeTypes); ++i) {
|
||||
@@ -45,10 +45,10 @@ base::string16 GetDescriptionFromMimeType(const std::string& mime_type) {
|
||||
return base::string16();
|
||||
}
|
||||
|
||||
void AddFilters(NSPopUpButton *button,
|
||||
void AddFilters(NSPopUpButton* button,
|
||||
const std::vector<base::string16>& accept_filters,
|
||||
bool include_all_files,
|
||||
std::vector<std::vector<base::string16> >* all_extensions) {
|
||||
std::vector<std::vector<base::string16>>* all_extensions) {
|
||||
for (size_t i = 0; i < accept_filters.size(); ++i) {
|
||||
const base::string16& filter = accept_filters[i];
|
||||
if (filter.empty())
|
||||
@@ -62,11 +62,9 @@ void AddFilters(NSPopUpButton *button,
|
||||
// Treat as a filter of the form "Filter Name|.ext1;.ext2;.ext3".
|
||||
description = filter.substr(0, sep_index);
|
||||
|
||||
const std::vector<base::string16>& ext =
|
||||
base::SplitString(filter.substr(sep_index + 1),
|
||||
base::ASCIIToUTF16(";"),
|
||||
base::TRIM_WHITESPACE,
|
||||
base::SPLIT_WANT_NONEMPTY);
|
||||
const std::vector<base::string16>& ext = base::SplitString(
|
||||
filter.substr(sep_index + 1), base::ASCIIToUTF16(";"),
|
||||
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
||||
for (size_t x = 0; x < ext.size(); ++x) {
|
||||
const base::string16& file_ext = ext[x];
|
||||
if (!file_ext.empty() && file_ext[0] == '.')
|
||||
@@ -131,12 +129,12 @@ void AddFilters(NSPopUpButton *button,
|
||||
@interface CefFilterDelegate : NSObject {
|
||||
@private
|
||||
NSSavePanel* panel_;
|
||||
std::vector<std::vector<base::string16> > extensions_;
|
||||
std::vector<std::vector<base::string16>> extensions_;
|
||||
int selected_index_;
|
||||
}
|
||||
- (id)initWithPanel:(NSSavePanel*)panel
|
||||
andAcceptFilters:(const std::vector<base::string16>&)accept_filters
|
||||
andFilterIndex:(int)index;
|
||||
andAcceptFilters:(const std::vector<base::string16>&)accept_filters
|
||||
andFilterIndex:(int)index;
|
||||
- (void)setFilter:(int)index;
|
||||
- (int)filter;
|
||||
- (void)filterSelectionChanged:(id)sender;
|
||||
@@ -146,14 +144,14 @@ void AddFilters(NSPopUpButton *button,
|
||||
@implementation CefFilterDelegate
|
||||
|
||||
- (id)initWithPanel:(NSSavePanel*)panel
|
||||
andAcceptFilters:(const std::vector<base::string16>&)accept_filters
|
||||
andFilterIndex:(int)index {
|
||||
andAcceptFilters:(const std::vector<base::string16>&)accept_filters
|
||||
andFilterIndex:(int)index {
|
||||
if (self = [super init]) {
|
||||
DCHECK(panel);
|
||||
panel_ = panel;
|
||||
selected_index_ = 0;
|
||||
|
||||
NSPopUpButton *button = [[NSPopUpButton alloc] init];
|
||||
NSPopUpButton* button = [[NSPopUpButton alloc] init];
|
||||
AddFilters(button, accept_filters, true, &extensions_);
|
||||
[button sizeToFit];
|
||||
[button setTarget:self];
|
||||
@@ -181,8 +179,8 @@ void AddFilters(NSPopUpButton *button,
|
||||
if (!extensions_[index].empty()) {
|
||||
acceptArray = [[NSMutableArray alloc] init];
|
||||
for (size_t i = 0; i < extensions_[index].size(); ++i) {
|
||||
[acceptArray addObject:
|
||||
base::SysUTF16ToNSString(extensions_[index][i].substr(1))];
|
||||
[acceptArray
|
||||
addObject:base::SysUTF16ToNSString(extensions_[index][i].substr(1))];
|
||||
}
|
||||
}
|
||||
[panel_ setAllowedFileTypes:acceptArray];
|
||||
@@ -200,7 +198,7 @@ void AddFilters(NSPopUpButton *button,
|
||||
|
||||
// Called when the selected filter is changed via the NSPopUpButton.
|
||||
- (void)filterSelectionChanged:(id)sender {
|
||||
NSPopUpButton *button = (NSPopUpButton*)sender;
|
||||
NSPopUpButton* button = (NSPopUpButton*)sender;
|
||||
[self setFilter:[button indexOfSelectedItem]];
|
||||
}
|
||||
|
||||
@@ -233,11 +231,10 @@ void AddFilters(NSPopUpButton *button,
|
||||
|
||||
namespace {
|
||||
|
||||
void RunOpenFileDialog(
|
||||
const CefFileDialogRunner::FileChooserParams& params,
|
||||
NSView* view,
|
||||
int filter_index,
|
||||
CefFileDialogRunner::RunFileChooserCallback callback) {
|
||||
void RunOpenFileDialog(const CefFileDialogRunner::FileChooserParams& params,
|
||||
NSView* view,
|
||||
int filter_index,
|
||||
CefFileDialogRunner::RunFileChooserCallback callback) {
|
||||
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
|
||||
|
||||
base::string16 title;
|
||||
@@ -245,10 +242,11 @@ void RunOpenFileDialog(
|
||||
title = params.title;
|
||||
} else {
|
||||
title = l10n_util::GetStringUTF16(
|
||||
params.mode == content::FileChooserParams::Open ?
|
||||
IDS_OPEN_FILE_DIALOG_TITLE :
|
||||
(params.mode == content::FileChooserParams::OpenMultiple ?
|
||||
IDS_OPEN_FILES_DIALOG_TITLE : IDS_SELECT_FOLDER_DIALOG_TITLE));
|
||||
params.mode == content::FileChooserParams::Open
|
||||
? IDS_OPEN_FILE_DIALOG_TITLE
|
||||
: (params.mode == content::FileChooserParams::OpenMultiple
|
||||
? IDS_OPEN_FILES_DIALOG_TITLE
|
||||
: IDS_SELECT_FOLDER_DIALOG_TITLE));
|
||||
}
|
||||
[openPanel setTitle:base::SysUTF16ToNSString(title)];
|
||||
|
||||
@@ -268,8 +266,8 @@ void RunOpenFileDialog(
|
||||
[openPanel setNameFieldStringValue:base::SysUTF8ToNSString(filename)];
|
||||
}
|
||||
if (!directory.empty()) {
|
||||
[openPanel setDirectoryURL:
|
||||
[NSURL fileURLWithPath:base::SysUTF8ToNSString(directory)]];
|
||||
[openPanel setDirectoryURL:[NSURL fileURLWithPath:base::SysUTF8ToNSString(
|
||||
directory)]];
|
||||
}
|
||||
|
||||
CefFilterDelegate* filter_delegate = nil;
|
||||
@@ -284,38 +282,42 @@ void RunOpenFileDialog(
|
||||
|
||||
// Further panel configuration.
|
||||
[openPanel setAllowsOtherFileTypes:YES];
|
||||
[openPanel setAllowsMultipleSelection:
|
||||
(params.mode == content::FileChooserParams::OpenMultiple)];
|
||||
[openPanel setCanChooseFiles:
|
||||
(params.mode != content::FileChooserParams::UploadFolder)];
|
||||
[openPanel setCanChooseDirectories:
|
||||
(params.mode == content::FileChooserParams::UploadFolder)];
|
||||
[openPanel
|
||||
setAllowsMultipleSelection:(params.mode ==
|
||||
content::FileChooserParams::OpenMultiple)];
|
||||
[openPanel setCanChooseFiles:(params.mode !=
|
||||
content::FileChooserParams::UploadFolder)];
|
||||
[openPanel
|
||||
setCanChooseDirectories:(params.mode ==
|
||||
content::FileChooserParams::UploadFolder)];
|
||||
[openPanel setShowsHiddenFiles:!params.hidereadonly];
|
||||
|
||||
// Show panel.
|
||||
[openPanel beginSheetModalForWindow:[view window]
|
||||
completionHandler:^(NSInteger returnCode) {
|
||||
int filter_index_to_use =
|
||||
(filter_delegate != nil) ? [filter_delegate filter] : filter_index;
|
||||
if (returnCode == NSFileHandlingPanelOKButton) {
|
||||
std::vector<base::FilePath> files;
|
||||
files.reserve(openPanel.URLs.count);
|
||||
for (NSURL* url in openPanel.URLs) {
|
||||
if (url.isFileURL)
|
||||
files.push_back(base::FilePath(url.path.UTF8String));
|
||||
}
|
||||
callback.Run(filter_index_to_use, files);
|
||||
} else {
|
||||
callback.Run(filter_index_to_use, std::vector<base::FilePath>());
|
||||
}
|
||||
}];
|
||||
[openPanel
|
||||
beginSheetModalForWindow:[view window]
|
||||
completionHandler:^(NSInteger returnCode) {
|
||||
int filter_index_to_use = (filter_delegate != nil)
|
||||
? [filter_delegate filter]
|
||||
: filter_index;
|
||||
if (returnCode == NSFileHandlingPanelOKButton) {
|
||||
std::vector<base::FilePath> files;
|
||||
files.reserve(openPanel.URLs.count);
|
||||
for (NSURL* url in openPanel.URLs) {
|
||||
if (url.isFileURL)
|
||||
files.push_back(base::FilePath(url.path.UTF8String));
|
||||
}
|
||||
callback.Run(filter_index_to_use, files);
|
||||
} else {
|
||||
callback.Run(filter_index_to_use,
|
||||
std::vector<base::FilePath>());
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
void RunSaveFileDialog(
|
||||
const CefFileDialogRunner::FileChooserParams& params,
|
||||
NSView* view,
|
||||
int filter_index,
|
||||
CefFileDialogRunner::RunFileChooserCallback callback) {
|
||||
void RunSaveFileDialog(const CefFileDialogRunner::FileChooserParams& params,
|
||||
NSView* view,
|
||||
int filter_index,
|
||||
CefFileDialogRunner::RunFileChooserCallback callback) {
|
||||
NSSavePanel* savePanel = [NSSavePanel savePanel];
|
||||
|
||||
base::string16 title;
|
||||
@@ -340,8 +342,8 @@ void RunSaveFileDialog(
|
||||
[savePanel setNameFieldStringValue:base::SysUTF8ToNSString(filename)];
|
||||
}
|
||||
if (!directory.empty()) {
|
||||
[savePanel setDirectoryURL:
|
||||
[NSURL fileURLWithPath:base::SysUTF8ToNSString(directory)]];
|
||||
[savePanel setDirectoryURL:[NSURL fileURLWithPath:base::SysUTF8ToNSString(
|
||||
directory)]];
|
||||
}
|
||||
|
||||
CefFilterDelegate* filter_delegate = nil;
|
||||
@@ -357,25 +359,27 @@ void RunSaveFileDialog(
|
||||
[savePanel setShowsHiddenFiles:!params.hidereadonly];
|
||||
|
||||
// Show panel.
|
||||
[savePanel beginSheetModalForWindow:view.window
|
||||
completionHandler:^(NSInteger resultCode) {
|
||||
int filter_index_to_use =
|
||||
(filter_delegate != nil) ? [filter_delegate filter] : filter_index;
|
||||
if (resultCode == NSFileHandlingPanelOKButton) {
|
||||
NSURL* url = savePanel.URL;
|
||||
const char* path = url.path.UTF8String;
|
||||
std::vector<base::FilePath> files(1, base::FilePath(path));
|
||||
callback.Run(filter_index_to_use, files);
|
||||
} else {
|
||||
callback.Run(filter_index_to_use, std::vector<base::FilePath>());
|
||||
}
|
||||
}];
|
||||
[savePanel
|
||||
beginSheetModalForWindow:view.window
|
||||
completionHandler:^(NSInteger resultCode) {
|
||||
int filter_index_to_use = (filter_delegate != nil)
|
||||
? [filter_delegate filter]
|
||||
: filter_index;
|
||||
if (resultCode == NSFileHandlingPanelOKButton) {
|
||||
NSURL* url = savePanel.URL;
|
||||
const char* path = url.path.UTF8String;
|
||||
std::vector<base::FilePath> files(1, base::FilePath(path));
|
||||
callback.Run(filter_index_to_use, files);
|
||||
} else {
|
||||
callback.Run(filter_index_to_use,
|
||||
std::vector<base::FilePath>());
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CefFileDialogRunnerMac::CefFileDialogRunnerMac() {
|
||||
}
|
||||
CefFileDialogRunnerMac::CefFileDialogRunnerMac() {}
|
||||
|
||||
void CefFileDialogRunnerMac::Run(CefBrowserHostImpl* browser,
|
||||
const FileChooserParams& params,
|
||||
@@ -389,7 +393,7 @@ void CefFileDialogRunnerMac::Run(CefBrowserHostImpl* browser,
|
||||
RunOpenFileDialog(params, owner, filter_index, callback);
|
||||
} else if (params.mode == content::FileChooserParams::Save) {
|
||||
RunSaveFileDialog(params, owner, filter_index, callback);
|
||||
} else {
|
||||
} else {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
}
|
||||
|
@@ -66,8 +66,8 @@ std::wstring FormatFilterForExtensions(
|
||||
bool include_all_files) {
|
||||
const std::wstring all_ext = L"*.*";
|
||||
const std::wstring all_desc =
|
||||
l10n_util::GetStringUTF16(IDS_APP_SAVEAS_ALL_FILES) +
|
||||
L" (" + all_ext + L")";
|
||||
l10n_util::GetStringUTF16(IDS_APP_SAVEAS_ALL_FILES) + L" (" + all_ext +
|
||||
L")";
|
||||
|
||||
DCHECK(file_ext.size() >= ext_desc.size());
|
||||
|
||||
@@ -132,10 +132,10 @@ std::wstring GetDescriptionFromMimeType(const std::string& mime_type) {
|
||||
const char* mime_type;
|
||||
int string_id;
|
||||
} kWildCardMimeTypes[] = {
|
||||
{ "audio", IDS_AUDIO_FILES },
|
||||
{ "image", IDS_IMAGE_FILES },
|
||||
{ "text", IDS_TEXT_FILES },
|
||||
{ "video", IDS_VIDEO_FILES },
|
||||
{"audio", IDS_AUDIO_FILES},
|
||||
{"image", IDS_IMAGE_FILES},
|
||||
{"text", IDS_TEXT_FILES},
|
||||
{"video", IDS_VIDEO_FILES},
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < arraysize(kWildCardMimeTypes); ++i) {
|
||||
@@ -160,11 +160,9 @@ std::wstring GetFilterString(
|
||||
if (sep_index != base::string16::npos) {
|
||||
// Treat as a filter of the form "Filter Name|.ext1;.ext2;.ext3".
|
||||
const base::string16& desc = filter.substr(0, sep_index);
|
||||
const std::vector<base::string16>& ext =
|
||||
base::SplitString(filter.substr(sep_index + 1),
|
||||
base::ASCIIToUTF16(";"),
|
||||
base::TRIM_WHITESPACE,
|
||||
base::SPLIT_WANT_NONEMPTY);
|
||||
const std::vector<base::string16>& ext = base::SplitString(
|
||||
filter.substr(sep_index + 1), base::ASCIIToUTF16(";"),
|
||||
base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
||||
std::wstring ext_str;
|
||||
for (size_t x = 0; x < ext.size(); ++x) {
|
||||
const base::string16& file_ext = ext[x];
|
||||
@@ -205,11 +203,10 @@ std::wstring GetFilterString(
|
||||
|
||||
// From chrome/browser/views/shell_dialogs_win.cc
|
||||
|
||||
bool RunOpenFileDialog(
|
||||
const CefFileDialogRunner::FileChooserParams& params,
|
||||
HWND owner,
|
||||
int* filter_index,
|
||||
base::FilePath* path) {
|
||||
bool RunOpenFileDialog(const CefFileDialogRunner::FileChooserParams& params,
|
||||
HWND owner,
|
||||
int* filter_index,
|
||||
base::FilePath* path) {
|
||||
OPENFILENAME ofn;
|
||||
|
||||
// We must do this otherwise the ofn's FlagsEx may be initialized to random
|
||||
@@ -231,7 +228,7 @@ bool RunOpenFileDialog(
|
||||
} else {
|
||||
// The value is a file name and possibly a directory.
|
||||
base::wcslcpy(filename, params.default_file_name.value().c_str(),
|
||||
arraysize(filename));
|
||||
arraysize(filename));
|
||||
directory = params.default_file_name.DirName().value();
|
||||
}
|
||||
}
|
||||
@@ -248,8 +245,8 @@ bool RunOpenFileDialog(
|
||||
|
||||
// We use OFN_NOCHANGEDIR so that the user can rename or delete the directory
|
||||
// without having to close Chrome first.
|
||||
ofn.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_EXPLORER |
|
||||
OFN_ENABLESIZING;
|
||||
ofn.Flags =
|
||||
OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_EXPLORER | OFN_ENABLESIZING;
|
||||
if (params.hidereadonly)
|
||||
ofn.Flags |= OFN_HIDEREADONLY;
|
||||
|
||||
@@ -358,8 +355,7 @@ bool RunOpenMultiFileDialog(
|
||||
int CALLBACK BrowseCallbackProc(HWND window,
|
||||
UINT message,
|
||||
LPARAM parameter,
|
||||
LPARAM data)
|
||||
{
|
||||
LPARAM data) {
|
||||
if (message == BFFM_INITIALIZED) {
|
||||
// WParam is TRUE since passing a path.
|
||||
// data lParam member of the BROWSEINFO structure.
|
||||
@@ -368,10 +364,9 @@ int CALLBACK BrowseCallbackProc(HWND window,
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool RunOpenFolderDialog(
|
||||
const CefFileDialogRunner::FileChooserParams& params,
|
||||
HWND owner,
|
||||
base::FilePath* path) {
|
||||
bool RunOpenFolderDialog(const CefFileDialogRunner::FileChooserParams& params,
|
||||
HWND owner,
|
||||
base::FilePath* path) {
|
||||
wchar_t dir_buffer[MAX_PATH + 1] = {0};
|
||||
|
||||
bool result = false;
|
||||
@@ -423,11 +418,10 @@ bool RunOpenFolderDialog(
|
||||
return result;
|
||||
}
|
||||
|
||||
bool RunSaveFileDialog(
|
||||
const CefFileDialogRunner::FileChooserParams& params,
|
||||
HWND owner,
|
||||
int* filter_index,
|
||||
base::FilePath* path) {
|
||||
bool RunSaveFileDialog(const CefFileDialogRunner::FileChooserParams& params,
|
||||
HWND owner,
|
||||
int* filter_index,
|
||||
base::FilePath* path) {
|
||||
OPENFILENAME ofn;
|
||||
|
||||
// We must do this otherwise the ofn's FlagsEx may be initialized to random
|
||||
@@ -449,7 +443,7 @@ bool RunSaveFileDialog(
|
||||
} else {
|
||||
// The value is a file name and possibly a directory.
|
||||
base::wcslcpy(filename, params.default_file_name.value().c_str(),
|
||||
arraysize(filename));
|
||||
arraysize(filename));
|
||||
directory = params.default_file_name.DirName().value();
|
||||
}
|
||||
}
|
||||
@@ -466,8 +460,8 @@ bool RunSaveFileDialog(
|
||||
|
||||
// We use OFN_NOCHANGEDIR so that the user can rename or delete the directory
|
||||
// without having to close Chrome first.
|
||||
ofn.Flags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_NOCHANGEDIR |
|
||||
OFN_PATHMUSTEXIST;
|
||||
ofn.Flags =
|
||||
OFN_EXPLORER | OFN_ENABLESIZING | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST;
|
||||
if (params.hidereadonly)
|
||||
ofn.Flags |= OFN_HIDEREADONLY;
|
||||
if (params.overwriteprompt)
|
||||
@@ -493,8 +487,7 @@ bool RunSaveFileDialog(
|
||||
|
||||
} // namespace
|
||||
|
||||
CefFileDialogRunnerWin::CefFileDialogRunnerWin() {
|
||||
}
|
||||
CefFileDialogRunnerWin::CefFileDialogRunnerWin() {}
|
||||
|
||||
void CefFileDialogRunnerWin::Run(CefBrowserHostImpl* browser,
|
||||
const FileChooserParams& params,
|
||||
|
@@ -24,18 +24,16 @@ class CefJavaScriptDialogRunnerMac : public CefJavaScriptDialogRunner {
|
||||
~CefJavaScriptDialogRunnerMac() override;
|
||||
|
||||
// CefJavaScriptDialogRunner methods:
|
||||
void Run(
|
||||
CefBrowserHostImpl* browser,
|
||||
content::JavaScriptDialogType message_type,
|
||||
const base::string16& display_url,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback) override;
|
||||
void Run(CefBrowserHostImpl* browser,
|
||||
content::JavaScriptDialogType message_type,
|
||||
const base::string16& display_url,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback) override;
|
||||
void Cancel() override;
|
||||
|
||||
// Callback from CefJavaScriptDialogHelper when the dialog is closed.
|
||||
void DialogClosed(bool success,
|
||||
const base::string16& user_input);
|
||||
void DialogClosed(bool success, const base::string16& user_input);
|
||||
|
||||
private:
|
||||
DialogClosedCallback callback_;
|
||||
|
@@ -23,7 +23,7 @@
|
||||
}
|
||||
|
||||
- (id)initHelperWithCallback:
|
||||
(CefJavaScriptDialogRunner::DialogClosedCallback)callback;
|
||||
(CefJavaScriptDialogRunner::DialogClosedCallback)callback;
|
||||
- (NSAlert*)alert;
|
||||
- (NSTextField*)textField;
|
||||
- (void)alertDidEnd:(NSAlert*)alert
|
||||
@@ -36,7 +36,7 @@
|
||||
@implementation CefJavaScriptDialogHelper
|
||||
|
||||
- (id)initHelperWithCallback:
|
||||
(CefJavaScriptDialogRunner::DialogClosedCallback)callback {
|
||||
(CefJavaScriptDialogRunner::DialogClosedCallback)callback {
|
||||
if (self = [super init])
|
||||
callback_ = callback;
|
||||
|
||||
@@ -80,8 +80,7 @@
|
||||
@end
|
||||
|
||||
CefJavaScriptDialogRunnerMac::CefJavaScriptDialogRunnerMac()
|
||||
: weak_ptr_factory_(this) {
|
||||
}
|
||||
: weak_ptr_factory_(this) {}
|
||||
|
||||
CefJavaScriptDialogRunnerMac::~CefJavaScriptDialogRunnerMac() {
|
||||
Cancel();
|
||||
@@ -97,15 +96,13 @@ void CefJavaScriptDialogRunnerMac::Run(
|
||||
DCHECK(!helper_.get());
|
||||
callback_ = callback;
|
||||
|
||||
bool text_field =
|
||||
message_type == content::JAVASCRIPT_DIALOG_TYPE_PROMPT;
|
||||
bool one_button =
|
||||
message_type == content::JAVASCRIPT_DIALOG_TYPE_ALERT;
|
||||
bool text_field = message_type == content::JAVASCRIPT_DIALOG_TYPE_PROMPT;
|
||||
bool one_button = message_type == content::JAVASCRIPT_DIALOG_TYPE_ALERT;
|
||||
|
||||
helper_.reset(
|
||||
[[CefJavaScriptDialogHelper alloc] initHelperWithCallback:
|
||||
base::Bind(&CefJavaScriptDialogRunnerMac::DialogClosed,
|
||||
weak_ptr_factory_.GetWeakPtr())]);
|
||||
helper_.reset([[CefJavaScriptDialogHelper alloc]
|
||||
initHelperWithCallback:base::Bind(
|
||||
&CefJavaScriptDialogRunnerMac::DialogClosed,
|
||||
weak_ptr_factory_.GetWeakPtr())]);
|
||||
|
||||
// Show the modal dialog.
|
||||
NSAlert* alert = [helper_ alert];
|
||||
@@ -145,11 +142,10 @@ void CefJavaScriptDialogRunnerMac::Run(
|
||||
// building with the 10.11 SDK. See http://crbug.com/383820 for related
|
||||
// discussion.
|
||||
id nilArg = nil;
|
||||
[alert
|
||||
beginSheetModalForWindow:nilArg // nil here makes it app-modal
|
||||
modalDelegate:helper_
|
||||
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
|
||||
contextInfo:this];
|
||||
[alert beginSheetModalForWindow:nilArg // nil here makes it app-modal
|
||||
modalDelegate:helper_
|
||||
didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:)
|
||||
contextInfo:this];
|
||||
|
||||
if ([alert accessoryView])
|
||||
[[alert window] makeFirstResponder:[alert accessoryView]];
|
||||
|
@@ -18,8 +18,10 @@ class CefJavaScriptDialogRunnerWin;
|
||||
HHOOK CefJavaScriptDialogRunnerWin::msg_hook_ = NULL;
|
||||
int CefJavaScriptDialogRunnerWin::msg_hook_user_count_ = 0;
|
||||
|
||||
INT_PTR CALLBACK CefJavaScriptDialogRunnerWin::DialogProc(
|
||||
HWND dialog, UINT message, WPARAM wparam, LPARAM lparam) {
|
||||
INT_PTR CALLBACK CefJavaScriptDialogRunnerWin::DialogProc(HWND dialog,
|
||||
UINT message,
|
||||
WPARAM wparam,
|
||||
LPARAM lparam) {
|
||||
switch (message) {
|
||||
case WM_INITDIALOG: {
|
||||
SetWindowLongPtr(dialog, DWLP_USER, static_cast<LONG_PTR>(lparam));
|
||||
@@ -84,10 +86,7 @@ INT_PTR CALLBACK CefJavaScriptDialogRunnerWin::DialogProc(
|
||||
}
|
||||
|
||||
CefJavaScriptDialogRunnerWin::CefJavaScriptDialogRunnerWin()
|
||||
: dialog_win_(NULL),
|
||||
parent_win_(NULL),
|
||||
hook_installed_(false) {
|
||||
}
|
||||
: dialog_win_(NULL), parent_win_(NULL), hook_installed_(false) {}
|
||||
|
||||
CefJavaScriptDialogRunnerWin::~CefJavaScriptDialogRunnerWin() {
|
||||
Cancel();
|
||||
@@ -129,17 +128,15 @@ void CefJavaScriptDialogRunnerWin::Run(
|
||||
DCHECK(hModule);
|
||||
|
||||
parent_win_ = GetAncestor(browser->GetWindowHandle(), GA_ROOT);
|
||||
dialog_win_ = CreateDialogParam(hModule,
|
||||
MAKEINTRESOURCE(dialog_type),
|
||||
parent_win_,
|
||||
DialogProc,
|
||||
reinterpret_cast<LPARAM>(this));
|
||||
dialog_win_ =
|
||||
CreateDialogParam(hModule, MAKEINTRESOURCE(dialog_type), parent_win_,
|
||||
DialogProc, reinterpret_cast<LPARAM>(this));
|
||||
DCHECK(dialog_win_);
|
||||
|
||||
if (!display_url.empty()) {
|
||||
// Add the display URL to the window title.
|
||||
TCHAR text[64];
|
||||
GetWindowText(dialog_win_, text, sizeof(text)/sizeof(TCHAR));
|
||||
GetWindowText(dialog_win_, text, sizeof(text) / sizeof(TCHAR));
|
||||
|
||||
base::string16 new_window_text =
|
||||
text + base::ASCIIToUTF16(" - ") + display_url;
|
||||
@@ -181,13 +178,14 @@ void CefJavaScriptDialogRunnerWin::Cancel() {
|
||||
}
|
||||
|
||||
// static
|
||||
LRESULT CALLBACK CefJavaScriptDialogRunnerWin::GetMsgProc(
|
||||
int code, WPARAM wparam, LPARAM lparam) {
|
||||
LRESULT CALLBACK CefJavaScriptDialogRunnerWin::GetMsgProc(int code,
|
||||
WPARAM wparam,
|
||||
LPARAM lparam) {
|
||||
// Mostly borrowed from http://support.microsoft.com/kb/q187988/
|
||||
// and http://www.codeproject.com/KB/atl/cdialogmessagehook.aspx.
|
||||
LPMSG msg = reinterpret_cast<LPMSG>(lparam);
|
||||
if (code >= 0 && wparam == PM_REMOVE &&
|
||||
msg->message >= WM_KEYFIRST && msg->message <= WM_KEYLAST) {
|
||||
if (code >= 0 && wparam == PM_REMOVE && msg->message >= WM_KEYFIRST &&
|
||||
msg->message <= WM_KEYLAST) {
|
||||
HWND hwnd = GetActiveWindow();
|
||||
if (::IsWindow(hwnd) && ::IsDialogMessage(hwnd, msg)) {
|
||||
// The value returned from this hookproc is ignored, and it cannot
|
||||
@@ -216,8 +214,7 @@ bool CefJavaScriptDialogRunnerWin::InstallMessageHook() {
|
||||
|
||||
msg_hook_ = ::SetWindowsHookEx(WH_GETMESSAGE,
|
||||
&CefJavaScriptDialogRunnerWin::GetMsgProc,
|
||||
NULL,
|
||||
GetCurrentThreadId());
|
||||
NULL, GetCurrentThreadId());
|
||||
DCHECK(msg_hook_ != NULL);
|
||||
return msg_hook_ != NULL;
|
||||
}
|
||||
|
@@ -15,13 +15,12 @@ class CefJavaScriptDialogRunnerWin : public CefJavaScriptDialogRunner {
|
||||
~CefJavaScriptDialogRunnerWin() override;
|
||||
|
||||
// CefJavaScriptDialogRunner methods:
|
||||
void Run(
|
||||
CefBrowserHostImpl* browser,
|
||||
content::JavaScriptDialogType message_type,
|
||||
const base::string16& display_url,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback) override;
|
||||
void Run(CefBrowserHostImpl* browser,
|
||||
content::JavaScriptDialogType message_type,
|
||||
const base::string16& display_url,
|
||||
const base::string16& message_text,
|
||||
const base::string16& default_prompt_text,
|
||||
const DialogClosedCallback& callback) override;
|
||||
void Cancel() override;
|
||||
|
||||
private:
|
||||
@@ -35,7 +34,9 @@ class CefJavaScriptDialogRunnerWin : public CefJavaScriptDialogRunner {
|
||||
|
||||
bool hook_installed_;
|
||||
|
||||
static INT_PTR CALLBACK DialogProc(HWND dialog, UINT message, WPARAM wparam,
|
||||
static INT_PTR CALLBACK DialogProc(HWND dialog,
|
||||
UINT message,
|
||||
WPARAM wparam,
|
||||
LPARAM lparam);
|
||||
|
||||
// Since the message loop we expect to run in isn't going to be nicely
|
||||
|
@@ -10,8 +10,7 @@
|
||||
namespace views {
|
||||
|
||||
Menu2::Menu2(ui::MenuModel* model)
|
||||
: model_(model),
|
||||
wrapper_(MenuWrapper::CreateWrapper(model)) {
|
||||
: model_(model), wrapper_(MenuWrapper::CreateWrapper(model)) {
|
||||
Rebuild();
|
||||
}
|
||||
|
||||
|
@@ -31,10 +31,7 @@ class Menu2 {
|
||||
public:
|
||||
// How the menu is aligned relative to the point it is shown at.
|
||||
// The alignment is reversed by menu if text direction is right to left.
|
||||
enum Alignment {
|
||||
ALIGN_TOPLEFT,
|
||||
ALIGN_TOPRIGHT
|
||||
};
|
||||
enum Alignment { ALIGN_TOPLEFT, ALIGN_TOPRIGHT };
|
||||
|
||||
// Creates a new menu populated with the contents of |model|.
|
||||
// WARNING: this populates the menu on construction by invoking methods on
|
||||
@@ -83,7 +80,6 @@ class Menu2 {
|
||||
void SetMinimumWidth(int width);
|
||||
|
||||
private:
|
||||
|
||||
ui::MenuModel* model_;
|
||||
|
||||
// The object that actually implements the menu.
|
||||
|
@@ -10,8 +10,7 @@
|
||||
#include "base/strings/string_util.h"
|
||||
#include "ui/gfx/geometry/point.h"
|
||||
|
||||
CefMenuRunnerLinux::CefMenuRunnerLinux() {
|
||||
}
|
||||
CefMenuRunnerLinux::CefMenuRunnerLinux() {}
|
||||
|
||||
bool CefMenuRunnerLinux::RunContextMenu(
|
||||
CefBrowserHostImpl* browser,
|
||||
@@ -27,11 +26,9 @@ bool CefMenuRunnerLinux::RunContextMenu(
|
||||
if (!browser->IsWindowless())
|
||||
parent_widget = browser->GetWindowWidget();
|
||||
|
||||
views::MenuRunner::RunResult result =
|
||||
menu_->RunMenuAt(parent_widget,
|
||||
NULL, gfx::Rect(screen_point, gfx::Size()),
|
||||
views::MENU_ANCHOR_TOPRIGHT,
|
||||
ui::MENU_SOURCE_NONE);
|
||||
views::MenuRunner::RunResult result = menu_->RunMenuAt(
|
||||
parent_widget, NULL, gfx::Rect(screen_point, gfx::Size()),
|
||||
views::MENU_ANCHOR_TOPRIGHT, ui::MENU_SOURCE_NONE);
|
||||
ALLOW_UNUSED_LOCAL(result);
|
||||
|
||||
return true;
|
||||
|
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "ui/views/controls/menu/menu_runner.h"
|
||||
|
||||
class CefMenuRunnerLinux: public CefMenuRunner {
|
||||
class CefMenuRunnerLinux : public CefMenuRunner {
|
||||
public:
|
||||
CefMenuRunnerLinux();
|
||||
|
||||
|
@@ -6,17 +6,15 @@
|
||||
|
||||
#include "libcef/browser/browser_host_impl.h"
|
||||
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#import "base/mac/scoped_sending_event.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#import "ui/base/cocoa/menu_controller.h"
|
||||
#include "ui/gfx/geometry/point.h"
|
||||
|
||||
CefMenuRunnerMac::CefMenuRunnerMac() {
|
||||
}
|
||||
CefMenuRunnerMac::CefMenuRunnerMac() {}
|
||||
|
||||
CefMenuRunnerMac::~CefMenuRunnerMac() {
|
||||
}
|
||||
CefMenuRunnerMac::~CefMenuRunnerMac() {}
|
||||
|
||||
bool CefMenuRunnerMac::RunContextMenu(
|
||||
CefBrowserHostImpl* browser,
|
||||
@@ -88,4 +86,3 @@ void CefMenuRunnerMac::CancelContextMenu() {
|
||||
if (menu_controller_.get())
|
||||
[menu_controller_ cancel];
|
||||
}
|
||||
|
||||
|
@@ -10,8 +10,7 @@
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "ui/gfx/geometry/point.h"
|
||||
|
||||
CefMenuRunnerWin::CefMenuRunnerWin() {
|
||||
}
|
||||
CefMenuRunnerWin::CefMenuRunnerWin() {}
|
||||
|
||||
bool CefMenuRunnerWin::RunContextMenu(
|
||||
CefBrowserHostImpl* browser,
|
||||
|
@@ -10,7 +10,6 @@
|
||||
|
||||
#include "libcef/browser/native/native_menu_win.h"
|
||||
|
||||
|
||||
class CefMenuRunnerWin : public CefMenuRunner {
|
||||
public:
|
||||
CefMenuRunnerWin();
|
||||
|
@@ -57,7 +57,10 @@ namespace {
|
||||
// HDC to back the canvas if one doesn't already exist, tearing it down
|
||||
// before returning. If |src_rect| is null, copies the entire canvas.
|
||||
// Deleted from skia/ext/platform_canvas.h in https://crbug.com/675977#c13
|
||||
void DrawToNativeContext(SkCanvas* canvas, HDC destination_hdc, int x, int y,
|
||||
void DrawToNativeContext(SkCanvas* canvas,
|
||||
HDC destination_hdc,
|
||||
int x,
|
||||
int y,
|
||||
const RECT* src_rect) {
|
||||
RECT temp_rect;
|
||||
if (!src_rect) {
|
||||
@@ -111,9 +114,7 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
gfx::SetWindowUserData(hwnd_, this);
|
||||
}
|
||||
|
||||
~MenuHostWindow() {
|
||||
DestroyWindow(hwnd_);
|
||||
}
|
||||
~MenuHostWindow() { DestroyWindow(hwnd_); }
|
||||
|
||||
HWND hwnd() const { return hwnd_; }
|
||||
|
||||
@@ -127,17 +128,9 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
|
||||
WNDCLASSEX window_class;
|
||||
base::win::InitializeWindowClass(
|
||||
kWindowClassName,
|
||||
&base::win::WrappedWindowProc<MenuHostWindowProc>,
|
||||
CS_DBLCLKS,
|
||||
0,
|
||||
0,
|
||||
NULL,
|
||||
reinterpret_cast<HBRUSH>(COLOR_WINDOW+1),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&window_class);
|
||||
kWindowClassName, &base::win::WrappedWindowProc<MenuHostWindowProc>,
|
||||
CS_DBLCLKS, 0, 0, NULL, reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1),
|
||||
NULL, NULL, NULL, &window_class);
|
||||
ATOM clazz = RegisterClassEx(&window_class);
|
||||
CHECK(clazz);
|
||||
registered = true;
|
||||
@@ -201,8 +194,8 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
if (data) {
|
||||
gfx::FontList font_list;
|
||||
measure_item_struct->itemWidth =
|
||||
gfx::GetStringWidth(data->label, font_list) +
|
||||
kIconWidth + kItemLeftMargin + views::kItemLabelSpacing -
|
||||
gfx::GetStringWidth(data->label, font_list) + kIconWidth +
|
||||
kItemLeftMargin + views::kItemLabelSpacing -
|
||||
GetSystemMetrics(SM_CXMENUCHECK);
|
||||
if (data->submenu.get())
|
||||
measure_item_struct->itemWidth += kArrowWidth;
|
||||
@@ -275,8 +268,8 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
static_cast<int>(label.size()), &rect, format | DT_LEFT, NULL);
|
||||
if (!accel.empty())
|
||||
DrawTextEx(dc, const_cast<wchar_t*>(accel.data()),
|
||||
static_cast<int>(accel.size()), &rect,
|
||||
format | DT_RIGHT, NULL);
|
||||
static_cast<int>(accel.size()), &rect, format | DT_RIGHT,
|
||||
NULL);
|
||||
SelectObject(dc, old_font);
|
||||
|
||||
ui::MenuModel::ItemType type =
|
||||
@@ -293,10 +286,12 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
skia_icon.width(), skia_icon.height(), false);
|
||||
canvas->drawBitmap(*skia_icon.bitmap(), 0, 0);
|
||||
DrawToNativeContext(
|
||||
canvas.get(), dc,
|
||||
draw_item_struct->rcItem.left + kItemLeftMargin,
|
||||
draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom -
|
||||
draw_item_struct->rcItem.top - skia_icon.height()) / 2, NULL);
|
||||
canvas.get(), dc, draw_item_struct->rcItem.left + kItemLeftMargin,
|
||||
draw_item_struct->rcItem.top +
|
||||
(draw_item_struct->rcItem.bottom -
|
||||
draw_item_struct->rcItem.top - skia_icon.height()) /
|
||||
2,
|
||||
NULL);
|
||||
} else if (type == ui::MenuModel::TYPE_CHECK &&
|
||||
data->native_menu_win->model_->IsItemCheckedAt(
|
||||
data->model_index)) {
|
||||
@@ -306,8 +301,9 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
if (draw_item_struct->itemState & ODS_DISABLED) {
|
||||
state = NativeTheme::kDisabled;
|
||||
} else {
|
||||
state = draw_item_struct->itemState & ODS_SELECTED ?
|
||||
NativeTheme::kHovered : NativeTheme::kNormal;
|
||||
state = draw_item_struct->itemState & ODS_SELECTED
|
||||
? NativeTheme::kHovered
|
||||
: NativeTheme::kNormal;
|
||||
}
|
||||
|
||||
std::unique_ptr<SkCanvas> canvas = skia::CreatePlatformCanvas(
|
||||
@@ -321,17 +317,19 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
// Draw the background and the check.
|
||||
ui::NativeTheme* native_theme =
|
||||
ui::NativeTheme::GetInstanceForNativeUi();
|
||||
native_theme->Paint(
|
||||
&paint_canvas, NativeTheme::kMenuCheckBackground,
|
||||
state, bounds, extra);
|
||||
native_theme->Paint(
|
||||
&paint_canvas, NativeTheme::kMenuCheck, state, bounds, extra);
|
||||
native_theme->Paint(&paint_canvas, NativeTheme::kMenuCheckBackground,
|
||||
state, bounds, extra);
|
||||
native_theme->Paint(&paint_canvas, NativeTheme::kMenuCheck, state,
|
||||
bounds, extra);
|
||||
|
||||
// Draw checkbox to menu.
|
||||
DrawToNativeContext(canvas.get(), dc,
|
||||
draw_item_struct->rcItem.left + kItemLeftMargin,
|
||||
draw_item_struct->rcItem.top + (draw_item_struct->rcItem.bottom -
|
||||
draw_item_struct->rcItem.top - config.check_height) / 2, NULL);
|
||||
DrawToNativeContext(
|
||||
canvas.get(), dc, draw_item_struct->rcItem.left + kItemLeftMargin,
|
||||
draw_item_struct->rcItem.top +
|
||||
(draw_item_struct->rcItem.bottom -
|
||||
draw_item_struct->rcItem.top - config.check_height) /
|
||||
2,
|
||||
NULL);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -367,7 +365,7 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
OnDrawItem(w_param, reinterpret_cast<DRAWITEMSTRUCT*>(l_param));
|
||||
*l_result = 0;
|
||||
return true;
|
||||
// TODO(beng): bring over owner draw from old menu system.
|
||||
// TODO(beng): bring over owner draw from old menu system.
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -395,11 +393,7 @@ class CefNativeMenuWin::MenuHostWindow {
|
||||
|
||||
struct CefNativeMenuWin::HighlightedMenuItemInfo {
|
||||
HighlightedMenuItemInfo()
|
||||
: has_parent(false),
|
||||
has_submenu(false),
|
||||
menu(NULL),
|
||||
position(-1) {
|
||||
}
|
||||
: has_parent(false), has_submenu(false), menu(NULL), position(-1) {}
|
||||
|
||||
bool has_parent;
|
||||
bool has_submenu;
|
||||
@@ -428,8 +422,7 @@ CefNativeMenuWin::CefNativeMenuWin(ui::MenuModel* model, HWND system_menu_for)
|
||||
position_to_select_(-1),
|
||||
parent_(NULL),
|
||||
destroyed_flag_(NULL),
|
||||
menu_to_select_factory_(this) {
|
||||
}
|
||||
menu_to_select_factory_(this) {}
|
||||
|
||||
CefNativeMenuWin::~CefNativeMenuWin() {
|
||||
if (destroyed_flag_)
|
||||
@@ -481,9 +474,8 @@ void CefNativeMenuWin::RunMenuAt(const gfx::Point& point, int alignment) {
|
||||
// does.
|
||||
menu_to_select_factory_.InvalidateWeakPtrs();
|
||||
base::ThreadTaskRunnerHandle::Get()->PostTask(
|
||||
FROM_HERE,
|
||||
base::Bind(&CefNativeMenuWin::DelayedSelect,
|
||||
menu_to_select_factory_.GetWeakPtr()));
|
||||
FROM_HERE, base::Bind(&CefNativeMenuWin::DelayedSelect,
|
||||
menu_to_select_factory_.GetWeakPtr()));
|
||||
menu_action_ = MENU_ACTION_SELECTED;
|
||||
}
|
||||
// Send MenuWillClose after we schedule the select, otherwise MenuWillClose is
|
||||
@@ -502,7 +494,7 @@ void CefNativeMenuWin::Rebuild(MenuInsertionDelegateWin* delegate) {
|
||||
owner_draw_ = model_->HasIcons() || owner_draw_;
|
||||
first_item_index_ = delegate ? delegate->GetInsertionIndex(menu_) : 0;
|
||||
for (int menu_index = first_item_index_;
|
||||
menu_index < first_item_index_ + model_->GetItemCount(); ++menu_index) {
|
||||
menu_index < first_item_index_ + model_->GetItemCount(); ++menu_index) {
|
||||
int model_index = menu_index - first_item_index_;
|
||||
if (model_->GetTypeAt(model_index) == ui::MenuModel::TYPE_SEPARATOR)
|
||||
AddSeparatorItemAt(menu_index, model_index);
|
||||
@@ -585,8 +577,9 @@ bool CefNativeMenuWin::GetHighlightedMenuItemInfo(
|
||||
}
|
||||
|
||||
// static
|
||||
LRESULT CALLBACK CefNativeMenuWin::MenuMessageHook(
|
||||
int n_code, WPARAM w_param, LPARAM l_param) {
|
||||
LRESULT CALLBACK CefNativeMenuWin::MenuMessageHook(int n_code,
|
||||
WPARAM w_param,
|
||||
LPARAM l_param) {
|
||||
LRESULT result = CallNextHookEx(NULL, n_code, w_param, l_param);
|
||||
|
||||
CefNativeMenuWin* this_ptr = open_native_menu_win_;
|
||||
@@ -685,8 +678,10 @@ void CefNativeMenuWin::AddSeparatorItemAt(int menu_index, int model_index) {
|
||||
InsertMenuItem(menu_, menu_index, TRUE, &mii);
|
||||
}
|
||||
|
||||
void CefNativeMenuWin::SetMenuItemState(
|
||||
int menu_index, bool enabled, bool checked, bool is_default) {
|
||||
void CefNativeMenuWin::SetMenuItemState(int menu_index,
|
||||
bool enabled,
|
||||
bool checked,
|
||||
bool is_default) {
|
||||
if (IsSeparatorItemAt(menu_index))
|
||||
return;
|
||||
|
||||
@@ -704,8 +699,8 @@ void CefNativeMenuWin::SetMenuItemState(
|
||||
}
|
||||
|
||||
void CefNativeMenuWin::SetMenuItemLabel(int menu_index,
|
||||
int model_index,
|
||||
const base::string16& label) {
|
||||
int model_index,
|
||||
const base::string16& label) {
|
||||
if (IsSeparatorItemAt(menu_index))
|
||||
return;
|
||||
|
||||
@@ -715,9 +710,10 @@ void CefNativeMenuWin::SetMenuItemLabel(int menu_index,
|
||||
SetMenuItemInfo(menu_, menu_index, MF_BYPOSITION, &mii);
|
||||
}
|
||||
|
||||
void CefNativeMenuWin::UpdateMenuItemInfoForString(MENUITEMINFO* mii,
|
||||
int model_index,
|
||||
const base::string16& label) {
|
||||
void CefNativeMenuWin::UpdateMenuItemInfoForString(
|
||||
MENUITEMINFO* mii,
|
||||
int model_index,
|
||||
const base::string16& label) {
|
||||
base::string16 formatted = label;
|
||||
ui::MenuModel::ItemType type = model_->GetTypeAt(model_index);
|
||||
// Strip out any tabs, otherwise they get interpreted as accelerators and can
|
||||
@@ -738,8 +734,7 @@ void CefNativeMenuWin::UpdateMenuItemInfoForString(MENUITEMINFO* mii,
|
||||
|
||||
// Give Windows a pointer to the label string.
|
||||
mii->fMask |= MIIM_STRING;
|
||||
mii->dwTypeData =
|
||||
const_cast<wchar_t*>(items_[model_index]->label.c_str());
|
||||
mii->dwTypeData = const_cast<wchar_t*>(items_[model_index]->label.c_str());
|
||||
}
|
||||
|
||||
UINT CefNativeMenuWin::GetAlignmentFlags(int alignment) const {
|
||||
|
@@ -10,8 +10,8 @@
|
||||
|
||||
#include "libcef/browser/native/menu_wrapper.h"
|
||||
|
||||
#include "base/macros.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/strings/string16.h"
|
||||
@@ -105,8 +105,9 @@ class CefNativeMenuWin : public MenuWrapper {
|
||||
HighlightedMenuItemInfo* info);
|
||||
|
||||
// Hook to receive keyboard events while the menu is open.
|
||||
static LRESULT CALLBACK MenuMessageHook(
|
||||
int n_code, WPARAM w_param, LPARAM l_param);
|
||||
static LRESULT CALLBACK MenuMessageHook(int n_code,
|
||||
WPARAM w_param,
|
||||
LPARAM l_param);
|
||||
|
||||
// Our attached model and delegate.
|
||||
ui::MenuModel* model_;
|
||||
|
@@ -11,14 +11,11 @@
|
||||
#include "ui/views/widget/widget.h"
|
||||
|
||||
CefWindowDelegateView::CefWindowDelegateView(SkColor background_color)
|
||||
: background_color_(background_color),
|
||||
web_view_(NULL) {
|
||||
}
|
||||
: background_color_(background_color), web_view_(NULL) {}
|
||||
|
||||
void CefWindowDelegateView::Init(
|
||||
gfx::AcceleratedWidget parent_widget,
|
||||
content::WebContents* web_contents,
|
||||
const gfx::Rect& bounds) {
|
||||
void CefWindowDelegateView::Init(gfx::AcceleratedWidget parent_widget,
|
||||
content::WebContents* web_contents,
|
||||
const gfx::Rect& bounds) {
|
||||
DCHECK(!web_view_);
|
||||
web_view_ = new views::WebView(web_contents->GetBrowserContext());
|
||||
web_view_->SetWebContents(web_contents);
|
||||
@@ -67,4 +64,3 @@ void CefWindowDelegateView::ViewHierarchyChanged(
|
||||
if (details.is_add && details.child == this)
|
||||
InitContent();
|
||||
}
|
||||
|
||||
|
@@ -6,10 +6,10 @@
|
||||
#include "libcef/browser/native/window_x11.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
#include <X11/extensions/XInput2.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/extensions/XInput2.h>
|
||||
|
||||
#include "ui/base/x/x11_util.h"
|
||||
#include "ui/events/platform/platform_event_source.h"
|
||||
@@ -28,15 +28,8 @@ const char kNetWMState[] = "_NET_WM_STATE";
|
||||
const char kXdndProxy[] = "XdndProxy";
|
||||
|
||||
const char* kAtomsToCache[] = {
|
||||
kAtom,
|
||||
kWMDeleteWindow,
|
||||
kWMProtocols,
|
||||
kNetWMPid,
|
||||
kNetWMPing,
|
||||
kNetWMState,
|
||||
kXdndProxy,
|
||||
NULL
|
||||
};
|
||||
kAtom, kWMDeleteWindow, kWMProtocols, kNetWMPid,
|
||||
kNetWMPing, kNetWMState, kXdndProxy, NULL};
|
||||
|
||||
::Window FindEventTarget(const base::NativeEvent& xev) {
|
||||
::Window target = xev->xany.window;
|
||||
@@ -93,15 +86,15 @@ CEF_EXPORT XDisplay* cef_get_xdisplay() {
|
||||
CefWindowX11::CefWindowX11(CefRefPtr<CefBrowserHostImpl> browser,
|
||||
::Window parent_xwindow,
|
||||
const gfx::Rect& bounds)
|
||||
: browser_(browser),
|
||||
xdisplay_(gfx::GetXDisplay()),
|
||||
parent_xwindow_(parent_xwindow),
|
||||
xwindow_(0),
|
||||
window_mapped_(false),
|
||||
bounds_(bounds),
|
||||
focus_pending_(false),
|
||||
atom_cache_(xdisplay_, kAtomsToCache),
|
||||
weak_ptr_factory_(this) {
|
||||
: browser_(browser),
|
||||
xdisplay_(gfx::GetXDisplay()),
|
||||
parent_xwindow_(parent_xwindow),
|
||||
xwindow_(0),
|
||||
window_mapped_(false),
|
||||
bounds_(bounds),
|
||||
focus_pending_(false),
|
||||
atom_cache_(xdisplay_, kAtomsToCache),
|
||||
weak_ptr_factory_(this) {
|
||||
if (parent_xwindow_ == None)
|
||||
parent_xwindow_ = DefaultRootWindow(xdisplay_);
|
||||
|
||||
@@ -109,15 +102,13 @@ CefWindowX11::CefWindowX11(CefRefPtr<CefBrowserHostImpl> browser,
|
||||
memset(&swa, 0, sizeof(swa));
|
||||
swa.background_pixmap = None;
|
||||
swa.override_redirect = false;
|
||||
xwindow_ = XCreateWindow(
|
||||
xdisplay_, parent_xwindow_,
|
||||
bounds.x(), bounds.y(), bounds.width(), bounds.height(),
|
||||
0, // border width
|
||||
CopyFromParent, // depth
|
||||
InputOutput,
|
||||
CopyFromParent, // visual
|
||||
CWBackPixmap | CWOverrideRedirect,
|
||||
&swa);
|
||||
xwindow_ = XCreateWindow(xdisplay_, parent_xwindow_, bounds.x(), bounds.y(),
|
||||
bounds.width(), bounds.height(),
|
||||
0, // border width
|
||||
CopyFromParent, // depth
|
||||
InputOutput,
|
||||
CopyFromParent, // visual
|
||||
CWBackPixmap | CWOverrideRedirect, &swa);
|
||||
|
||||
if (ui::PlatformEventSource::GetInstance())
|
||||
ui::PlatformEventSource::GetInstance()->AddPlatformEventDispatcher(this);
|
||||
@@ -144,12 +135,8 @@ CefWindowX11::CefWindowX11(CefRefPtr<CefBrowserHostImpl> browser,
|
||||
static_assert(sizeof(long) >= sizeof(pid_t),
|
||||
"pid_t should not be larger than long");
|
||||
long pid = getpid();
|
||||
XChangeProperty(xdisplay_,
|
||||
xwindow_,
|
||||
atom_cache_.GetAtom(kNetWMPid),
|
||||
XA_CARDINAL,
|
||||
32,
|
||||
PropModeReplace,
|
||||
XChangeProperty(xdisplay_, xwindow_, atom_cache_.GetAtom(kNetWMPid),
|
||||
XA_CARDINAL, 32, PropModeReplace,
|
||||
reinterpret_cast<unsigned char*>(&pid), 1);
|
||||
|
||||
// Allow subclasses to create and cache additional atoms.
|
||||
@@ -213,21 +200,14 @@ void CefWindowX11::Show() {
|
||||
|
||||
if (proxy_target != child) {
|
||||
// Set the proxy target for the top-most window.
|
||||
XChangeProperty(xdisplay_,
|
||||
toplevel_window,
|
||||
atom_cache_.GetAtom(kXdndProxy),
|
||||
XA_WINDOW,
|
||||
32,
|
||||
PropModeReplace,
|
||||
reinterpret_cast<unsigned char*>(&child), 1);
|
||||
XChangeProperty(xdisplay_, toplevel_window,
|
||||
atom_cache_.GetAtom(kXdndProxy), XA_WINDOW, 32,
|
||||
PropModeReplace,
|
||||
reinterpret_cast<unsigned char*>(&child), 1);
|
||||
// Do the same for the proxy target per the spec.
|
||||
XChangeProperty(xdisplay_,
|
||||
child,
|
||||
atom_cache_.GetAtom(kXdndProxy),
|
||||
XA_WINDOW,
|
||||
32,
|
||||
PropModeReplace,
|
||||
reinterpret_cast<unsigned char*>(&child), 1);
|
||||
XChangeProperty(xdisplay_, child, atom_cache_.GetAtom(kXdndProxy),
|
||||
XA_WINDOW, 32, PropModeReplace,
|
||||
reinterpret_cast<unsigned char*>(&child), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,7 +284,7 @@ views::DesktopWindowTreeHostX11* CefWindowX11::GetHost() {
|
||||
|
||||
bool CefWindowX11::CanDispatchEvent(const ui::PlatformEvent& event) {
|
||||
::Window target = FindEventTarget(event);
|
||||
return target == xwindow_;
|
||||
return target == xwindow_;
|
||||
}
|
||||
|
||||
uint32_t CefWindowX11::DispatchEvent(const ui::PlatformEvent& event) {
|
||||
@@ -317,7 +297,7 @@ uint32_t CefWindowX11::DispatchEvent(const ui::PlatformEvent& event) {
|
||||
// than from within Aura (e.g. the X window manager can change the
|
||||
// size). Make sure the root window size is maintained properly.
|
||||
gfx::Rect bounds(xev->xconfigure.x, xev->xconfigure.y,
|
||||
xev->xconfigure.width, xev->xconfigure.height);
|
||||
xev->xconfigure.width, xev->xconfigure.height);
|
||||
bounds_ = bounds;
|
||||
|
||||
if (browser_.get()) {
|
||||
@@ -348,9 +328,7 @@ uint32_t CefWindowX11::DispatchEvent(const ui::PlatformEvent& event) {
|
||||
XEvent reply_event = *xev;
|
||||
reply_event.xclient.window = parent_xwindow_;
|
||||
|
||||
XSendEvent(xdisplay_,
|
||||
reply_event.xclient.window,
|
||||
False,
|
||||
XSendEvent(xdisplay_, reply_event.xclient.window, False,
|
||||
SubstructureRedirectMask | SubstructureNotifyMask,
|
||||
&reply_event);
|
||||
XFlush(xdisplay_);
|
||||
@@ -378,9 +356,9 @@ uint32_t CefWindowX11::DispatchEvent(const ui::PlatformEvent& event) {
|
||||
if (!focus_pending_) {
|
||||
focus_pending_ = true;
|
||||
CEF_POST_DELAYED_TASK(CEF_UIT,
|
||||
base::Bind(&CefWindowX11::ContinueFocus,
|
||||
weak_ptr_factory_.GetWeakPtr()),
|
||||
100);
|
||||
base::Bind(&CefWindowX11::ContinueFocus,
|
||||
weak_ptr_factory_.GetWeakPtr()),
|
||||
100);
|
||||
}
|
||||
break;
|
||||
case FocusOut:
|
||||
@@ -400,20 +378,18 @@ uint32_t CefWindowX11::DispatchEvent(const ui::PlatformEvent& event) {
|
||||
// Forward the state change to the child DesktopWindowTreeHostX11
|
||||
// window so that resource usage will be reduced while the window is
|
||||
// minimized.
|
||||
std::vector< ::Atom> atom_list;
|
||||
std::vector<::Atom> atom_list;
|
||||
if (ui::GetAtomArrayProperty(xwindow_, kNetWMState, &atom_list) &&
|
||||
!atom_list.empty()) {
|
||||
ui::SetAtomArrayProperty(child, kNetWMState, "ATOM", atom_list);
|
||||
} else {
|
||||
// Set an empty list of property values to pass the check in
|
||||
// DesktopWindowTreeHostX11::OnWMStateUpdated().
|
||||
XChangeProperty(xdisplay_,
|
||||
child,
|
||||
XChangeProperty(xdisplay_, child,
|
||||
atom_cache_.GetAtom(kNetWMState), // name
|
||||
atom_cache_.GetAtom(kAtom), // type
|
||||
atom_cache_.GetAtom(kAtom), // type
|
||||
32, // size in bits of items in 'value'
|
||||
PropModeReplace,
|
||||
NULL,
|
||||
PropModeReplace, NULL,
|
||||
0); // num items
|
||||
}
|
||||
}
|
||||
@@ -433,4 +409,3 @@ void CefWindowX11::ContinueFocus() {
|
||||
browser_->SetFocus(true);
|
||||
focus_pending_ = false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user