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 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 const gfx::Size& initial_size, gfx::NativeView context) { | 734 const gfx::Size& initial_size, gfx::NativeView context) { |
735 // NOTE: we ignore |initial_size| since in some cases it's wrong (such as | 735 // NOTE: we ignore |initial_size| since in some cases it's wrong (such as |
736 // if the bookmark bar is not shown and you create a new tab). The right | 736 // if the bookmark bar is not shown and you create a new tab). The right |
737 // value is set shortly after this, so its safe to ignore. | 737 // value is set shortly after this, so its safe to ignore. |
738 | 738 |
739 window_.reset(new aura::Window(this)); | 739 window_.reset(new aura::Window(this)); |
740 window_->set_owned_by_parent(false); | 740 window_->set_owned_by_parent(false); |
741 window_->SetType(aura::client::WINDOW_TYPE_CONTROL); | 741 window_->SetType(aura::client::WINDOW_TYPE_CONTROL); |
742 window_->SetTransparent(false); | 742 window_->SetTransparent(false); |
743 window_->Init(ui::LAYER_NOT_DRAWN); | 743 window_->Init(ui::LAYER_NOT_DRAWN); |
744 // TODO(mukai, erg): Should use a non-NULL value later when the DCHECK is | 744 if (context) { |
745 // turned on in SetDefaultParentByRootWindow(). | 745 // There are places where there is no context currently because object |
746 aura::RootWindow* target_root = context ? context->GetRootWindow() : NULL; | 746 // hierarchies are built before they're attached to a Widget. (See |
747 window_->SetDefaultParentByRootWindow(target_root, gfx::Rect()); | 747 // views::WebView as an example; GetWidget() returns NULL at the point |
| 748 // where we are created.) |
| 749 // |
| 750 // It should be OK to not set a default parent since such users will |
| 751 // explicitly add this WebContentsViewAura to their tree after they create |
| 752 // us. |
| 753 window_->SetDefaultParentByRootWindow(context->GetRootWindow(), |
| 754 gfx::Rect()); |
| 755 } |
748 window_->layer()->SetMasksToBounds(true); | 756 window_->layer()->SetMasksToBounds(true); |
749 window_->SetName("WebContentsViewAura"); | 757 window_->SetName("WebContentsViewAura"); |
750 | 758 |
751 window_observer_.reset(new WindowObserver(this)); | 759 window_observer_.reset(new WindowObserver(this)); |
752 | 760 |
753 // delegate_->GetDragDestDelegate() creates a new delegate on every call. | 761 // delegate_->GetDragDestDelegate() creates a new delegate on every call. |
754 // Hence, we save a reference to it locally. Similar model is used on other | 762 // Hence, we save a reference to it locally. Similar model is used on other |
755 // platforms as well. | 763 // platforms as well. |
756 if (delegate_.get()) | 764 if (delegate_.get()) |
757 drag_dest_delegate_ = delegate_->GetDragDestDelegate(); | 765 drag_dest_delegate_ = delegate_->GetDragDestDelegate(); |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 event.location(), | 1237 event.location(), |
1230 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | 1238 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
1231 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1239 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1232 if (drag_dest_delegate_) | 1240 if (drag_dest_delegate_) |
1233 drag_dest_delegate_->OnDrop(); | 1241 drag_dest_delegate_->OnDrop(); |
1234 current_drop_data_.reset(); | 1242 current_drop_data_.reset(); |
1235 return current_drag_op_; | 1243 return current_drag_op_; |
1236 } | 1244 } |
1237 | 1245 |
1238 } // namespace content | 1246 } // namespace content |
OLD | NEW |