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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_native_widget_aura.cc

Issue 2517663002: Fix unable to delete extensions continuously through keyboard (Closed)
Patch Set: based on comment Created 4 years, 1 month 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 | « ui/views/widget/desktop_aura/desktop_native_widget_aura.h ('k') | no next file » | 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) 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/widget/desktop_aura/desktop_native_widget_aura.h" 5 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 wm::CursorManager* DesktopNativeWidgetAura::cursor_manager_ = NULL; 236 wm::CursorManager* DesktopNativeWidgetAura::cursor_manager_ = NULL;
237 237
238 DesktopNativeWidgetAura::DesktopNativeWidgetAura( 238 DesktopNativeWidgetAura::DesktopNativeWidgetAura(
239 internal::NativeWidgetDelegate* delegate) 239 internal::NativeWidgetDelegate* delegate)
240 : desktop_window_tree_host_(NULL), 240 : desktop_window_tree_host_(NULL),
241 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), 241 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET),
242 content_window_container_(NULL), 242 content_window_container_(NULL),
243 content_window_(new aura::Window(this)), 243 content_window_(new aura::Window(this)),
244 native_widget_delegate_(delegate), 244 native_widget_delegate_(delegate),
245 last_drop_operation_(ui::DragDropTypes::DRAG_NONE), 245 last_drop_operation_(ui::DragDropTypes::DRAG_NONE),
246 restore_focus_on_activate_(false),
246 cursor_(gfx::kNullCursor), 247 cursor_(gfx::kNullCursor),
247 widget_type_(Widget::InitParams::TYPE_WINDOW), 248 widget_type_(Widget::InitParams::TYPE_WINDOW),
248 close_widget_factory_(this) { 249 close_widget_factory_(this) {
249 aura::client::SetFocusChangeObserver(content_window_, this); 250 aura::client::SetFocusChangeObserver(content_window_, this);
250 aura::client::SetActivationChangeObserver(content_window_, this); 251 aura::client::SetActivationChangeObserver(content_window_, this);
251 } 252 }
252 253
253 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() { 254 DesktopNativeWidgetAura::~DesktopNativeWidgetAura() {
254 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) 255 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
255 delete native_widget_delegate_; 256 delete native_widget_delegate_;
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 if (GetWidget()->HasFocusManager()) { 355 if (GetWidget()->HasFocusManager()) {
355 // This function can be called before the focus manager has had a 356 // This function can be called before the focus manager has had a
356 // chance to set the focused view. In which case we should get the 357 // chance to set the focused view. In which case we should get the
357 // last focused view. 358 // last focused view.
358 views::FocusManager* focus_manager = GetWidget()->GetFocusManager(); 359 views::FocusManager* focus_manager = GetWidget()->GetFocusManager();
359 View* view_for_activation = focus_manager->GetFocusedView() 360 View* view_for_activation = focus_manager->GetFocusedView()
360 ? focus_manager->GetFocusedView() 361 ? focus_manager->GetFocusedView()
361 : focus_manager->GetStoredFocusView(); 362 : focus_manager->GetStoredFocusView();
362 if (!view_for_activation) 363 if (!view_for_activation)
363 view_for_activation = GetWidget()->GetRootView(); 364 view_for_activation = GetWidget()->GetRootView();
364 else if (view_for_activation == focus_manager->GetStoredFocusView()) 365 else if (view_for_activation == focus_manager->GetStoredFocusView()) {
sky 2016/11/21 22:21:40 When you add parens to one branch of a conditional
365 focus_manager->RestoreFocusedView(); 366 focus_manager->RestoreFocusedView();
367 // Set to false if desktop native widget has activated activation
368 // change, so that aura window activation change focus restore operation
369 // can be ignored.
370 restore_focus_on_activate_ = false;
371 }
366 activation_client->ActivateWindow( 372 activation_client->ActivateWindow(
367 view_for_activation->GetWidget()->GetNativeView()); 373 view_for_activation->GetWidget()->GetNativeView());
368 // Refreshes the focus info to IMF in case that IMF cached the old info 374 // Refreshes the focus info to IMF in case that IMF cached the old info
369 // about focused text input client when it was "inactive". 375 // about focused text input client when it was "inactive".
370 GetInputMethod()->OnFocus(); 376 GetInputMethod()->OnFocus();
371 } 377 }
372 } else { 378 } else {
373 // If we're not active we need to deactivate the corresponding 379 // If we're not active we need to deactivate the corresponding
374 // aura::Window. This way if a child widget is active it gets correctly 380 // aura::Window. This way if a child widget is active it gets correctly
375 // deactivated (child widgets don't get native desktop activation changes, 381 // deactivated (child widgets don't get native desktop activation changes,
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1081 1087
1082 //////////////////////////////////////////////////////////////////////////////// 1088 ////////////////////////////////////////////////////////////////////////////////
1083 // DesktopNativeWidgetAura, aura::client::ActivationChangeObserver 1089 // DesktopNativeWidgetAura, aura::client::ActivationChangeObserver
1084 // implementation: 1090 // implementation:
1085 1091
1086 void DesktopNativeWidgetAura::OnWindowActivated( 1092 void DesktopNativeWidgetAura::OnWindowActivated(
1087 aura::client::ActivationChangeObserver::ActivationReason reason, 1093 aura::client::ActivationChangeObserver::ActivationReason reason,
1088 aura::Window* gained_active, 1094 aura::Window* gained_active,
1089 aura::Window* lost_active) { 1095 aura::Window* lost_active) {
1090 DCHECK(content_window_ == gained_active || content_window_ == lost_active); 1096 DCHECK(content_window_ == gained_active || content_window_ == lost_active);
1091 if (lost_active == content_window_ && GetWidget()->HasFocusManager()) { 1097 if (gained_active == content_window_ && restore_focus_on_activate_) {
1098 restore_focus_on_activate_ = false;
sky 2016/11/21 16:19:08 I'm still confused as to why we need logic here? I
Qiang(Joe) Xu 2016/11/21 19:25:10 HandleActivationChanged is not always called. It i
1099 // For OS_LINUX, desktop native widget may not be activated when child
1100 // widgets gets aura activation changes. Only when desktop native widget is
1101 // active, we can rely on aura activation to restore focused view.
1102 if (GetWidget()->IsActive())
1103 GetWidget()->GetFocusManager()->RestoreFocusedView();
1104 } else if (lost_active == content_window_ && GetWidget()->HasFocusManager()) {
1105 DCHECK(!restore_focus_on_activate_);
1106 restore_focus_on_activate_ = true;
1092 // Pass in false so that ClearNativeFocus() isn't invoked. 1107 // Pass in false so that ClearNativeFocus() isn't invoked.
1093 GetWidget()->GetFocusManager()->StoreFocusedView(false); 1108 GetWidget()->GetFocusManager()->StoreFocusedView(false);
1094 } 1109 }
1095 } 1110 }
1096 1111
1097 //////////////////////////////////////////////////////////////////////////////// 1112 ////////////////////////////////////////////////////////////////////////////////
1098 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation: 1113 // DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation:
1099 1114
1100 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus, 1115 void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus,
1101 aura::Window* lost_focus) { 1116 aura::Window* lost_focus) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 if (cursor_reference_count_ == 0) { 1203 if (cursor_reference_count_ == 0) {
1189 // We are the last DesktopNativeWidgetAura instance, and we are responsible 1204 // We are the last DesktopNativeWidgetAura instance, and we are responsible
1190 // for cleaning up |cursor_manager_|. 1205 // for cleaning up |cursor_manager_|.
1191 delete cursor_manager_; 1206 delete cursor_manager_;
1192 native_cursor_manager_ = NULL; 1207 native_cursor_manager_ = NULL;
1193 cursor_manager_ = NULL; 1208 cursor_manager_ = NULL;
1194 } 1209 }
1195 } 1210 }
1196 1211
1197 } // namespace views 1212 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_aura/desktop_native_widget_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698