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

Side by Side Diff: ui/views/controls/native/native_view_host.cc

Issue 1746013002: Hide/show widget on Windows screen lock/unlock Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits. Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « ui/views/controls/native/native_view_host.h ('k') | ui/views/view.h » ('j') | 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/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/base/cursor/cursor.h" 8 #include "ui/base/cursor/cursor.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/views/accessibility/native_view_accessibility.h" 10 #include "ui/views/accessibility/native_view_accessibility.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // It would be nice if this used some approximation of the page's 120 // It would be nice if this used some approximation of the page's
121 // current background color. 121 // current background color.
122 if (native_wrapper_->HasInstalledClip()) 122 if (native_wrapper_->HasInstalledClip())
123 canvas->FillRect(GetLocalBounds(), resize_background_color_); 123 canvas->FillRect(GetLocalBounds(), resize_background_color_);
124 } 124 }
125 125
126 void NativeViewHost::VisibilityChanged(View* starting_from, bool is_visible) { 126 void NativeViewHost::VisibilityChanged(View* starting_from, bool is_visible) {
127 Layout(); 127 Layout();
128 } 128 }
129 129
130 void NativeViewHost::OnSoftVisibilityChanged(bool visible) {
131 if (!native_view_ || !native_wrapper_.get())
132 return;
133
134 if (GetVisibleBounds().IsEmpty())
135 return;
136
137 // If the widget wasn't .e.g. minimized, hide and show would trigger
138 // PageVisibility API, enabling JS to save power while screen is locked.
139 if (visible) {
140 Layout();
141 } else {
142 native_wrapper_->HideWidget();
143 }
144 }
145
130 bool NativeViewHost::GetNeedsNotificationWhenVisibleBoundsChange() const { 146 bool NativeViewHost::GetNeedsNotificationWhenVisibleBoundsChange() const {
131 // The native widget is placed relative to the root. As such, we need to 147 // The native widget is placed relative to the root. As such, we need to
132 // know when the position of any ancestor changes, or our visibility relative 148 // know when the position of any ancestor changes, or our visibility relative
133 // to other views changed as it'll effect our position relative to the root. 149 // to other views changed as it'll effect our position relative to the root.
134 return true; 150 return true;
135 } 151 }
136 152
137 void NativeViewHost::OnVisibleBoundsChanged() { 153 void NativeViewHost::OnVisibleBoundsChanged() {
138 Layout(); 154 Layout();
139 } 155 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 Widget::Widgets widgets; 226 Widget::Widgets widgets;
211 Widget::GetAllChildWidgets(native_view(), &widgets); 227 Widget::GetAllChildWidgets(native_view(), &widgets);
212 for (Widget::Widgets::iterator i = widgets.begin(); i != widgets.end(); ++i) { 228 for (Widget::Widgets::iterator i = widgets.begin(); i != widgets.end(); ++i) {
213 focus_manager->ViewRemoved((*i)->GetRootView()); 229 focus_manager->ViewRemoved((*i)->GetRootView());
214 if (!focus_manager->GetFocusedView()) 230 if (!focus_manager->GetFocusedView())
215 return; 231 return;
216 } 232 }
217 } 233 }
218 234
219 } // namespace views 235 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/native/native_view_host.h ('k') | ui/views/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698