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

Unified Diff: ui/views/controls/native/native_view_host.cc

Issue 10910034: Attempt 2 at: Fixes crash that occured because NativeViewHostAura::Detach was not (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: da fix Created 8 years, 4 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/controls/native/native_view_host.h ('k') | ui/views/controls/native/native_view_host_aura.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/native/native_view_host.cc
diff --git a/ui/views/controls/native/native_view_host.cc b/ui/views/controls/native/native_view_host.cc
index 3accab5ed8427bcf536fa78ac7f6309cd471f2e4..e75d779e1cfb069ec30bca343b48b171cba3412e 100644
--- a/ui/views/controls/native/native_view_host.cc
+++ b/ui/views/controls/native/native_view_host.cc
@@ -181,9 +181,26 @@ gfx::NativeViewAccessible NativeViewHost::GetNativeViewAccessible() {
void NativeViewHost::Detach(bool destroyed) {
if (native_view_) {
+ if (!destroyed)
+ ClearFocus();
native_wrapper_->NativeViewDetaching(destroyed);
native_view_ = NULL;
}
}
+void NativeViewHost::ClearFocus() {
+ FocusManager* focus_manager = GetFocusManager();
+ if (!focus_manager || !focus_manager->GetFocusedView())
+ return;
+
+ Widget::Widgets widgets;
+ Widget::GetAllChildWidgets(native_view(), &widgets);
+ for (Widget::Widgets::iterator i = widgets.begin(); i != widgets.end(); ++i) {
+ focus_manager->ViewRemoved((*i)->GetRootView());
+ if (!focus_manager->GetFocusedView())
+ return;
+ }
+}
+
+
} // namespace views
« no previous file with comments | « ui/views/controls/native/native_view_host.h ('k') | ui/views/controls/native/native_view_host_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698