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

Side by Side Diff: base/gfx/native_widget_types.h

Issue 18768: POSIX: gfx::NativeViewId and CrossProcessEvent (Closed)
Patch Set: Addressing Brett's comments Created 11 years, 10 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/download/download_file.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_GFX_NATIVE_WIDGET_TYPES_H_ 5 #ifndef BASE_GFX_NATIVE_WIDGET_TYPES_H_
6 #define BASE_GFX_NATIVE_WIDGET_TYPES_H_ 6 #define BASE_GFX_NATIVE_WIDGET_TYPES_H_
7 7
8 #include "base/basictypes.h"
8 #include "build/build_config.h" 9 #include "build/build_config.h"
9 10
10 // This file provides cross platform typedefs for native widget types. 11 // This file provides cross platform typedefs for native widget types.
11 // NativeWindow: this is a handle to a native, top-level window 12 // NativeWindow: this is a handle to a native, top-level window
12 // NativeView: this is a handle to a native UI element. It may be the 13 // NativeView: this is a handle to a native UI element. It may be the
13 // same type as a NativeWindow on some platforms. 14 // same type as a NativeWindow on some platforms.
14 // NativeEditView: a handle to a native edit-box. The Mac folks wanted 15 // NativeViewId: Often, in our cross process model, we need to pass around a
15 // this specific typedef. 16 // reference to a "window". This reference will, say, be echoed back from a
17 // renderer to the browser when it wishes to query it's size. On Windows, a
18 // HWND can be used for this. On other platforms, we may wish to pass
19 // around X window ids, or maybe abstract identifiers.
20 //
21 // As a rule of thumb - if you're in the renderer, you should be dealing
22 // with NativeViewIds. This should remind you that you shouldn't be doing
23 // direct operations on platform widgets from the renderer process.
24 //
25 // If you're in the browser, you're probably dealing with NativeViews,
26 // unless you're in the IPC layer, which will be translating between
27 // NativeViewIds from the renderer and NativeViews.
28 //
29 // NativeEditView: a handle to a native edit-box. The Mac folks wanted this
30 // specific typedef.
16 // 31 //
17 // The name 'View' here meshes with OS X where the UI elements are called 32 // The name 'View' here meshes with OS X where the UI elements are called
18 // 'views' and with our Chrome UI code where the elements are also called 33 // 'views' and with our Chrome UI code where the elements are also called
19 // 'views'. 34 // 'views'.
20 35
21 #if defined(OS_WIN) 36 #if defined(OS_WIN)
22 #include <windows.h> 37 #include <windows.h>
23 #elif defined(OS_MACOSX) 38 #elif defined(OS_MACOSX)
24 #ifdef __OBJC__ 39 #ifdef __OBJC__
25 @class NSView; 40 @class NSView;
(...skipping 19 matching lines...) Expand all
45 typedef NSWindow* NativeWindow; 60 typedef NSWindow* NativeWindow;
46 typedef NSTextField* NativeEditView; 61 typedef NSTextField* NativeEditView;
47 #elif defined(OS_LINUX) 62 #elif defined(OS_LINUX)
48 typedef GtkWidget* NativeView; 63 typedef GtkWidget* NativeView;
49 typedef GtkWidget* NativeWindow; 64 typedef GtkWidget* NativeWindow;
50 typedef GtkWidget* NativeEditView; 65 typedef GtkWidget* NativeEditView;
51 #else // null port. 66 #else // null port.
52 #error No known OS defined 67 #error No known OS defined
53 #endif 68 #endif
54 69
70 // Note: for test_shell we're packing a pointer into the NativeViewId. So, if
71 // you make it a type which is smaller than a pointer, you have to fix
72 // test_shell.
73 //
74 // See comment at the top of the file for usage.
75 typedef intptr_t NativeViewId;
76
77 // Convert a NativeViewId to a NativeView. At the moment, we assume that the
78 // ids are the same as the NativeViews. This is correct on Windows (where
79 // NativeView == HWND).
80 // TODO(port): figure out what ids are going to be and implement this function
81 // This is only to be called in the browser process.
82 static inline NativeView NativeViewFromId(NativeViewId id) {
83 return reinterpret_cast<NativeView>(id);
84 }
85
86 // Convert a NativeView to a NativeViewId. At the moment, we assume that the
87 // ids are the same as the NativeViews. This is correct on Windows (where
88 // NativeView == HWND).
89 // TODO(port): figure out what ids are going to be and implement this function
90 // This is only to be called in the browser process.
91 static inline NativeViewId IdFromNativeView(NativeView view) {
92 return reinterpret_cast<NativeViewId>(view);
93 }
94
55 } // namespace gfx 95 } // namespace gfx
56 96
57 #endif // BASE_GFX_NATIVE_WIDGET_TYPES_H_ 97 #endif // BASE_GFX_NATIVE_WIDGET_TYPES_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/download_file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698