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

Side by Side Diff: chrome/browser/renderer_host/render_widget_host_view_views.cc

Issue 8568030: base::Bind() conversion in renderer_host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add missing #include for Mac Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/renderer_host/render_widget_host_view_views.h" 5 #include "chrome/browser/renderer_host/render_widget_host_view_views.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h"
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "base/message_loop.h" 13 #include "base/message_loop.h"
13 #include "base/metrics/histogram.h" 14 #include "base/metrics/histogram.h"
14 #include "base/string_number_conversions.h" 15 #include "base/string_number_conversions.h"
15 #include "base/task.h"
16 #include "base/time.h" 16 #include "base/time.h"
17 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
18 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
19 #include "chrome/common/native_web_keyboard_event_views.h" 19 #include "chrome/common/native_web_keyboard_event_views.h"
20 #include "chrome/common/render_messages.h" 20 #include "chrome/common/render_messages.h"
21 #include "content/browser/renderer_host/backing_store_skia.h" 21 #include "content/browser/renderer_host/backing_store_skia.h"
22 #include "content/browser/renderer_host/render_widget_host.h" 22 #include "content/browser/renderer_host/render_widget_host.h"
23 #include "content/common/view_messages.h" 23 #include "content/common/view_messages.h"
24 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
25 #include "content/public/common/result_codes.h" 25 #include "content/public/common/result_codes.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 is_hidden_(false), 115 is_hidden_(false),
116 is_loading_(false), 116 is_loading_(false),
117 native_cursor_(gfx::kNullCursor), 117 native_cursor_(gfx::kNullCursor),
118 is_showing_context_menu_(false), 118 is_showing_context_menu_(false),
119 visually_deemphasized_(false), 119 visually_deemphasized_(false),
120 touch_event_(), 120 touch_event_(),
121 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 121 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
122 has_composition_text_(false), 122 has_composition_text_(false),
123 ALLOW_THIS_IN_INITIALIZER_LIST(touch_selection_controller_( 123 ALLOW_THIS_IN_INITIALIZER_LIST(touch_selection_controller_(
124 views::TouchSelectionController::create(this))), 124 views::TouchSelectionController::create(this))),
125 ALLOW_THIS_IN_INITIALIZER_LIST(update_touch_selection_(this)) { 125 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
126 set_focusable(true); 126 set_focusable(true);
127 host_->SetView(this); 127 host_->SetView(this);
128 128
129 #if defined(TOUCH_UI) 129 #if defined(TOUCH_UI)
130 SetPaintToLayer(true); 130 SetPaintToLayer(true);
131 registrar_.Add(this, 131 registrar_.Add(this,
132 chrome::NOTIFICATION_KEYBOARD_VISIBLE_BOUNDS_CHANGED, 132 chrome::NOTIFICATION_KEYBOARD_VISIBLE_BOUNDS_CHANGED,
133 content::NotificationService::AllSources()); 133 content::NotificationService::AllSources());
134 #endif 134 #endif
135 } 135 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 // If we receive any more paint messages while we are hidden, we want to 193 // If we receive any more paint messages while we are hidden, we want to
194 // ignore them so we don't re-allocate the backing store. We will paint 194 // ignore them so we don't re-allocate the backing store. We will paint
195 // everything again when we become selected again. 195 // everything again when we become selected again.
196 is_hidden_ = true; 196 is_hidden_ = true;
197 197
198 // If we have a renderer, then inform it that we are being hidden so it can 198 // If we have a renderer, then inform it that we are being hidden so it can
199 // reduce its resource utilization. 199 // reduce its resource utilization.
200 if (host_) 200 if (host_)
201 host_->WasHidden(); 201 host_->WasHidden();
202 202
203 if (!update_touch_selection_.empty()) 203 weak_factory_.InvalidateWeakPtrs();
204 update_touch_selection_.RevokeAll();
205 } 204 }
206 205
207 void RenderWidgetHostViewViews::SetSize(const gfx::Size& size) { 206 void RenderWidgetHostViewViews::SetSize(const gfx::Size& size) {
208 // This is called when webkit has sent us a Move message. 207 // This is called when webkit has sent us a Move message.
209 int width = std::min(size.width(), kMaxWindowWidth); 208 int width = std::min(size.width(), kMaxWindowWidth);
210 int height = std::min(size.height(), kMaxWindowHeight); 209 int height = std::min(size.height(), kMaxWindowHeight);
211 if (requested_size_.width() != width || 210 if (requested_size_.width() != width ||
212 requested_size_.height() != height) { 211 requested_size_.height() != height) {
213 requested_size_ = gfx::Size(width, height); 212 requested_size_ = gfx::Size(width, height);
214 views::View::SetBounds(x(), y(), width, height); 213 views::View::SetBounds(x(), y(), width, height);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 input_method->OnCaretBoundsChanged(this); 403 input_method->OnCaretBoundsChanged(this);
405 404
406 // TODO(sad): This is a workaround for a webkit bug: 405 // TODO(sad): This is a workaround for a webkit bug:
407 // https://bugs.webkit.org/show_bug.cgi?id=67464 406 // https://bugs.webkit.org/show_bug.cgi?id=67464
408 // Remove this when the bug gets fixed. 407 // Remove this when the bug gets fixed.
409 // 408 //
410 // Webkit can send spurious selection-change on text-input (e.g. when 409 // Webkit can send spurious selection-change on text-input (e.g. when
411 // inserting text at the beginning of a non-empty text control). But in those 410 // inserting text at the beginning of a non-empty text control). But in those
412 // cases, it does send the correct selection information quickly afterwards. 411 // cases, it does send the correct selection information quickly afterwards.
413 // So delay the notification to the touch-selection controller. 412 // So delay the notification to the touch-selection controller.
414 if (update_touch_selection_.empty()) { 413 if (!weak_factory_.HasWeakPtrs()) {
415 MessageLoop::current()->PostDelayedTask(FROM_HERE, 414 MessageLoop::current()->PostDelayedTask(FROM_HERE,
416 update_touch_selection_.NewRunnableMethod( 415 base::Bind(
417 &RenderWidgetHostViewViews::UpdateTouchSelectionController), 416 &RenderWidgetHostViewViews::UpdateTouchSelectionController,
417 weak_factory_.GetWeakPtr()),
418 kTouchControllerUpdateDelay); 418 kTouchControllerUpdateDelay);
419 } 419 }
420 } 420 }
421 421
422 void RenderWidgetHostViewViews::Observe( 422 void RenderWidgetHostViewViews::Observe(
423 int type, 423 int type,
424 const content::NotificationSource& source, 424 const content::NotificationSource& source,
425 const content::NotificationDetails& details) { 425 const content::NotificationDetails& details) {
426 #if defined(TOUCH_UI) 426 #if defined(TOUCH_UI)
427 if (type != chrome::NOTIFICATION_KEYBOARD_VISIBLE_BOUNDS_CHANGED) { 427 if (type != chrome::NOTIFICATION_KEYBOARD_VISIBLE_BOUNDS_CHANGED) {
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 for (std::vector< base::Callback<void(void)> >::const_iterator 1166 for (std::vector< base::Callback<void(void)> >::const_iterator
1167 it = on_compositing_ended_callbacks_.begin(); 1167 it = on_compositing_ended_callbacks_.begin();
1168 it != on_compositing_ended_callbacks_.end(); ++it) { 1168 it != on_compositing_ended_callbacks_.end(); ++it) {
1169 it->Run(); 1169 it->Run();
1170 } 1170 }
1171 on_compositing_ended_callbacks_.clear(); 1171 on_compositing_ended_callbacks_.clear();
1172 compositor->RemoveObserver(this); 1172 compositor->RemoveObserver(this);
1173 } 1173 }
1174 1174
1175 #endif 1175 #endif
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_views.h ('k') | chrome/browser/renderer_host/web_cache_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698