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

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

Issue 224023: Don't send tab switching/killing/creating keyboard accelerators to pages. Th... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: call Browser:IsReservedAccelerator from tab_contents_view.cc instead of each platform file Created 11 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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.h" 5 #include "chrome/browser/renderer_host/render_widget_host.h"
6 6
7 #include "base/histogram.h" 7 #include "base/histogram.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/keyboard_codes.h" 9 #include "base/keyboard_codes.h"
10 #include "chrome/browser/renderer_host/backing_store.h" 10 #include "chrome/browser/renderer_host/backing_store.h"
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 OnUserGesture(); 393 OnUserGesture();
394 } 394 }
395 395
396 // Double check the type to make sure caller hasn't sent us nonsense that 396 // Double check the type to make sure caller hasn't sent us nonsense that
397 // will mess up our key queue. 397 // will mess up our key queue.
398 if (WebInputEvent::isKeyboardEventType(key_event.type)) { 398 if (WebInputEvent::isKeyboardEventType(key_event.type)) {
399 // Don't add this key to the queue if we have no way to send the message... 399 // Don't add this key to the queue if we have no way to send the message...
400 if (!process_->HasConnection()) 400 if (!process_->HasConnection())
401 return; 401 return;
402 402
403 // Tab switching/closing accelerators aren't sent to the renderer to avoid a
404 // hung/malicious renderer from interfering.
405 if (!ShouldSendToRenderer(key_event)) {
406 UnhandledKeyboardEvent(key_event);
407 return;
408 }
409
403 // Put all WebKeyboardEvent objects in a queue since we can't trust the 410 // Put all WebKeyboardEvent objects in a queue since we can't trust the
404 // renderer and we need to give something to the UnhandledInputEvent 411 // renderer and we need to give something to the UnhandledInputEvent
405 // handler. 412 // handler.
406 key_queue_.push(key_event); 413 key_queue_.push(key_event);
407 HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size()); 414 HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size());
408 } 415 }
409 416
410 // Only forward the non-native portions of our event. 417 // Only forward the non-native portions of our event.
411 ForwardInputEvent(key_event, sizeof(WebKeyboardEvent)); 418 ForwardInputEvent(key_event, sizeof(WebKeyboardEvent));
412 } 419 }
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 << "don't seem to have sent it to the renderer!"; 754 << "don't seem to have sent it to the renderer!";
748 } else if (key_queue_.front().type != type) { 755 } else if (key_queue_.front().type != type) {
749 LOG(ERROR) << "We seem to have a different key type sent from " 756 LOG(ERROR) << "We seem to have a different key type sent from "
750 << "the renderer. (" << key_queue_.front().type << " vs. " 757 << "the renderer. (" << key_queue_.front().type << " vs. "
751 << type << "). Ignoring event."; 758 << type << "). Ignoring event.";
752 } else { 759 } else {
753 bool processed = false; 760 bool processed = false;
754 if (!message.ReadBool(&iter, &processed)) 761 if (!message.ReadBool(&iter, &processed))
755 process()->ReceivedBadMessage(message.type()); 762 process()->ReceivedBadMessage(message.type());
756 763
757 KeyQueue::value_type front_item = key_queue_.front(); 764 NativeWebKeyboardEvent front_item = key_queue_.front();
758 key_queue_.pop(); 765 key_queue_.pop();
759 766
760 if (!processed) { 767 if (!processed) {
761 UnhandledKeyboardEvent(front_item); 768 UnhandledKeyboardEvent(front_item);
762 769
763 // WARNING: This RenderWidgetHost can be deallocated at this point 770 // WARNING: This RenderWidgetHost can be deallocated at this point
764 // (i.e. in the case of Ctrl+W, where the call to 771 // (i.e. in the case of Ctrl+W, where the call to
765 // UnhandledKeyboardEvent destroys this RenderWidgetHost). 772 // UnhandledKeyboardEvent destroys this RenderWidgetHost).
766 } 773 }
767 } 774 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 Send(new ViewMsg_ToggleSpellPanel(routing_id(), is_currently_visible)); 899 Send(new ViewMsg_ToggleSpellPanel(routing_id(), is_currently_visible));
893 } 900 }
894 901
895 void RenderWidgetHost::ReplaceWord(const std::wstring& word) { 902 void RenderWidgetHost::ReplaceWord(const std::wstring& word) {
896 Send(new ViewMsg_Replace(routing_id_, word)); 903 Send(new ViewMsg_Replace(routing_id_, word));
897 } 904 }
898 905
899 void RenderWidgetHost::AdvanceToNextMisspelling() { 906 void RenderWidgetHost::AdvanceToNextMisspelling() {
900 Send(new ViewMsg_AdvanceToNextMisspelling(routing_id_)); 907 Send(new ViewMsg_AdvanceToNextMisspelling(routing_id_));
901 } 908 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698