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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 #if defined(OS_WIN) | 489 #if defined(OS_WIN) |
490 plugin_parent_window_ = NULL; | 490 plugin_parent_window_ = NULL; |
491 #endif | 491 #endif |
492 } | 492 } |
493 | 493 |
494 //////////////////////////////////////////////////////////////////////////////// | 494 //////////////////////////////////////////////////////////////////////////////// |
495 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 495 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
496 | 496 |
497 void RenderWidgetHostViewAura::InitAsChild( | 497 void RenderWidgetHostViewAura::InitAsChild( |
498 gfx::NativeView parent_view) { | 498 gfx::NativeView parent_view) { |
499 window_->Init(ui::LAYER_TEXTURED); | 499 window_->Init(aura::WINDOW_LAYER_TEXTURED); |
500 window_->SetName("RenderWidgetHostViewAura"); | 500 window_->SetName("RenderWidgetHostViewAura"); |
501 } | 501 } |
502 | 502 |
503 void RenderWidgetHostViewAura::InitAsPopup( | 503 void RenderWidgetHostViewAura::InitAsPopup( |
504 RenderWidgetHostView* parent_host_view, | 504 RenderWidgetHostView* parent_host_view, |
505 const gfx::Rect& bounds_in_screen) { | 505 const gfx::Rect& bounds_in_screen) { |
506 popup_parent_host_view_ = | 506 popup_parent_host_view_ = |
507 static_cast<RenderWidgetHostViewAura*>(parent_host_view); | 507 static_cast<RenderWidgetHostViewAura*>(parent_host_view); |
508 | 508 |
509 // TransientWindowClient may be NULL during tests. | 509 // TransientWindowClient may be NULL during tests. |
510 aura::client::TransientWindowClient* transient_window_client = | 510 aura::client::TransientWindowClient* transient_window_client = |
511 aura::client::GetTransientWindowClient(); | 511 aura::client::GetTransientWindowClient(); |
512 RenderWidgetHostViewAura* old_child = | 512 RenderWidgetHostViewAura* old_child = |
513 popup_parent_host_view_->popup_child_host_view_; | 513 popup_parent_host_view_->popup_child_host_view_; |
514 if (old_child) { | 514 if (old_child) { |
515 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or | 515 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or |
516 // similar mechanism to ensure a second popup doesn't cause the first one | 516 // similar mechanism to ensure a second popup doesn't cause the first one |
517 // to never get a chance to filter events. See crbug.com/160589. | 517 // to never get a chance to filter events. See crbug.com/160589. |
518 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); | 518 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); |
519 if (transient_window_client) { | 519 if (transient_window_client) { |
520 transient_window_client->RemoveTransientChild( | 520 transient_window_client->RemoveTransientChild( |
521 popup_parent_host_view_->window_, old_child->window_); | 521 popup_parent_host_view_->window_, old_child->window_); |
522 } | 522 } |
523 old_child->popup_parent_host_view_ = NULL; | 523 old_child->popup_parent_host_view_ = NULL; |
524 } | 524 } |
525 popup_parent_host_view_->popup_child_host_view_ = this; | 525 popup_parent_host_view_->popup_child_host_view_ = this; |
526 window_->SetType(ui::wm::WINDOW_TYPE_MENU); | 526 window_->SetType(ui::wm::WINDOW_TYPE_MENU); |
527 window_->Init(ui::LAYER_TEXTURED); | 527 window_->Init(aura::WINDOW_LAYER_TEXTURED); |
528 window_->SetName("RenderWidgetHostViewAura"); | 528 window_->SetName("RenderWidgetHostViewAura"); |
529 | 529 |
530 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); | 530 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); |
531 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); | 531 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); |
532 // Setting the transient child allows for the popup to get mouse events when | 532 // Setting the transient child allows for the popup to get mouse events when |
533 // in a system modal dialog. | 533 // in a system modal dialog. |
534 // This fixes crbug.com/328593. | 534 // This fixes crbug.com/328593. |
535 if (transient_window_client) { | 535 if (transient_window_client) { |
536 transient_window_client->AddTransientChild( | 536 transient_window_client->AddTransientChild( |
537 popup_parent_host_view_->window_, window_); | 537 popup_parent_host_view_->window_, window_); |
538 } | 538 } |
539 | 539 |
540 SetBounds(bounds_in_screen); | 540 SetBounds(bounds_in_screen); |
541 Show(); | 541 Show(); |
542 #if !defined(OS_WIN) && !defined(OS_CHROMEOS) | 542 #if !defined(OS_WIN) && !defined(OS_CHROMEOS) |
543 if (NeedsInputGrab()) | 543 if (NeedsInputGrab()) |
544 window_->SetCapture(); | 544 window_->SetCapture(); |
545 #endif | 545 #endif |
546 } | 546 } |
547 | 547 |
548 void RenderWidgetHostViewAura::InitAsFullscreen( | 548 void RenderWidgetHostViewAura::InitAsFullscreen( |
549 RenderWidgetHostView* reference_host_view) { | 549 RenderWidgetHostView* reference_host_view) { |
550 is_fullscreen_ = true; | 550 is_fullscreen_ = true; |
551 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 551 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
552 window_->Init(ui::LAYER_TEXTURED); | 552 window_->Init(aura::WINDOW_LAYER_TEXTURED); |
553 window_->SetName("RenderWidgetHostViewAura"); | 553 window_->SetName("RenderWidgetHostViewAura"); |
554 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 554 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
555 | 555 |
556 aura::Window* parent = NULL; | 556 aura::Window* parent = NULL; |
557 gfx::Rect bounds; | 557 gfx::Rect bounds; |
558 if (reference_host_view) { | 558 if (reference_host_view) { |
559 aura::Window* reference_window = | 559 aura::Window* reference_window = |
560 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; | 560 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; |
561 if (reference_window) { | 561 if (reference_window) { |
562 host_tracker_.reset(new aura::WindowTracker); | 562 host_tracker_.reset(new aura::WindowTracker); |
(...skipping 2938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3501 RenderWidgetHost* widget) { | 3501 RenderWidgetHost* widget) { |
3502 return new RenderWidgetHostViewAura(widget); | 3502 return new RenderWidgetHostViewAura(widget); |
3503 } | 3503 } |
3504 | 3504 |
3505 // static | 3505 // static |
3506 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3506 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
3507 GetScreenInfoForWindow(results, NULL); | 3507 GetScreenInfoForWindow(results, NULL); |
3508 } | 3508 } |
3509 | 3509 |
3510 } // namespace content | 3510 } // namespace content |
OLD | NEW |