Index: views/widget/widget_win.cc |
=================================================================== |
--- views/widget/widget_win.cc (revision 66785) |
+++ views/widget/widget_win.cc (working copy) |
@@ -7,8 +7,8 @@ |
#include "app/keyboard_code_conversion_win.h" |
#include "app/l10n_util_win.h" |
#include "app/system_monitor.h" |
-#include "app/view_prop.h" |
#include "app/win_util.h" |
+#include "app/win/scoped_prop.h" |
#include "base/string_util.h" |
#include "base/win_util.h" |
#include "gfx/canvas_skia.h" |
@@ -26,16 +26,12 @@ |
#include "views/widget/widget_delegate.h" |
#include "views/window/window_win.h" |
-using app::ViewProp; |
- |
namespace views { |
// Property used to link the HWND to its RootView. |
-static const char* const kRootViewWindowProperty = "__ROOT_VIEW__"; |
+static const wchar_t* const kRootViewWindowProperty = L"__ROOT_VIEW__"; |
+static const wchar_t* kWidgetKey = L"__VIEWS_WIDGET__"; |
-// Links the HWND to it's Widget (as a Widget, not a WidgetWin). |
-static const char* const kWidgetKey = "__VIEWS_WIDGET__"; |
- |
bool WidgetWin::screen_reader_active_ = false; |
// A custom MSAA object id used to determine if a screen reader is actively |
@@ -43,8 +39,7 @@ |
#define OBJID_CUSTOM 1 |
RootView* GetRootViewForHWND(HWND hwnd) { |
- return reinterpret_cast<RootView*>( |
- ViewProp::GetValue(hwnd, kRootViewWindowProperty)); |
+ return reinterpret_cast<RootView*>(::GetProp(hwnd, kRootViewWindowProperty)); |
} |
/////////////////////////////////////////////////////////////////////////////// |
@@ -419,21 +414,21 @@ |
return GetWindowImpl(hwnd()); |
} |
-void WidgetWin::SetNativeWindowProperty(const char* name, void* value) { |
+void WidgetWin::SetNativeWindowProperty(const std::wstring& name, void* value) { |
// Remove the existing property (if any). |
- for (ViewProps::iterator i = props_.begin(); i != props_.end(); ++i) { |
- if ((*i)->Key() == name) { |
+ for (ScopedProps::iterator i = props_.begin(); i != props_.end(); ++i) { |
+ if ((*i)->key() == name) { |
props_.erase(i); |
break; |
} |
} |
if (value) |
- props_.push_back(new ViewProp(hwnd(), name, value)); |
+ props_.push_back(new app::win::ScopedProp(hwnd(), name, value)); |
} |
-void* WidgetWin::GetNativeWindowProperty(const char* name) { |
- return ViewProp::GetValue(hwnd(), name); |
+void* WidgetWin::GetNativeWindowProperty(const std::wstring& name) { |
+ return GetProp(hwnd(), name.c_str()); |
} |
ThemeProvider* WidgetWin::GetThemeProvider() const { |
@@ -1303,7 +1298,8 @@ |
} |
static BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM l_param) { |
- RootView* root_view = GetRootViewForHWND(hwnd); |
+ RootView* root_view = |
+ reinterpret_cast<RootView*>(GetProp(hwnd, kRootViewWindowProperty)); |
if (root_view) { |
*reinterpret_cast<RootView**>(l_param) = root_view; |
return FALSE; // Stop enumerating. |
@@ -1313,7 +1309,8 @@ |
// static |
RootView* Widget::FindRootView(HWND hwnd) { |
- RootView* root_view = GetRootViewForHWND(hwnd); |
+ RootView* root_view = |
+ reinterpret_cast<RootView*>(GetProp(hwnd, kRootViewWindowProperty)); |
if (root_view) |
return root_view; |
@@ -1326,7 +1323,8 @@ |
// Enumerate child windows as they could have RootView distinct from |
// the HWND's root view. |
BOOL CALLBACK EnumAllRootViewsChildProc(HWND hwnd, LPARAM l_param) { |
- RootView* root_view = GetRootViewForHWND(hwnd); |
+ RootView* root_view = |
+ reinterpret_cast<RootView*>(GetProp(hwnd, kRootViewWindowProperty)); |
if (root_view) { |
std::set<RootView*>* root_views_set = |
reinterpret_cast<std::set<RootView*>*>(l_param); |
@@ -1337,7 +1335,8 @@ |
void Widget::FindAllRootViews(HWND window, |
std::vector<RootView*>* root_views) { |
- RootView* root_view = GetRootViewForHWND(window); |
+ RootView* root_view = |
+ reinterpret_cast<RootView*>(GetProp(window, kRootViewWindowProperty)); |
std::set<RootView*> root_views_set; |
if (root_view) |
root_views_set.insert(root_view); |
@@ -1357,9 +1356,12 @@ |
// static |
Widget* Widget::GetWidgetFromNativeView(gfx::NativeView native_view) { |
- return IsWindow(native_view) ? |
- reinterpret_cast<Widget*>(ViewProp::GetValue(native_view, kWidgetKey)) : |
- NULL; |
+ if (IsWindow(native_view)) { |
+ HANDLE raw_widget = GetProp(native_view, kWidgetKey); |
+ if (raw_widget) |
+ return reinterpret_cast<Widget*>(raw_widget); |
+ } |
+ return NULL; |
} |
// static |