| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/controls/native/native_view_host.h" | 5 #include "ui/views/controls/native/native_view_host.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ui/gfx/canvas.h" | 8 #include "ui/gfx/canvas.h" |
| 9 #include "ui/views/controls/native/native_view_host_wrapper.h" | 9 #include "ui/views/controls/native/native_view_host_wrapper.h" |
| 10 #include "ui/views/widget/widget.h" | 10 #include "ui/views/widget/widget.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 174 } |
| 175 | 175 |
| 176 return View::GetNativeViewAccessible(); | 176 return View::GetNativeViewAccessible(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 //////////////////////////////////////////////////////////////////////////////// | 179 //////////////////////////////////////////////////////////////////////////////// |
| 180 // NativeViewHost, private: | 180 // NativeViewHost, private: |
| 181 | 181 |
| 182 void NativeViewHost::Detach(bool destroyed) { | 182 void NativeViewHost::Detach(bool destroyed) { |
| 183 if (native_view_) { | 183 if (native_view_) { |
| 184 if (!destroyed) |
| 185 ClearFocus(); |
| 184 native_wrapper_->NativeViewDetaching(destroyed); | 186 native_wrapper_->NativeViewDetaching(destroyed); |
| 185 native_view_ = NULL; | 187 native_view_ = NULL; |
| 186 } | 188 } |
| 187 } | 189 } |
| 188 | 190 |
| 191 void NativeViewHost::ClearFocus() { |
| 192 FocusManager* focus_manager = GetFocusManager(); |
| 193 if (!focus_manager || !focus_manager->GetFocusedView()) |
| 194 return; |
| 195 |
| 196 Widget::Widgets widgets; |
| 197 Widget::GetAllChildWidgets(native_view(), &widgets); |
| 198 for (Widget::Widgets::iterator i = widgets.begin(); i != widgets.end(); ++i) { |
| 199 focus_manager->ViewRemoved((*i)->GetRootView()); |
| 200 if (!focus_manager->GetFocusedView()) |
| 201 return; |
| 202 } |
| 203 } |
| 204 |
| 205 |
| 189 } // namespace views | 206 } // namespace views |
| OLD | NEW |