| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_mac.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #import "base/chrome_application_mac.h" |
| 7 #include "base/histogram.h" | 8 #include "base/histogram.h" |
| 8 #import "base/scoped_nsobject.h" | 9 #import "base/scoped_nsobject.h" |
| 9 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 10 #include "base/sys_string_conversions.h" | 11 #include "base/sys_string_conversions.h" |
| 11 #include "chrome/browser/browser_trial.h" | 12 #include "chrome/browser/browser_trial.h" |
| 12 #import "chrome/browser/cocoa/rwhvm_editcommand_helper.h" | 13 #import "chrome/browser/cocoa/rwhvm_editcommand_helper.h" |
| 13 #include "chrome/browser/plugin_process_host.h" | 14 #include "chrome/browser/plugin_process_host.h" |
| 14 #include "chrome/browser/renderer_host/backing_store_mac.h" | 15 #include "chrome/browser/renderer_host/backing_store_mac.h" |
| 15 #include "chrome/browser/renderer_host/render_process_host.h" | 16 #include "chrome/browser/renderer_host/render_process_host.h" |
| 16 #include "chrome/browser/renderer_host/render_widget_host.h" | 17 #include "chrome/browser/renderer_host/render_widget_host.h" |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 NSRect position = NSMakeRect(bounds.x(), parent_rect.size.height - y_offset, | 401 NSRect position = NSMakeRect(bounds.x(), parent_rect.size.height - y_offset, |
| 401 bounds.width(), bounds.height()); | 402 bounds.width(), bounds.height()); |
| 402 | 403 |
| 403 // Display the menu. | 404 // Display the menu. |
| 404 scoped_nsobject<WebMenuRunner> menu_runner; | 405 scoped_nsobject<WebMenuRunner> menu_runner; |
| 405 menu_runner.reset([[WebMenuRunner alloc] initWithItems:items]); | 406 menu_runner.reset([[WebMenuRunner alloc] initWithItems:items]); |
| 406 | 407 |
| 407 { | 408 { |
| 408 // Make sure events can be pumped while the menu is up. | 409 // Make sure events can be pumped while the menu is up. |
| 409 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); | 410 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); |
| 411 |
| 412 // One of the events that could be pumped is |window.close()|. |
| 413 // User-initiated event-tracking loops protect against this by |
| 414 // setting flags in -[CrApplication sendEvent:], but since |
| 415 // web-content menus are initiated by IPC message the setup has to |
| 416 // be done manually. |
| 417 chrome_application_mac::ScopedSendingEvent sendingEventScoper; |
| 418 |
| 410 [menu_runner runMenuInView:parent_view_ | 419 [menu_runner runMenuInView:parent_view_ |
| 411 withBounds:position | 420 withBounds:position |
| 412 initialIndex:selected_item]; | 421 initialIndex:selected_item]; |
| 413 } | 422 } |
| 414 | 423 |
| 415 int window_num = [[parent_view_ window] windowNumber]; | 424 int window_num = [[parent_view_ window] windowNumber]; |
| 416 NSEvent* event = | 425 NSEvent* event = |
| 417 webkit_glue::EventWithMenuAction([menu_runner menuItemWasChosen], | 426 webkit_glue::EventWithMenuAction([menu_runner menuItemWasChosen], |
| 418 window_num, item_height, | 427 window_num, item_height, |
| 419 [menu_runner indexOfSelectedItem], | 428 [menu_runner indexOfSelectedItem], |
| (...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1397 event.skip_in_browser = true; | 1406 event.skip_in_browser = true; |
| 1398 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); | 1407 renderWidgetHostView_->render_widget_host_->ForwardKeyboardEvent(event); |
| 1399 } else { | 1408 } else { |
| 1400 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( | 1409 renderWidgetHostView_->render_widget_host_->ImeConfirmComposition( |
| 1401 UTF8ToUTF16([im_text UTF8String])); | 1410 UTF8ToUTF16([im_text UTF8String])); |
| 1402 } | 1411 } |
| 1403 renderWidgetHostView_->im_composing_ = false; | 1412 renderWidgetHostView_->im_composing_ = false; |
| 1404 } | 1413 } |
| 1405 | 1414 |
| 1406 @end | 1415 @end |
| OLD | NEW |