OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "views/widget/native_widget_aura.h" | 5 #include "views/widget/native_widget_aura.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "ui/aura/desktop.h" | 8 #include "ui/aura/desktop.h" |
9 #include "ui/aura/event.h" | 9 #include "ui/aura/event.h" |
10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
11 #include "ui/aura/window_types.h" | 11 #include "ui/aura/window_types.h" |
| 12 #include "ui/base/view_prop.h" |
12 #include "ui/base/ui_base_types.h" | 13 #include "ui/base/ui_base_types.h" |
13 #include "ui/gfx/canvas.h" | 14 #include "ui/gfx/canvas.h" |
14 #include "ui/gfx/compositor/layer.h" | 15 #include "ui/gfx/compositor/layer.h" |
15 #include "ui/gfx/font.h" | 16 #include "ui/gfx/font.h" |
16 #include "ui/gfx/screen.h" | 17 #include "ui/gfx/screen.h" |
17 #include "views/widget/native_widget_delegate.h" | 18 #include "views/widget/native_widget_delegate.h" |
18 | 19 |
19 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
20 #include "base/win/scoped_gdi_object.h" | 21 #include "base/win/scoped_gdi_object.h" |
21 #include "base/win/win_util.h" | 22 #include "base/win/win_util.h" |
22 #include "ui/base/l10n/l10n_util_win.h" | 23 #include "ui/base/l10n/l10n_util_win.h" |
23 #endif | 24 #endif |
24 | 25 |
25 #if defined(HAVE_IBUS) | 26 #if defined(HAVE_IBUS) |
26 #include "views/ime/input_method_ibus.h" | 27 #include "views/ime/input_method_ibus.h" |
27 #else | 28 #else |
28 #include "views/ime/mock_input_method.h" | 29 #include "views/ime/mock_input_method.h" |
29 #endif | 30 #endif |
30 | 31 |
| 32 using ui::ViewProp; |
| 33 |
31 namespace views { | 34 namespace views { |
32 | 35 |
33 namespace { | 36 namespace { |
34 | 37 |
35 int GetAuraWindowTypeFromInitParams(const Widget::InitParams& params) { | 38 int GetAuraWindowTypeFromInitParams(const Widget::InitParams& params) { |
36 if (params.child) | 39 if (params.child) |
37 return aura::kWindowType_Control; | 40 return aura::kWindowType_Control; |
38 switch (params.type) { | 41 switch (params.type) { |
39 case Widget::InitParams::TYPE_WINDOW: | 42 case Widget::InitParams::TYPE_WINDOW: |
40 case Widget::InitParams::TYPE_WINDOW_FRAMELESS: | 43 case Widget::InitParams::TYPE_WINDOW_FRAMELESS: |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 169 } |
167 | 170 |
168 void NativeWidgetAura::ReorderLayers() { | 171 void NativeWidgetAura::ReorderLayers() { |
169 } | 172 } |
170 | 173 |
171 void NativeWidgetAura::ViewRemoved(View* view) { | 174 void NativeWidgetAura::ViewRemoved(View* view) { |
172 // NOTIMPLEMENTED(); | 175 // NOTIMPLEMENTED(); |
173 } | 176 } |
174 | 177 |
175 void NativeWidgetAura::SetNativeWindowProperty(const char* name, void* value) { | 178 void NativeWidgetAura::SetNativeWindowProperty(const char* name, void* value) { |
176 if (!value) | 179 // TODO(sky): push this to Widget when we get rid of NativeWidgetGtk. |
177 props_map_.erase(name); | 180 if (!window_) |
178 else | 181 return; |
179 props_map_[name] = value; | 182 |
| 183 // Remove the existing property (if any). |
| 184 for (ViewProps::iterator i = props_.begin(); i != props_.end(); ++i) { |
| 185 if ((*i)->Key() == name) { |
| 186 props_.erase(i); |
| 187 break; |
| 188 } |
| 189 } |
| 190 |
| 191 if (value) |
| 192 props_.push_back(new ViewProp(window_, name, value)); |
180 } | 193 } |
181 | 194 |
182 void* NativeWidgetAura::GetNativeWindowProperty(const char* name) const { | 195 void* NativeWidgetAura::GetNativeWindowProperty(const char* name) const { |
183 PropsMap::const_iterator i = props_map_.find(name); | 196 return window_ ? ViewProp::GetValue(window_, name) : NULL; |
184 return i == props_map_.end() ? NULL : i->second; | |
185 } | 197 } |
186 | 198 |
187 TooltipManager* NativeWidgetAura::GetTooltipManager() const { | 199 TooltipManager* NativeWidgetAura::GetTooltipManager() const { |
188 //NOTIMPLEMENTED(); | 200 //NOTIMPLEMENTED(); |
189 return NULL; | 201 return NULL; |
190 } | 202 } |
191 | 203 |
192 bool NativeWidgetAura::IsScreenReaderActive() const { | 204 bool NativeWidgetAura::IsScreenReaderActive() const { |
193 NOTIMPLEMENTED(); | 205 NOTIMPLEMENTED(); |
194 return false; | 206 return false; |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 | 543 |
532 void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) { | 544 void NativeWidgetAura::OnPaint(gfx::Canvas* canvas) { |
533 delegate_->OnNativeWidgetPaint(canvas); | 545 delegate_->OnNativeWidgetPaint(canvas); |
534 } | 546 } |
535 | 547 |
536 void NativeWidgetAura::OnWindowDestroying() { | 548 void NativeWidgetAura::OnWindowDestroying() { |
537 delegate_->OnNativeWidgetDestroying(); | 549 delegate_->OnNativeWidgetDestroying(); |
538 } | 550 } |
539 | 551 |
540 void NativeWidgetAura::OnWindowDestroyed() { | 552 void NativeWidgetAura::OnWindowDestroyed() { |
| 553 props_.reset(); |
541 window_ = NULL; | 554 window_ = NULL; |
542 delegate_->OnNativeWidgetDestroyed(); | 555 delegate_->OnNativeWidgetDestroyed(); |
543 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) | 556 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) |
544 delete this; | 557 delete this; |
545 } | 558 } |
546 | 559 |
547 void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) { | 560 void NativeWidgetAura::OnWindowVisibilityChanged(bool visible) { |
548 delegate_->OnNativeWidgetVisibilityChanged(visible); | 561 delegate_->OnNativeWidgetVisibilityChanged(visible); |
549 } | 562 } |
550 | 563 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 } | 647 } |
635 | 648 |
636 // static | 649 // static |
637 bool NativeWidgetPrivate::IsMouseButtonDown() { | 650 bool NativeWidgetPrivate::IsMouseButtonDown() { |
638 NOTIMPLEMENTED(); | 651 NOTIMPLEMENTED(); |
639 return false; | 652 return false; |
640 } | 653 } |
641 | 654 |
642 } // namespace internal | 655 } // namespace internal |
643 } // namespace views | 656 } // namespace views |
OLD | NEW |