Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1197)

Unified Diff: ui/views/focus/focus_traversal_unittest.cc

Issue 2482193003: views_unittests: Fix FocusTraversalTest's BorderView::widget_ deletion. (Closed)
Patch Set: Use base::MakeUnique, add to imports. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/focus/focus_traversal_unittest.cc
diff --git a/ui/views/focus/focus_traversal_unittest.cc b/ui/views/focus/focus_traversal_unittest.cc
index 7a43eef857d3ed05941fa4da830310a637eb231e..352b4e481d0fdac354983ca47cf3ad9eef904d5d 100644
--- a/ui/views/focus/focus_traversal_unittest.cc
+++ b/ui/views/focus/focus_traversal_unittest.cc
@@ -5,6 +5,7 @@
#include <stddef.h>
#include "base/macros.h"
+#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
@@ -132,20 +133,11 @@ class PaneView : public View, public FocusTraversable {
// view hierarchy.
class BorderView : public NativeViewHost {
public:
- explicit BorderView(View* child) : child_(child), widget_(NULL) {
+ explicit BorderView(View* child) : child_(child) {
DCHECK(child);
SetFocusBehavior(FocusBehavior::NEVER);
}
- ~BorderView() override {
- // TODO: ifdef should not be necessary. NativeWidgetMac has different
- // ownership semantics: http://crbug.com/663418.
-#if !defined(OS_MACOSX)
- if (widget_)
- widget_->CloseNow();
-#endif
- }
-
virtual internal::RootView* GetContentsRootView() {
return static_cast<internal::RootView*>(widget_->GetRootView());
}
@@ -160,9 +152,10 @@ class BorderView : public NativeViewHost {
if (details.child == this && details.is_add) {
if (!widget_) {
- widget_ = new Widget;
+ widget_ = base::MakeUnique<Widget>();
Widget::InitParams params(Widget::InitParams::TYPE_CONTROL);
params.parent = details.parent->GetWidget()->GetNativeView();
+ params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
widget_->Init(params);
widget_->SetFocusTraversableParentView(this);
widget_->SetContentsView(child_);
@@ -178,7 +171,7 @@ class BorderView : public NativeViewHost {
private:
View* child_;
- Widget* widget_;
+ std::unique_ptr<Widget> widget_;
DISALLOW_COPY_AND_ASSIGN(BorderView);
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698