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

Side by Side Diff: ui/keyboard/content/keyboard_ui_content.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 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/keyboard/content/keyboard_ui_content.h ('k') | ui/keyboard/keyboard_controller.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/keyboard/content/keyboard_ui_content.h" 5 #include "ui/keyboard/content/keyboard_ui_content.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "content/public/browser/render_widget_host.h" 10 #include "content/public/browser/render_widget_host.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 LoadContents(default_url_); 159 LoadContents(default_url_);
160 } 160 }
161 } 161 }
162 162
163 void KeyboardUIContent::UpdateInsetsForWindow(aura::Window* window) { 163 void KeyboardUIContent::UpdateInsetsForWindow(aura::Window* window) {
164 aura::Window* keyboard_container = 164 aura::Window* keyboard_container =
165 keyboard_controller()->GetContainerWindow(); 165 keyboard_controller()->GetContainerWindow();
166 if (!ShouldWindowOverscroll(window)) 166 if (!ShouldWindowOverscroll(window))
167 return; 167 return;
168 168
169 scoped_ptr<content::RenderWidgetHostIterator> widgets( 169 std::unique_ptr<content::RenderWidgetHostIterator> widgets(
170 content::RenderWidgetHost::GetRenderWidgetHosts()); 170 content::RenderWidgetHost::GetRenderWidgetHosts());
171 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { 171 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
172 content::RenderWidgetHostView* view = widget->GetView(); 172 content::RenderWidgetHostView* view = widget->GetView();
173 if (view && window->Contains(view->GetNativeView())) { 173 if (view && window->Contains(view->GetNativeView())) {
174 gfx::Rect window_bounds = view->GetNativeView()->GetBoundsInScreen(); 174 gfx::Rect window_bounds = view->GetNativeView()->GetBoundsInScreen();
175 gfx::Rect intersect = 175 gfx::Rect intersect =
176 gfx::IntersectRects(window_bounds, keyboard_container->bounds()); 176 gfx::IntersectRects(window_bounds, keyboard_container->bounds());
177 int overlap = ShouldEnableInsets(window) ? intersect.height() : 0; 177 int overlap = ShouldEnableInsets(window) ? intersect.height() : 0;
178 if (overlap > 0 && overlap < window_bounds.height()) 178 if (overlap > 0 && overlap < window_bounds.height())
179 view->SetInsets(gfx::Insets(0, 0, overlap, 0)); 179 view->SetInsets(gfx::Insets(0, 0, overlap, 0));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 223 }
224 LoadContents(GetVirtualKeyboardUrl()); 224 LoadContents(GetVirtualKeyboardUrl());
225 } 225 }
226 } 226 }
227 227
228 void KeyboardUIContent::InitInsets(const gfx::Rect& new_bounds) { 228 void KeyboardUIContent::InitInsets(const gfx::Rect& new_bounds) {
229 // Adjust the height of the viewport for visible windows on the primary 229 // Adjust the height of the viewport for visible windows on the primary
230 // display. 230 // display.
231 // TODO(kevers): Add EnvObserver to properly initialize insets if a 231 // TODO(kevers): Add EnvObserver to properly initialize insets if a
232 // window is created while the keyboard is visible. 232 // window is created while the keyboard is visible.
233 scoped_ptr<content::RenderWidgetHostIterator> widgets( 233 std::unique_ptr<content::RenderWidgetHostIterator> widgets(
234 content::RenderWidgetHost::GetRenderWidgetHosts()); 234 content::RenderWidgetHost::GetRenderWidgetHosts());
235 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { 235 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
236 content::RenderWidgetHostView* view = widget->GetView(); 236 content::RenderWidgetHostView* view = widget->GetView();
237 // Can be NULL, e.g. if the RenderWidget is being destroyed or 237 // Can be NULL, e.g. if the RenderWidget is being destroyed or
238 // the render process crashed. 238 // the render process crashed.
239 if (view) { 239 if (view) {
240 aura::Window* window = view->GetNativeView(); 240 aura::Window* window = view->GetNativeView();
241 if (ShouldWindowOverscroll(window)) { 241 if (ShouldWindowOverscroll(window)) {
242 gfx::Rect window_bounds = window->GetBoundsInScreen(); 242 gfx::Rect window_bounds = window->GetBoundsInScreen();
243 gfx::Rect intersect = gfx::IntersectRects(window_bounds, 243 gfx::Rect intersect = gfx::IntersectRects(window_bounds,
244 new_bounds); 244 new_bounds);
245 int overlap = intersect.height(); 245 int overlap = intersect.height();
246 if (overlap > 0 && overlap < window_bounds.height()) 246 if (overlap > 0 && overlap < window_bounds.height())
247 view->SetInsets(gfx::Insets(0, 0, overlap, 0)); 247 view->SetInsets(gfx::Insets(0, 0, overlap, 0));
248 else 248 else
249 view->SetInsets(gfx::Insets()); 249 view->SetInsets(gfx::Insets());
250 AddBoundsChangedObserver(window); 250 AddBoundsChangedObserver(window);
251 } 251 }
252 } 252 }
253 } 253 }
254 } 254 }
255 255
256 void KeyboardUIContent::ResetInsets() { 256 void KeyboardUIContent::ResetInsets() {
257 const gfx::Insets insets; 257 const gfx::Insets insets;
258 scoped_ptr<content::RenderWidgetHostIterator> widgets( 258 std::unique_ptr<content::RenderWidgetHostIterator> widgets(
259 content::RenderWidgetHost::GetRenderWidgetHosts()); 259 content::RenderWidgetHost::GetRenderWidgetHosts());
260 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { 260 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) {
261 content::RenderWidgetHostView* view = widget->GetView(); 261 content::RenderWidgetHostView* view = widget->GetView();
262 if (view) 262 if (view)
263 view->SetInsets(insets); 263 view->SetInsets(insets);
264 } 264 }
265 window_bounds_observer_->RemoveAllObservedWindows(); 265 window_bounds_observer_->RemoveAllObservedWindows();
266 } 266 }
267 267
268 void KeyboardUIContent::SetupWebContents(content::WebContents* contents) { 268 void KeyboardUIContent::SetupWebContents(content::WebContents* contents) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 keyboard_controller()->keyboard_visible()); 323 keyboard_controller()->keyboard_visible());
324 } 324 }
325 325
326 void KeyboardUIContent::AddBoundsChangedObserver(aura::Window* window) { 326 void KeyboardUIContent::AddBoundsChangedObserver(aura::Window* window) {
327 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr; 327 aura::Window* target_window = window ? window->GetToplevelWindow() : nullptr;
328 if (target_window) 328 if (target_window)
329 window_bounds_observer_->AddObservedWindow(target_window); 329 window_bounds_observer_->AddObservedWindow(target_window);
330 } 330 }
331 331
332 } // namespace keyboard 332 } // namespace keyboard
OLDNEW
« no previous file with comments | « ui/keyboard/content/keyboard_ui_content.h ('k') | ui/keyboard/keyboard_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698