OLD | NEW |
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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 48 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
49 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 49 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
50 #include "third_party/WebKit/public/web/WebInputEvent.h" | 50 #include "third_party/WebKit/public/web/WebInputEvent.h" |
51 #include "ui/aura/client/activation_client.h" | 51 #include "ui/aura/client/activation_client.h" |
52 #include "ui/aura/client/aura_constants.h" | 52 #include "ui/aura/client/aura_constants.h" |
53 #include "ui/aura/client/cursor_client.h" | 53 #include "ui/aura/client/cursor_client.h" |
54 #include "ui/aura/client/cursor_client_observer.h" | 54 #include "ui/aura/client/cursor_client_observer.h" |
55 #include "ui/aura/client/focus_client.h" | 55 #include "ui/aura/client/focus_client.h" |
56 #include "ui/aura/client/screen_position_client.h" | 56 #include "ui/aura/client/screen_position_client.h" |
57 #include "ui/aura/client/tooltip_client.h" | 57 #include "ui/aura/client/tooltip_client.h" |
| 58 #include "ui/aura/client/transient_window_client.h" |
58 #include "ui/aura/client/window_tree_client.h" | 59 #include "ui/aura/client/window_tree_client.h" |
59 #include "ui/aura/env.h" | 60 #include "ui/aura/env.h" |
60 #include "ui/aura/root_window.h" | 61 #include "ui/aura/root_window.h" |
61 #include "ui/aura/window.h" | 62 #include "ui/aura/window.h" |
62 #include "ui/aura/window_observer.h" | 63 #include "ui/aura/window_observer.h" |
63 #include "ui/aura/window_tracker.h" | 64 #include "ui/aura/window_tracker.h" |
64 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 65 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
65 #include "ui/base/hit_test.h" | 66 #include "ui/base/hit_test.h" |
66 #include "ui/base/ime/input_method.h" | 67 #include "ui/base/ime/input_method.h" |
67 #include "ui/base/ui_base_types.h" | 68 #include "ui/base/ui_base_types.h" |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 window_->Init(ui::LAYER_TEXTURED); | 498 window_->Init(ui::LAYER_TEXTURED); |
498 window_->SetName("RenderWidgetHostViewAura"); | 499 window_->SetName("RenderWidgetHostViewAura"); |
499 } | 500 } |
500 | 501 |
501 void RenderWidgetHostViewAura::InitAsPopup( | 502 void RenderWidgetHostViewAura::InitAsPopup( |
502 RenderWidgetHostView* parent_host_view, | 503 RenderWidgetHostView* parent_host_view, |
503 const gfx::Rect& bounds_in_screen) { | 504 const gfx::Rect& bounds_in_screen) { |
504 popup_parent_host_view_ = | 505 popup_parent_host_view_ = |
505 static_cast<RenderWidgetHostViewAura*>(parent_host_view); | 506 static_cast<RenderWidgetHostViewAura*>(parent_host_view); |
506 | 507 |
| 508 // TransientWindowClient may be NULL during tests. |
| 509 aura::client::TransientWindowClient* transient_window_client = |
| 510 aura::client::GetTransientWindowClient(); |
507 RenderWidgetHostViewAura* old_child = | 511 RenderWidgetHostViewAura* old_child = |
508 popup_parent_host_view_->popup_child_host_view_; | 512 popup_parent_host_view_->popup_child_host_view_; |
509 if (old_child) { | 513 if (old_child) { |
510 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or | 514 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or |
511 // similar mechanism to ensure a second popup doesn't cause the first one | 515 // similar mechanism to ensure a second popup doesn't cause the first one |
512 // to never get a chance to filter events. See crbug.com/160589. | 516 // to never get a chance to filter events. See crbug.com/160589. |
513 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); | 517 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); |
514 popup_parent_host_view_->window_->RemoveTransientChild(old_child->window_); | 518 if (transient_window_client) { |
| 519 transient_window_client->RemoveTransientChild( |
| 520 popup_parent_host_view_->window_, old_child->window_); |
| 521 } |
515 old_child->popup_parent_host_view_ = NULL; | 522 old_child->popup_parent_host_view_ = NULL; |
516 } | 523 } |
517 popup_parent_host_view_->popup_child_host_view_ = this; | 524 popup_parent_host_view_->popup_child_host_view_ = this; |
518 window_->SetType(ui::wm::WINDOW_TYPE_MENU); | 525 window_->SetType(ui::wm::WINDOW_TYPE_MENU); |
519 window_->Init(ui::LAYER_TEXTURED); | 526 window_->Init(ui::LAYER_TEXTURED); |
520 window_->SetName("RenderWidgetHostViewAura"); | 527 window_->SetName("RenderWidgetHostViewAura"); |
521 | 528 |
522 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); | 529 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); |
523 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); | 530 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); |
524 // Setting the transient child allows for the popup to get mouse events when | 531 // Setting the transient child allows for the popup to get mouse events when |
525 // in a system modal dialog. | 532 // in a system modal dialog. |
526 // This fixes crbug.com/328593. | 533 // This fixes crbug.com/328593. |
527 popup_parent_host_view_->window_->AddTransientChild(window_); | 534 if (transient_window_client) { |
| 535 transient_window_client->AddTransientChild( |
| 536 popup_parent_host_view_->window_, window_); |
| 537 } |
528 | 538 |
529 SetBounds(bounds_in_screen); | 539 SetBounds(bounds_in_screen); |
530 Show(); | 540 Show(); |
531 #if !defined(OS_WIN) && !defined(OS_CHROMEOS) | 541 #if !defined(OS_WIN) && !defined(OS_CHROMEOS) |
532 if (NeedsInputGrab()) | 542 if (NeedsInputGrab()) |
533 window_->SetCapture(); | 543 window_->SetCapture(); |
534 #endif | 544 #endif |
535 } | 545 } |
536 | 546 |
537 void RenderWidgetHostViewAura::InitAsFullscreen( | 547 void RenderWidgetHostViewAura::InitAsFullscreen( |
(...skipping 2954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3492 RenderWidgetHost* widget) { | 3502 RenderWidgetHost* widget) { |
3493 return new RenderWidgetHostViewAura(widget); | 3503 return new RenderWidgetHostViewAura(widget); |
3494 } | 3504 } |
3495 | 3505 |
3496 // static | 3506 // static |
3497 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3507 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
3498 GetScreenInfoForWindow(results, NULL); | 3508 GetScreenInfoForWindow(results, NULL); |
3499 } | 3509 } |
3500 | 3510 |
3501 } // namespace content | 3511 } // namespace content |
OLD | NEW |