Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Unified Diff: ui/views/cocoa/bridged_native_widget.mm

Issue 782673002: MacViews: tryjobs for toolkit_views=1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: With SetNativeWindowProperty Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.h ('k') | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/cocoa/bridged_native_widget.mm
diff --git a/ui/views/cocoa/bridged_native_widget.mm b/ui/views/cocoa/bridged_native_widget.mm
index 591f4cba9f2232b5969c2d79e46de9a81c37cf90..ed1339d38afd318d0bf43b44f67c94dfdcabc8fb 100644
--- a/ui/views/cocoa/bridged_native_widget.mm
+++ b/ui/views/cocoa/bridged_native_widget.mm
@@ -4,6 +4,8 @@
#import "ui/views/cocoa/bridged_native_widget.h"
+#import <objc/runtime.h>
+
#include "base/logging.h"
#include "base/mac/mac_util.h"
#import "base/mac/sdk_forward_declarations.h"
@@ -27,6 +29,8 @@
namespace {
+int kWindowPropertiesKey;
+
float GetDeviceScaleFactorFromView(NSView* view) {
gfx::Display display =
gfx::Screen::GetScreenFor(view)->GetDisplayNearestWindow(view);
@@ -208,6 +212,22 @@ bool BridgedNativeWidget::HasCapture() {
return mouse_capture_ && mouse_capture_->IsActive();
}
+void BridgedNativeWidget::SetNativeWindowProperty(const char* name,
+ void* value) {
+ NSString* key = [NSString stringWithUTF8String:name];
+ if (value) {
+ [GetWindowProperties() setObject:[NSValue valueWithPointer:value]
+ forKey:key];
+ } else {
+ [GetWindowProperties() removeObjectForKey:key];
+ }
+}
+
+void* BridgedNativeWidget::GetNativeWindowProperty(const char* name) const {
+ NSString* key = [NSString stringWithUTF8String:name];
+ return [[GetWindowProperties() objectForKey:key] pointerValue];
+}
+
void BridgedNativeWidget::OnWindowWillClose() {
if (parent_)
parent_->RemoveChildWindow(this);
@@ -609,4 +629,15 @@ void BridgedNativeWidget::UpdateLayerProperties() {
ConvertSizeToPixel(scale_factor, size_in_dip));
}
+NSMutableDictionary* BridgedNativeWidget::GetWindowProperties() const {
+ NSMutableDictionary* properties = objc_getAssociatedObject(
+ window_, &kWindowPropertiesKey);
+ if (!properties) {
+ properties = [NSMutableDictionary dictionary];
+ objc_setAssociatedObject(window_, &kWindowPropertiesKey,
+ properties, OBJC_ASSOCIATION_RETAIN);
+ }
+ return properties;
+}
+
} // namespace views
« no previous file with comments | « ui/views/cocoa/bridged_native_widget.h ('k') | ui/views/controls/menu/menu_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698