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/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "content/browser/renderer_host/dip_util.h" | 9 #include "content/browser/renderer_host/dip_util.h" |
10 #include "content/browser/renderer_host/overscroll_controller.h" | 10 #include "content/browser/renderer_host/overscroll_controller.h" |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 const gfx::Size& initial_size, gfx::NativeView context) { | 627 const gfx::Size& initial_size, gfx::NativeView context) { |
628 // NOTE: we ignore |initial_size| since in some cases it's wrong (such as | 628 // NOTE: we ignore |initial_size| since in some cases it's wrong (such as |
629 // if the bookmark bar is not shown and you create a new tab). The right | 629 // if the bookmark bar is not shown and you create a new tab). The right |
630 // value is set shortly after this, so its safe to ignore. | 630 // value is set shortly after this, so its safe to ignore. |
631 | 631 |
632 window_.reset(new aura::Window(this)); | 632 window_.reset(new aura::Window(this)); |
633 window_->set_owned_by_parent(false); | 633 window_->set_owned_by_parent(false); |
634 window_->SetType(aura::client::WINDOW_TYPE_CONTROL); | 634 window_->SetType(aura::client::WINDOW_TYPE_CONTROL); |
635 window_->SetTransparent(false); | 635 window_->SetTransparent(false); |
636 window_->Init(ui::LAYER_NOT_DRAWN); | 636 window_->Init(ui::LAYER_NOT_DRAWN); |
637 // TODO(mukai, erg): Should use a non-NULL value later when the DCHECK is | 637 if (context) { |
638 // turned on in SetDefaultParentByRootWindow(). | 638 // There are places where there is no context currently because object |
639 aura::RootWindow* target_root = context ? context->GetRootWindow() : NULL; | 639 // hierarchies are built before they're attached to a Widget. (See |
640 window_->SetDefaultParentByRootWindow(target_root, gfx::Rect()); | 640 // views::WebView as an example; GetWidget() returns NULL at the point |
| 641 // where we are created.) |
| 642 // |
| 643 // It should be OK to not set a default parent since such users will |
| 644 // explicitly add this WebContentsViewAura to their tree after they create |
| 645 // us. |
| 646 window_->SetDefaultParentByRootWindow(context->GetRootWindow(), |
| 647 gfx::Rect()); |
| 648 } |
641 window_->layer()->SetMasksToBounds(true); | 649 window_->layer()->SetMasksToBounds(true); |
642 window_->SetName("WebContentsViewAura"); | 650 window_->SetName("WebContentsViewAura"); |
643 | 651 |
644 window_observer_.reset(new WindowObserver(this)); | 652 window_observer_.reset(new WindowObserver(this)); |
645 | 653 |
646 // delegate_->GetDragDestDelegate() creates a new delegate on every call. | 654 // delegate_->GetDragDestDelegate() creates a new delegate on every call. |
647 // Hence, we save a reference to it locally. Similar model is used on other | 655 // Hence, we save a reference to it locally. Similar model is used on other |
648 // platforms as well. | 656 // platforms as well. |
649 if (delegate_.get()) | 657 if (delegate_.get()) |
650 drag_dest_delegate_ = delegate_->GetDragDestDelegate(); | 658 drag_dest_delegate_ = delegate_->GetDragDestDelegate(); |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 event.location(), | 1118 event.location(), |
1111 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | 1119 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
1112 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1120 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1113 if (drag_dest_delegate_) | 1121 if (drag_dest_delegate_) |
1114 drag_dest_delegate_->OnDrop(); | 1122 drag_dest_delegate_->OnDrop(); |
1115 current_drop_data_.reset(); | 1123 current_drop_data_.reset(); |
1116 return current_drag_op_; | 1124 return current_drag_op_; |
1117 } | 1125 } |
1118 | 1126 |
1119 } // namespace content | 1127 } // namespace content |
OLD | NEW |