Reland "Added material refresh layout provider. Updated material design controller."

This is a reland of 7a462a5db6eeeedd30c5e4abfa9f45b6a8aca7f6

Original change's description:
> Added material refresh layout provider. Updated material design controller.
> 
> Added IsMaterialRefreshMode() function to ChromeLayoutProvider.
> 
> Bug: 822000
> Change-Id: I379d7603838cdec60b3f94fc0e163e9907995b61
> Reviewed-on: https://chromium-review.googlesource.com/988052
> Commit-Queue: Allen Bauer <kylixrd@chromium.org>
> Reviewed-by: Scott Violet <sky@chromium.org>
> Reviewed-by: Peter Kasting <pkasting@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#548413}

Bug: 822000
Change-Id: I10e27e8294308d01415664adccfac7c4a7206b38
Reviewed-on: https://chromium-review.googlesource.com/999335
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Allen Bauer <kylixrd@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548871}
diff --git a/chrome/browser/ui/BUILD.gn b/chrome/browser/ui/BUILD.gn
index 19aed51..fdf1c0ef 100644
--- a/chrome/browser/ui/BUILD.gn
+++ b/chrome/browser/ui/BUILD.gn
@@ -2871,6 +2871,8 @@
       "views/harmony/harmony_layout_provider.h",
       "views/harmony/harmony_typography_provider.cc",
       "views/harmony/harmony_typography_provider.h",
+      "views/harmony/material_refresh_layout_provider.cc",
+      "views/harmony/material_refresh_layout_provider.h",
       "views/harmony/textfield_layout.cc",
       "views/harmony/textfield_layout.h",
       "views/hover_button.cc",
diff --git a/chrome/browser/ui/views/harmony/chrome_layout_provider.cc b/chrome/browser/ui/views/harmony/chrome_layout_provider.cc
index acbf8b2..3dba5720 100644
--- a/chrome/browser/ui/views/harmony/chrome_layout_provider.cc
+++ b/chrome/browser/ui/views/harmony/chrome_layout_provider.cc
@@ -9,6 +9,7 @@
 #include "base/logging.h"
 #include "chrome/browser/ui/views/harmony/chrome_typography.h"
 #include "chrome/browser/ui/views/harmony/harmony_layout_provider.h"
+#include "chrome/browser/ui/views/harmony/material_refresh_layout_provider.h"
 #include "ui/base/material_design/material_design_controller.h"
 
 namespace {
@@ -37,6 +38,9 @@
 // static
 std::unique_ptr<views::LayoutProvider>
 ChromeLayoutProvider::CreateLayoutProvider() {
+  if (ui::MaterialDesignController::GetMode() ==
+      ui::MaterialDesignController::MATERIAL_REFRESH)
+    return std::make_unique<MaterialRefreshLayoutProvider>();
   return ui::MaterialDesignController::IsSecondaryUiMaterial()
              ? std::make_unique<HarmonyLayoutProvider>()
              : std::make_unique<ChromeLayoutProvider>();
diff --git a/chrome/browser/ui/views/harmony/material_refresh_layout_provider.cc b/chrome/browser/ui/views/harmony/material_refresh_layout_provider.cc
new file mode 100644
index 0000000..77d5d78
--- /dev/null
+++ b/chrome/browser/ui/views/harmony/material_refresh_layout_provider.cc
@@ -0,0 +1,21 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/views/harmony/material_refresh_layout_provider.h"
+
+int MaterialRefreshLayoutProvider::GetCornerRadiusMetric(
+    ChromeEmphasisMetric emphasis_metric,
+    const gfx::Rect& bounds) const {
+  switch (emphasis_metric) {
+    case EMPHASIS_LOW:
+      return 4;
+    case EMPHASIS_MEDIUM:
+      return 8;
+    case EMPHASIS_HIGH:
+      return std::min(bounds.width(), bounds.height()) / 2;
+    default:
+      NOTREACHED();
+      return 0;
+  }
+}
diff --git a/chrome/browser/ui/views/harmony/material_refresh_layout_provider.h b/chrome/browser/ui/views/harmony/material_refresh_layout_provider.h
new file mode 100644
index 0000000..47ef6cf
--- /dev/null
+++ b/chrome/browser/ui/views/harmony/material_refresh_layout_provider.h
@@ -0,0 +1,21 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_VIEWS_HARMONY_MATERIAL_REFRESH_LAYOUT_PROVIDER_H_
+#define CHROME_BROWSER_UI_VIEWS_HARMONY_MATERIAL_REFRESH_LAYOUT_PROVIDER_H_
+
+#include "base/macros.h"
+#include "chrome/browser/ui/views/harmony/harmony_layout_provider.h"
+
+class MaterialRefreshLayoutProvider : public HarmonyLayoutProvider {
+ public:
+  MaterialRefreshLayoutProvider() = default;
+  ~MaterialRefreshLayoutProvider() override = default;
+
+  int GetCornerRadiusMetric(
+      ChromeEmphasisMetric emphasis_metric,
+      const gfx::Rect& bounds = gfx::Rect()) const override;
+};
+
+#endif  // CHROME_BROWSER_UI_VIEWS_HARMONY_MATERIAL_REFRESH_LAYOUT_PROVIDER_H_
diff --git a/ui/base/material_design/material_design_controller.cc b/ui/base/material_design/material_design_controller.cc
index d4dd4b1..5abb641 100644
--- a/ui/base/material_design/material_design_controller.cc
+++ b/ui/base/material_design/material_design_controller.cc
@@ -120,7 +120,8 @@
 
 // static
 bool MaterialDesignController::IsSecondaryUiMaterial() {
-  return base::FeatureList::IsEnabled(features::kSecondaryUiMd);
+  return base::FeatureList::IsEnabled(features::kSecondaryUiMd) ||
+         GetMode() == MATERIAL_REFRESH;
 }
 
 // static
diff --git a/ui/views/controls/progress_bar_unittest.cc b/ui/views/controls/progress_bar_unittest.cc
index 6eddafe..09bb6d8 100644
--- a/ui/views/controls/progress_bar_unittest.cc
+++ b/ui/views/controls/progress_bar_unittest.cc
@@ -9,10 +9,13 @@
 #include "ui/accessibility/ax_node_data.h"
 #include "ui/gfx/color_utils.h"
 #include "ui/native_theme/native_theme.h"
+#include "ui/views/test/views_test_base.h"
 
 namespace views {
 
-TEST(ProgressBarTest, Accessibility) {
+using ProgressBarTest = ViewsTestBase;
+
+TEST_F(ProgressBarTest, Accessibility) {
   ProgressBar bar;
   bar.SetValue(0.62);
 
@@ -26,7 +29,7 @@
 }
 
 // Test that default colors can be overridden. Used by Chromecast.
-TEST(ProgressBarTest, OverrideDefaultColors) {
+TEST_F(ProgressBarTest, OverrideDefaultColors) {
   ProgressBar bar;
   EXPECT_NE(SK_ColorRED, bar.GetForegroundColor());
   EXPECT_NE(SK_ColorGREEN, bar.GetBackgroundColor());
diff --git a/ui/views/controls/scroll_view_unittest.cc b/ui/views/controls/scroll_view_unittest.cc
index d57fbb05..16ec528c8 100644
--- a/ui/views/controls/scroll_view_unittest.cc
+++ b/ui/views/controls/scroll_view_unittest.cc
@@ -134,12 +134,12 @@
   DISALLOW_COPY_AND_ASSIGN(CustomView);
 };
 
-void CheckScrollbarVisibility(const ScrollView& scroll_view,
+void CheckScrollbarVisibility(const ScrollView* scroll_view,
                               ScrollBarOrientation orientation,
                               bool should_be_visible) {
   const ScrollBar* scrollbar = orientation == HORIZONTAL
-                                   ? scroll_view.horizontal_scroll_bar()
-                                   : scroll_view.vertical_scroll_bar();
+                                   ? scroll_view->horizontal_scroll_bar()
+                                   : scroll_view->vertical_scroll_bar();
   if (should_be_visible) {
     ASSERT_TRUE(scrollbar);
     EXPECT_TRUE(scrollbar->visible());
@@ -179,11 +179,16 @@
  public:
   ScrollViewTest() {}
 
+  void SetUp() override {
+    ViewsTestBase::SetUp();
+    scroll_view_ = std::make_unique<ScrollView>();
+  }
+
   View* InstallContents() {
     const gfx::Rect default_outer_bounds(0, 0, 100, 100);
     View* contents = new View;
-    scroll_view_.SetContents(contents);
-    scroll_view_.SetBoundsRect(default_outer_bounds);
+    scroll_view_->SetContents(contents);
+    scroll_view_->SetBoundsRect(default_outer_bounds);
     return contents;
   }
 
@@ -208,14 +213,14 @@
  protected:
 #endif
   int VerticalScrollBarWidth() {
-    return scroll_view_.vertical_scroll_bar()->GetThickness();
+    return scroll_view_->vertical_scroll_bar()->GetThickness();
   }
 
   int HorizontalScrollBarHeight() {
-    return scroll_view_.horizontal_scroll_bar()->GetThickness();
+    return scroll_view_->horizontal_scroll_bar()->GetThickness();
   }
 
-  ScrollView scroll_view_;
+  std::unique_ptr<ScrollView> scroll_view_;
 
  private:
   DISALLOW_COPY_AND_ASSIGN(ScrollViewTest);
@@ -332,7 +337,7 @@
 // Verifies the viewport is sized to fit the available space.
 TEST_F(ScrollViewTest, ViewportSizedToFit) {
   View* contents = InstallContents();
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   EXPECT_EQ("0,0 100x100", contents->parent()->bounds().ToString());
 }
 
@@ -340,9 +345,9 @@
 // bounded scroll view.
 TEST_F(ScrollViewTest, BoundedViewportSizedToFit) {
   View* contents = InstallContents();
-  scroll_view_.ClipHeightTo(100, 200);
-  scroll_view_.SetBorder(CreateSolidBorder(2, 0));
-  scroll_view_.Layout();
+  scroll_view_->ClipHeightTo(100, 200);
+  scroll_view_->SetBorder(CreateSolidBorder(2, 0));
+  scroll_view_->Layout();
   EXPECT_EQ("2,2 96x96", contents->parent()->bounds().ToString());
 
   // Make sure the width of |contents| is set properly not to overflow the
@@ -355,11 +360,11 @@
 TEST_F(ScrollViewTest, VerticalScrollbarDoesNotAppearUnnecessarily) {
   const gfx::Rect default_outer_bounds(0, 0, 100, 100);
   View* contents = new VerticalResizingView;
-  scroll_view_.SetContents(contents);
-  scroll_view_.SetBoundsRect(default_outer_bounds);
-  scroll_view_.Layout();
-  EXPECT_FALSE(scroll_view_.vertical_scroll_bar()->visible());
-  EXPECT_TRUE(scroll_view_.horizontal_scroll_bar()->visible());
+  scroll_view_->SetContents(contents);
+  scroll_view_->SetBoundsRect(default_outer_bounds);
+  scroll_view_->Layout();
+  EXPECT_FALSE(scroll_view_->vertical_scroll_bar()->visible());
+  EXPECT_TRUE(scroll_view_->horizontal_scroll_bar()->visible());
 }
 
 // Verifies the scrollbars are added as necessary.
@@ -369,54 +374,54 @@
 
   // Size the contents such that vertical scrollbar is needed.
   contents->SetBounds(0, 0, 50, 400);
-  scroll_view_.Layout();
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutWidth(),
+  scroll_view_->Layout();
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutWidth(),
             contents->parent()->width());
   EXPECT_EQ(100, contents->parent()->height());
-  CheckScrollbarVisibility(scroll_view_, VERTICAL, true);
-  CheckScrollbarVisibility(scroll_view_, HORIZONTAL, false);
-  EXPECT_TRUE(!scroll_view_.horizontal_scroll_bar() ||
-              !scroll_view_.horizontal_scroll_bar()->visible());
-  ASSERT_TRUE(scroll_view_.vertical_scroll_bar() != NULL);
-  EXPECT_TRUE(scroll_view_.vertical_scroll_bar()->visible());
+  CheckScrollbarVisibility(scroll_view_.get(), VERTICAL, true);
+  CheckScrollbarVisibility(scroll_view_.get(), HORIZONTAL, false);
+  EXPECT_TRUE(!scroll_view_->horizontal_scroll_bar() ||
+              !scroll_view_->horizontal_scroll_bar()->visible());
+  ASSERT_TRUE(scroll_view_->vertical_scroll_bar() != NULL);
+  EXPECT_TRUE(scroll_view_->vertical_scroll_bar()->visible());
 
   // Size the contents such that horizontal scrollbar is needed.
   contents->SetBounds(0, 0, 400, 50);
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   EXPECT_EQ(100, contents->parent()->width());
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutHeight(),
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutHeight(),
             contents->parent()->height());
-  CheckScrollbarVisibility(scroll_view_, VERTICAL, false);
-  CheckScrollbarVisibility(scroll_view_, HORIZONTAL, true);
+  CheckScrollbarVisibility(scroll_view_.get(), VERTICAL, false);
+  CheckScrollbarVisibility(scroll_view_.get(), HORIZONTAL, true);
 
   // Both horizontal and vertical.
   contents->SetBounds(0, 0, 300, 400);
-  scroll_view_.Layout();
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutWidth(),
+  scroll_view_->Layout();
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutWidth(),
             contents->parent()->width());
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutHeight(),
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutHeight(),
             contents->parent()->height());
-  CheckScrollbarVisibility(scroll_view_, VERTICAL, true);
-  CheckScrollbarVisibility(scroll_view_, HORIZONTAL, true);
+  CheckScrollbarVisibility(scroll_view_.get(), VERTICAL, true);
+  CheckScrollbarVisibility(scroll_view_.get(), HORIZONTAL, true);
 
   // Add a border, test vertical scrollbar.
   const int kTopPadding = 1;
   const int kLeftPadding = 2;
   const int kBottomPadding = 3;
   const int kRightPadding = 4;
-  scroll_view_.SetBorder(CreateEmptyBorder(kTopPadding, kLeftPadding,
-                                           kBottomPadding, kRightPadding));
+  scroll_view_->SetBorder(CreateEmptyBorder(kTopPadding, kLeftPadding,
+                                            kBottomPadding, kRightPadding));
   contents->SetBounds(0, 0, 50, 400);
-  scroll_view_.Layout();
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutWidth() - kLeftPadding -
+  scroll_view_->Layout();
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutWidth() - kLeftPadding -
                 kRightPadding,
             contents->parent()->width());
   EXPECT_EQ(100 - kTopPadding - kBottomPadding, contents->parent()->height());
-  EXPECT_TRUE(!scroll_view_.horizontal_scroll_bar() ||
-              !scroll_view_.horizontal_scroll_bar()->visible());
-  ASSERT_TRUE(scroll_view_.vertical_scroll_bar() != NULL);
-  EXPECT_TRUE(scroll_view_.vertical_scroll_bar()->visible());
-  gfx::Rect bounds = scroll_view_.vertical_scroll_bar()->bounds();
+  EXPECT_TRUE(!scroll_view_->horizontal_scroll_bar() ||
+              !scroll_view_->horizontal_scroll_bar()->visible());
+  ASSERT_TRUE(scroll_view_->vertical_scroll_bar() != NULL);
+  EXPECT_TRUE(scroll_view_->vertical_scroll_bar()->visible());
+  gfx::Rect bounds = scroll_view_->vertical_scroll_bar()->bounds();
   EXPECT_EQ(100 - VerticalScrollBarWidth() - kRightPadding, bounds.x());
   EXPECT_EQ(100 - kRightPadding, bounds.right());
   EXPECT_EQ(kTopPadding, bounds.y());
@@ -424,16 +429,16 @@
 
   // Horizontal with border.
   contents->SetBounds(0, 0, 400, 50);
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   EXPECT_EQ(100 - kLeftPadding - kRightPadding, contents->parent()->width());
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutHeight() - kTopPadding -
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutHeight() - kTopPadding -
                 kBottomPadding,
             contents->parent()->height());
-  ASSERT_TRUE(scroll_view_.horizontal_scroll_bar() != NULL);
-  EXPECT_TRUE(scroll_view_.horizontal_scroll_bar()->visible());
-  EXPECT_TRUE(!scroll_view_.vertical_scroll_bar() ||
-              !scroll_view_.vertical_scroll_bar()->visible());
-  bounds = scroll_view_.horizontal_scroll_bar()->bounds();
+  ASSERT_TRUE(scroll_view_->horizontal_scroll_bar() != NULL);
+  EXPECT_TRUE(scroll_view_->horizontal_scroll_bar()->visible());
+  EXPECT_TRUE(!scroll_view_->vertical_scroll_bar() ||
+              !scroll_view_->vertical_scroll_bar()->visible());
+  bounds = scroll_view_->horizontal_scroll_bar()->bounds();
   EXPECT_EQ(kLeftPadding, bounds.x());
   EXPECT_EQ(100 - kRightPadding, bounds.right());
   EXPECT_EQ(100 - kBottomPadding - HorizontalScrollBarHeight(), bounds.y());
@@ -441,26 +446,26 @@
 
   // Both horizontal and vertical with border.
   contents->SetBounds(0, 0, 300, 400);
-  scroll_view_.Layout();
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutWidth() - kLeftPadding -
+  scroll_view_->Layout();
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutWidth() - kLeftPadding -
                 kRightPadding,
             contents->parent()->width());
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutHeight() - kTopPadding -
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutHeight() - kTopPadding -
                 kBottomPadding,
             contents->parent()->height());
-  bounds = scroll_view_.horizontal_scroll_bar()->bounds();
+  bounds = scroll_view_->horizontal_scroll_bar()->bounds();
   // Check horiz.
-  ASSERT_TRUE(scroll_view_.horizontal_scroll_bar() != NULL);
-  EXPECT_TRUE(scroll_view_.horizontal_scroll_bar()->visible());
-  bounds = scroll_view_.horizontal_scroll_bar()->bounds();
+  ASSERT_TRUE(scroll_view_->horizontal_scroll_bar() != NULL);
+  EXPECT_TRUE(scroll_view_->horizontal_scroll_bar()->visible());
+  bounds = scroll_view_->horizontal_scroll_bar()->bounds();
   EXPECT_EQ(kLeftPadding, bounds.x());
   EXPECT_EQ(100 - kRightPadding - VerticalScrollBarWidth(), bounds.right());
   EXPECT_EQ(100 - kBottomPadding - HorizontalScrollBarHeight(), bounds.y());
   EXPECT_EQ(100 - kBottomPadding, bounds.bottom());
   // Check vert.
-  ASSERT_TRUE(scroll_view_.vertical_scroll_bar() != NULL);
-  EXPECT_TRUE(scroll_view_.vertical_scroll_bar()->visible());
-  bounds = scroll_view_.vertical_scroll_bar()->bounds();
+  ASSERT_TRUE(scroll_view_->vertical_scroll_bar() != NULL);
+  EXPECT_TRUE(scroll_view_->vertical_scroll_bar()->visible());
+  bounds = scroll_view_->vertical_scroll_bar()->bounds();
   EXPECT_EQ(100 - VerticalScrollBarWidth() - kRightPadding, bounds.x());
   EXPECT_EQ(100 - kRightPadding, bounds.right());
   EXPECT_EQ(kTopPadding, bounds.y());
@@ -471,11 +476,11 @@
 // Assertions around adding a header.
 TEST_F(ScrollViewTest, Header) {
   CustomView* header = new CustomView;
-  scroll_view_.SetHeader(header);
+  scroll_view_->SetHeader(header);
   View* header_parent = header->parent();
   View* contents = InstallContents();
 
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   // |header|s preferred size is empty, which should result in all space going
   // to contents.
   EXPECT_EQ("0,0 100x0", header->parent()->bounds().ToString());
@@ -502,7 +507,7 @@
   EXPECT_EQ("0,0 0x0", contents->bounds().ToString());
 
   // Remove the header.
-  scroll_view_.SetHeader(NULL);
+  scroll_view_->SetHeader(NULL);
   // SetHeader(NULL) deletes header.
   header = NULL;
   EXPECT_EQ("0,0 100x0", header_parent->bounds().ToString());
@@ -512,111 +517,111 @@
 // Verifies the scrollbars are added as necessary when a header is present.
 TEST_F(ScrollViewTest, ScrollBarsWithHeader) {
   CustomView* header = new CustomView;
-  scroll_view_.SetHeader(header);
+  scroll_view_->SetHeader(header);
   View* contents = InstallContents();
 
   header->SetPreferredSize(gfx::Size(10, 20));
 
   // Size the contents such that vertical scrollbar is needed.
   contents->SetBounds(0, 0, 50, 400);
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   EXPECT_EQ(0, contents->parent()->x());
   EXPECT_EQ(20, contents->parent()->y());
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutWidth(),
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutWidth(),
             contents->parent()->width());
   EXPECT_EQ(80, contents->parent()->height());
   EXPECT_EQ(0, header->parent()->x());
   EXPECT_EQ(0, header->parent()->y());
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutWidth(),
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutWidth(),
             header->parent()->width());
   EXPECT_EQ(20, header->parent()->height());
-  EXPECT_TRUE(!scroll_view_.horizontal_scroll_bar() ||
-              !scroll_view_.horizontal_scroll_bar()->visible());
-  ASSERT_TRUE(scroll_view_.vertical_scroll_bar() != NULL);
-  EXPECT_TRUE(scroll_view_.vertical_scroll_bar()->visible());
+  EXPECT_TRUE(!scroll_view_->horizontal_scroll_bar() ||
+              !scroll_view_->horizontal_scroll_bar()->visible());
+  ASSERT_TRUE(scroll_view_->vertical_scroll_bar() != NULL);
+  EXPECT_TRUE(scroll_view_->vertical_scroll_bar()->visible());
   // Make sure the vertical scrollbar overlaps the header for traditional
   // scrollbars and doesn't overlap the header for overlay scrollbars.
   const int expected_scrollbar_y =
-      scroll_view_.vertical_scroll_bar()->OverlapsContent()
+      scroll_view_->vertical_scroll_bar()->OverlapsContent()
           ? header->bounds().bottom()
           : header->y();
-  EXPECT_EQ(expected_scrollbar_y, scroll_view_.vertical_scroll_bar()->y());
+  EXPECT_EQ(expected_scrollbar_y, scroll_view_->vertical_scroll_bar()->y());
   EXPECT_EQ(header->y(), contents->y());
 
   // Size the contents such that horizontal scrollbar is needed.
   contents->SetBounds(0, 0, 400, 50);
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   EXPECT_EQ(0, contents->parent()->x());
   EXPECT_EQ(20, contents->parent()->y());
   EXPECT_EQ(100, contents->parent()->width());
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutHeight() - 20,
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutHeight() - 20,
             contents->parent()->height());
   EXPECT_EQ(0, header->parent()->x());
   EXPECT_EQ(0, header->parent()->y());
   EXPECT_EQ(100, header->parent()->width());
   EXPECT_EQ(20, header->parent()->height());
-  ASSERT_TRUE(scroll_view_.horizontal_scroll_bar() != NULL);
-  EXPECT_TRUE(scroll_view_.horizontal_scroll_bar()->visible());
-  EXPECT_TRUE(!scroll_view_.vertical_scroll_bar() ||
-              !scroll_view_.vertical_scroll_bar()->visible());
+  ASSERT_TRUE(scroll_view_->horizontal_scroll_bar() != NULL);
+  EXPECT_TRUE(scroll_view_->horizontal_scroll_bar()->visible());
+  EXPECT_TRUE(!scroll_view_->vertical_scroll_bar() ||
+              !scroll_view_->vertical_scroll_bar()->visible());
 
   // Both horizontal and vertical.
   contents->SetBounds(0, 0, 300, 400);
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   EXPECT_EQ(0, contents->parent()->x());
   EXPECT_EQ(20, contents->parent()->y());
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutWidth(),
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutWidth(),
             contents->parent()->width());
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutHeight() - 20,
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutHeight() - 20,
             contents->parent()->height());
   EXPECT_EQ(0, header->parent()->x());
   EXPECT_EQ(0, header->parent()->y());
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutWidth(),
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutWidth(),
             header->parent()->width());
   EXPECT_EQ(20, header->parent()->height());
-  ASSERT_TRUE(scroll_view_.horizontal_scroll_bar() != NULL);
-  EXPECT_TRUE(scroll_view_.horizontal_scroll_bar()->visible());
-  ASSERT_TRUE(scroll_view_.vertical_scroll_bar() != NULL);
-  EXPECT_TRUE(scroll_view_.vertical_scroll_bar()->visible());
+  ASSERT_TRUE(scroll_view_->horizontal_scroll_bar() != NULL);
+  EXPECT_TRUE(scroll_view_->horizontal_scroll_bar()->visible());
+  ASSERT_TRUE(scroll_view_->vertical_scroll_bar() != NULL);
+  EXPECT_TRUE(scroll_view_->vertical_scroll_bar()->visible());
 }
 
 // Verifies the header scrolls horizontally with the content.
 TEST_F(ScrollViewTest, HeaderScrollsWithContent) {
-  ScrollViewTestApi test_api(&scroll_view_);
+  ScrollViewTestApi test_api(scroll_view_.get());
   CustomView* contents = new CustomView;
-  scroll_view_.SetContents(contents);
+  scroll_view_->SetContents(contents);
   contents->SetPreferredSize(gfx::Size(500, 500));
 
   CustomView* header = new CustomView;
-  scroll_view_.SetHeader(header);
+  scroll_view_->SetHeader(header);
   header->SetPreferredSize(gfx::Size(500, 20));
 
-  scroll_view_.SetBoundsRect(gfx::Rect(0, 0, 100, 100));
+  scroll_view_->SetBoundsRect(gfx::Rect(0, 0, 100, 100));
   EXPECT_EQ("0,0", test_api.IntegralViewOffset().ToString());
   EXPECT_EQ("0,0", header->origin().ToString());
 
   // Scroll the horizontal scrollbar.
-  ASSERT_TRUE(scroll_view_.horizontal_scroll_bar());
-  scroll_view_.ScrollToPosition(test_api.GetBaseScrollBar(HORIZONTAL), 1);
+  ASSERT_TRUE(scroll_view_->horizontal_scroll_bar());
+  scroll_view_->ScrollToPosition(test_api.GetBaseScrollBar(HORIZONTAL), 1);
   EXPECT_EQ("-1,0", test_api.IntegralViewOffset().ToString());
   EXPECT_EQ("-1,0", header->origin().ToString());
 
   // Scrolling the vertical scrollbar shouldn't effect the header.
-  ASSERT_TRUE(scroll_view_.vertical_scroll_bar());
-  scroll_view_.ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), 1);
+  ASSERT_TRUE(scroll_view_->vertical_scroll_bar());
+  scroll_view_->ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), 1);
   EXPECT_EQ("-1,-1", test_api.IntegralViewOffset().ToString());
   EXPECT_EQ("-1,0", header->origin().ToString());
 }
 
 // Verifies ScrollRectToVisible() on the child works.
 TEST_F(ScrollViewTest, ScrollRectToVisible) {
-  ScrollViewTestApi test_api(&scroll_view_);
+  ScrollViewTestApi test_api(scroll_view_.get());
   CustomView* contents = new CustomView;
-  scroll_view_.SetContents(contents);
+  scroll_view_->SetContents(contents);
   contents->SetPreferredSize(gfx::Size(500, 1000));
 
-  scroll_view_.SetBoundsRect(gfx::Rect(0, 0, 100, 100));
-  scroll_view_.Layout();
+  scroll_view_->SetBoundsRect(gfx::Rect(0, 0, 100, 100));
+  scroll_view_->Layout();
   EXPECT_EQ("0,0", test_api.IntegralViewOffset().ToString());
 
   // Scroll to y=405 height=10, this should make the y position of the content
@@ -625,7 +630,7 @@
   const int viewport_height = test_api.contents_viewport()->height();
 
   // Expect there to be a horizontal scrollbar, making the viewport shorter.
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutHeight(), viewport_height);
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutHeight(), viewport_height);
 
   gfx::ScrollOffset offset = test_api.CurrentOffset();
   EXPECT_EQ(415 - viewport_height, offset.y());
@@ -637,17 +642,17 @@
 
 // Verifies that child scrolls into view when it's focused.
 TEST_F(ScrollViewTest, ScrollChildToVisibleOnFocus) {
-  ScrollViewTestApi test_api(&scroll_view_);
+  ScrollViewTestApi test_api(scroll_view_.get());
   CustomView* contents = new CustomView;
-  scroll_view_.SetContents(contents);
+  scroll_view_->SetContents(contents);
   contents->SetPreferredSize(gfx::Size(500, 1000));
   FixedView* child = new FixedView;
   child->SetPreferredSize(gfx::Size(10, 10));
   child->SetPosition(gfx::Point(0, 405));
   contents->AddChildView(child);
 
-  scroll_view_.SetBoundsRect(gfx::Rect(0, 0, 100, 100));
-  scroll_view_.Layout();
+  scroll_view_->SetBoundsRect(gfx::Rect(0, 0, 100, 100));
+  scroll_view_->Layout();
   EXPECT_EQ(gfx::Point(), test_api.IntegralViewOffset());
 
   // Set focus to the child control. This should cause the control to scroll to
@@ -657,7 +662,7 @@
   const int viewport_height = test_api.contents_viewport()->height();
 
   // Expect there to be a horizontal scrollbar, making the viewport shorter.
-  EXPECT_EQ(100 - scroll_view_.GetScrollBarLayoutHeight(), viewport_height);
+  EXPECT_EQ(100 - scroll_view_->GetScrollBarLayoutHeight(), viewport_height);
 
   gfx::ScrollOffset offset = test_api.CurrentOffset();
   EXPECT_EQ(415 - viewport_height, offset.y());
@@ -666,138 +671,138 @@
 // Verifies ClipHeightTo() uses the height of the content when it is between the
 // minimum and maximum height values.
 TEST_F(ScrollViewTest, ClipHeightToNormalContentHeight) {
-  scroll_view_.ClipHeightTo(kMinHeight, kMaxHeight);
+  scroll_view_->ClipHeightTo(kMinHeight, kMaxHeight);
 
   const int kNormalContentHeight = 75;
-  scroll_view_.SetContents(
+  scroll_view_->SetContents(
       new views::StaticSizedView(gfx::Size(kWidth, kNormalContentHeight)));
 
   EXPECT_EQ(gfx::Size(kWidth, kNormalContentHeight),
-            scroll_view_.GetPreferredSize());
+            scroll_view_->GetPreferredSize());
 
-  scroll_view_.SizeToPreferredSize();
-  scroll_view_.Layout();
+  scroll_view_->SizeToPreferredSize();
+  scroll_view_->Layout();
 
   EXPECT_EQ(gfx::Size(kWidth, kNormalContentHeight),
-            scroll_view_.contents()->size());
-  EXPECT_EQ(gfx::Size(kWidth, kNormalContentHeight), scroll_view_.size());
+            scroll_view_->contents()->size());
+  EXPECT_EQ(gfx::Size(kWidth, kNormalContentHeight), scroll_view_->size());
 }
 
 // Verifies ClipHeightTo() uses the minimum height when the content is shorter
 // than the minimum height value.
 TEST_F(ScrollViewTest, ClipHeightToShortContentHeight) {
-  scroll_view_.ClipHeightTo(kMinHeight, kMaxHeight);
+  scroll_view_->ClipHeightTo(kMinHeight, kMaxHeight);
 
   const int kShortContentHeight = 10;
   View* contents =
       new views::StaticSizedView(gfx::Size(kWidth, kShortContentHeight));
-  scroll_view_.SetContents(contents);
+  scroll_view_->SetContents(contents);
 
-  EXPECT_EQ(gfx::Size(kWidth, kMinHeight), scroll_view_.GetPreferredSize());
+  EXPECT_EQ(gfx::Size(kWidth, kMinHeight), scroll_view_->GetPreferredSize());
 
-  scroll_view_.SizeToPreferredSize();
-  scroll_view_.Layout();
+  scroll_view_->SizeToPreferredSize();
+  scroll_view_->Layout();
 
   // Layered scrolling requires the contents to fill the viewport.
   if (contents->layer()) {
-    EXPECT_EQ(gfx::Size(kWidth, kMinHeight), scroll_view_.contents()->size());
+    EXPECT_EQ(gfx::Size(kWidth, kMinHeight), scroll_view_->contents()->size());
   } else {
     EXPECT_EQ(gfx::Size(kWidth, kShortContentHeight),
-              scroll_view_.contents()->size());
+              scroll_view_->contents()->size());
   }
-  EXPECT_EQ(gfx::Size(kWidth, kMinHeight), scroll_view_.size());
+  EXPECT_EQ(gfx::Size(kWidth, kMinHeight), scroll_view_->size());
 }
 
 // Verifies ClipHeightTo() uses the maximum height when the content is longer
 // thamn the maximum height value.
 TEST_F(ScrollViewTest, ClipHeightToTallContentHeight) {
-  scroll_view_.ClipHeightTo(kMinHeight, kMaxHeight);
+  scroll_view_->ClipHeightTo(kMinHeight, kMaxHeight);
 
   const int kTallContentHeight = 1000;
-  scroll_view_.SetContents(
+  scroll_view_->SetContents(
       new views::StaticSizedView(gfx::Size(kWidth, kTallContentHeight)));
 
-  EXPECT_EQ(gfx::Size(kWidth, kMaxHeight), scroll_view_.GetPreferredSize());
+  EXPECT_EQ(gfx::Size(kWidth, kMaxHeight), scroll_view_->GetPreferredSize());
 
-  scroll_view_.SizeToPreferredSize();
-  scroll_view_.Layout();
+  scroll_view_->SizeToPreferredSize();
+  scroll_view_->Layout();
 
   // The width may be less than kWidth if the scroll bar takes up some width.
-  EXPECT_GE(kWidth, scroll_view_.contents()->width());
-  EXPECT_EQ(kTallContentHeight, scroll_view_.contents()->height());
-  EXPECT_EQ(gfx::Size(kWidth, kMaxHeight), scroll_view_.size());
+  EXPECT_GE(kWidth, scroll_view_->contents()->width());
+  EXPECT_EQ(kTallContentHeight, scroll_view_->contents()->height());
+  EXPECT_EQ(gfx::Size(kWidth, kMaxHeight), scroll_view_->size());
 }
 
 // Verifies that when ClipHeightTo() produces a scrollbar, it reduces the width
 // of the inner content of the ScrollView.
 TEST_F(ScrollViewTest, ClipHeightToScrollbarUsesWidth) {
-  scroll_view_.ClipHeightTo(kMinHeight, kMaxHeight);
+  scroll_view_->ClipHeightTo(kMinHeight, kMaxHeight);
 
   // Create a view that will be much taller than it is wide.
-  scroll_view_.SetContents(new views::ProportionallySizedView(1000));
+  scroll_view_->SetContents(new views::ProportionallySizedView(1000));
 
   // Without any width, it will default to 0,0 but be overridden by min height.
-  scroll_view_.SizeToPreferredSize();
-  EXPECT_EQ(gfx::Size(0, kMinHeight), scroll_view_.GetPreferredSize());
+  scroll_view_->SizeToPreferredSize();
+  EXPECT_EQ(gfx::Size(0, kMinHeight), scroll_view_->GetPreferredSize());
 
-  gfx::Size new_size(kWidth, scroll_view_.GetHeightForWidth(kWidth));
-  scroll_view_.SetSize(new_size);
-  scroll_view_.Layout();
+  gfx::Size new_size(kWidth, scroll_view_->GetHeightForWidth(kWidth));
+  scroll_view_->SetSize(new_size);
+  scroll_view_->Layout();
 
-  int expected_width = kWidth - scroll_view_.GetScrollBarLayoutWidth();
-  EXPECT_EQ(scroll_view_.contents()->size().width(), expected_width);
-  EXPECT_EQ(scroll_view_.contents()->size().height(), 1000 * expected_width);
-  EXPECT_EQ(gfx::Size(kWidth, kMaxHeight), scroll_view_.size());
+  int expected_width = kWidth - scroll_view_->GetScrollBarLayoutWidth();
+  EXPECT_EQ(scroll_view_->contents()->size().width(), expected_width);
+  EXPECT_EQ(scroll_view_->contents()->size().height(), 1000 * expected_width);
+  EXPECT_EQ(gfx::Size(kWidth, kMaxHeight), scroll_view_->size());
 }
 
 TEST_F(ScrollViewTest, CornerViewVisibility) {
   View* contents = InstallContents();
-  View* corner_view = ScrollViewTestApi(&scroll_view_).corner_view();
+  View* corner_view = ScrollViewTestApi(scroll_view_.get()).corner_view();
 
   contents->SetBounds(0, 0, 200, 200);
-  scroll_view_.Layout();
+  scroll_view_->Layout();
 
   // Corner view should not exist if using overlay scrollbars.
-  if (scroll_view_.vertical_scroll_bar()->OverlapsContent()) {
+  if (scroll_view_->vertical_scroll_bar()->OverlapsContent()) {
     EXPECT_FALSE(corner_view->parent());
     return;
   }
 
   // Corner view should be visible when both scrollbars are visible.
-  EXPECT_EQ(&scroll_view_, corner_view->parent());
+  EXPECT_EQ(scroll_view_.get(), corner_view->parent());
   EXPECT_TRUE(corner_view->visible());
 
   // Corner view should be aligned to the scrollbars.
-  EXPECT_EQ(scroll_view_.vertical_scroll_bar()->x(), corner_view->x());
-  EXPECT_EQ(scroll_view_.horizontal_scroll_bar()->y(), corner_view->y());
-  EXPECT_EQ(scroll_view_.GetScrollBarLayoutWidth(), corner_view->width());
-  EXPECT_EQ(scroll_view_.GetScrollBarLayoutHeight(), corner_view->height());
+  EXPECT_EQ(scroll_view_->vertical_scroll_bar()->x(), corner_view->x());
+  EXPECT_EQ(scroll_view_->horizontal_scroll_bar()->y(), corner_view->y());
+  EXPECT_EQ(scroll_view_->GetScrollBarLayoutWidth(), corner_view->width());
+  EXPECT_EQ(scroll_view_->GetScrollBarLayoutHeight(), corner_view->height());
 
   // Corner view should be removed when only the vertical scrollbar is visible.
   contents->SetBounds(0, 0, 50, 200);
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   EXPECT_FALSE(corner_view->parent());
 
   // ... or when only the horizontal scrollbar is visible.
   contents->SetBounds(0, 0, 200, 50);
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   EXPECT_FALSE(corner_view->parent());
 
   // ... or when no scrollbar is visible.
   contents->SetBounds(0, 0, 50, 50);
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   EXPECT_FALSE(corner_view->parent());
 
   // Corner view should reappear when both scrollbars reappear.
   contents->SetBounds(0, 0, 200, 200);
-  scroll_view_.Layout();
-  EXPECT_EQ(&scroll_view_, corner_view->parent());
+  scroll_view_->Layout();
+  EXPECT_EQ(scroll_view_.get(), corner_view->parent());
   EXPECT_TRUE(corner_view->visible());
 }
 
 TEST_F(ScrollViewTest, ChildWithLayerTest) {
   View* contents = InstallContents();
-  ScrollViewTestApi test_api(&scroll_view_);
+  ScrollViewTestApi test_api(scroll_view_.get());
 
   if (test_api.contents_viewport()->layer())
     return;
@@ -812,7 +817,7 @@
   EXPECT_TRUE(test_api.contents_viewport()->layer()->fills_bounds_opaquely());
 
   // Setting a transparent color should make fills opaquely false.
-  scroll_view_.SetBackgroundColor(SK_ColorTRANSPARENT);
+  scroll_view_->SetBackgroundColor(SK_ColorTRANSPARENT);
   EXPECT_FALSE(test_api.contents_viewport()->layer()->fills_bounds_opaquely());
 
   child->DestroyLayer();
@@ -829,12 +834,12 @@
 // is added to the ScrollView's viewport.
 TEST_F(ScrollViewTest, DontCreateLayerOnViewportIfLayerOnScrollViewCreated) {
   View* contents = InstallContents();
-  ScrollViewTestApi test_api(&scroll_view_);
+  ScrollViewTestApi test_api(scroll_view_.get());
 
   if (test_api.contents_viewport()->layer())
     return;
 
-  scroll_view_.SetPaintToLayer();
+  scroll_view_->SetPaintToLayer();
 
   View* child = new View();
   contents->AddChildView(child);
@@ -853,35 +858,35 @@
   // Size the contents such that vertical scrollbar is needed.
   // Since it is overlaid, the ViewPort size should match the ScrollView.
   contents->SetBounds(0, 0, 50, 400);
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   EXPECT_EQ(100, contents->parent()->width());
   EXPECT_EQ(100, contents->parent()->height());
-  EXPECT_EQ(0, scroll_view_.GetScrollBarLayoutWidth());
-  CheckScrollbarVisibility(scroll_view_, VERTICAL, true);
-  CheckScrollbarVisibility(scroll_view_, HORIZONTAL, false);
+  EXPECT_EQ(0, scroll_view_->GetScrollBarLayoutWidth());
+  CheckScrollbarVisibility(scroll_view_.get(), VERTICAL, true);
+  CheckScrollbarVisibility(scroll_view_.get(), HORIZONTAL, false);
 
   // Size the contents such that horizontal scrollbar is needed.
   contents->SetBounds(0, 0, 400, 50);
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   EXPECT_EQ(100, contents->parent()->width());
   EXPECT_EQ(100, contents->parent()->height());
-  EXPECT_EQ(0, scroll_view_.GetScrollBarLayoutHeight());
-  CheckScrollbarVisibility(scroll_view_, VERTICAL, false);
-  CheckScrollbarVisibility(scroll_view_, HORIZONTAL, true);
+  EXPECT_EQ(0, scroll_view_->GetScrollBarLayoutHeight());
+  CheckScrollbarVisibility(scroll_view_.get(), VERTICAL, false);
+  CheckScrollbarVisibility(scroll_view_.get(), HORIZONTAL, true);
 
   // Both horizontal and vertical scrollbars.
   contents->SetBounds(0, 0, 300, 400);
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   EXPECT_EQ(100, contents->parent()->width());
   EXPECT_EQ(100, contents->parent()->height());
-  EXPECT_EQ(0, scroll_view_.GetScrollBarLayoutWidth());
-  EXPECT_EQ(0, scroll_view_.GetScrollBarLayoutHeight());
-  CheckScrollbarVisibility(scroll_view_, VERTICAL, true);
-  CheckScrollbarVisibility(scroll_view_, HORIZONTAL, true);
+  EXPECT_EQ(0, scroll_view_->GetScrollBarLayoutWidth());
+  EXPECT_EQ(0, scroll_view_->GetScrollBarLayoutHeight());
+  CheckScrollbarVisibility(scroll_view_.get(), VERTICAL, true);
+  CheckScrollbarVisibility(scroll_view_.get(), HORIZONTAL, true);
 
   // Make sure the horizontal and vertical scrollbars don't overlap each other.
-  gfx::Rect vert_bounds = scroll_view_.vertical_scroll_bar()->bounds();
-  gfx::Rect horiz_bounds = scroll_view_.horizontal_scroll_bar()->bounds();
+  gfx::Rect vert_bounds = scroll_view_->vertical_scroll_bar()->bounds();
+  gfx::Rect horiz_bounds = scroll_view_->horizontal_scroll_bar()->bounds();
   EXPECT_EQ(vert_bounds.x(), horiz_bounds.right());
   EXPECT_EQ(horiz_bounds.y(), vert_bounds.bottom());
 
@@ -982,11 +987,11 @@
 // Test that increasing the size of the viewport "below" scrolled content causes
 // the content to scroll up so that it still fills the viewport.
 TEST_F(ScrollViewTest, ConstrainScrollToBounds) {
-  ScrollViewTestApi test_api(&scroll_view_);
+  ScrollViewTestApi test_api(scroll_view_.get());
 
   View* contents = InstallContents();
   contents->SetBoundsRect(gfx::Rect(0, 0, 300, 300));
-  scroll_view_.Layout();
+  scroll_view_->Layout();
 
   EXPECT_EQ(gfx::ScrollOffset(), test_api.CurrentOffset());
 
@@ -996,49 +1001,49 @@
   EXPECT_NE(gfx::ScrollOffset(), fully_scrolled);
 
   // Making the viewport 55 pixels taller should scroll up the same amount.
-  scroll_view_.SetBoundsRect(gfx::Rect(0, 0, 100, 155));
-  scroll_view_.Layout();
+  scroll_view_->SetBoundsRect(gfx::Rect(0, 0, 100, 155));
+  scroll_view_->Layout();
   EXPECT_EQ(fully_scrolled.y() - 55, test_api.CurrentOffset().y());
   EXPECT_EQ(fully_scrolled.x(), test_api.CurrentOffset().x());
 
   // And 77 pixels wider should scroll left. Also make it short again: the y-
   // offset from the last change should remain.
-  scroll_view_.SetBoundsRect(gfx::Rect(0, 0, 177, 100));
-  scroll_view_.Layout();
+  scroll_view_->SetBoundsRect(gfx::Rect(0, 0, 177, 100));
+  scroll_view_->Layout();
   EXPECT_EQ(fully_scrolled.y() - 55, test_api.CurrentOffset().y());
   EXPECT_EQ(fully_scrolled.x() - 77, test_api.CurrentOffset().x());
 }
 
 // Calling Layout on ScrollView should not reset the scroll location.
 TEST_F(ScrollViewTest, ContentScrollNotResetOnLayout) {
-  ScrollViewTestApi test_api(&scroll_view_);
+  ScrollViewTestApi test_api(scroll_view_.get());
 
   CustomView* contents = new CustomView;
   contents->SetPreferredSize(gfx::Size(300, 300));
-  scroll_view_.SetContents(contents);
-  scroll_view_.ClipHeightTo(0, 150);
-  scroll_view_.SizeToPreferredSize();
+  scroll_view_->SetContents(contents);
+  scroll_view_->ClipHeightTo(0, 150);
+  scroll_view_->SizeToPreferredSize();
   // ScrollView preferred width matches that of |contents|, with the height
   // capped at the value we clipped to.
-  EXPECT_EQ(gfx::Size(300, 150), scroll_view_.size());
+  EXPECT_EQ(gfx::Size(300, 150), scroll_view_->size());
 
   // Scroll down.
-  scroll_view_.ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), 25);
+  scroll_view_->ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), 25);
   EXPECT_EQ(25, test_api.CurrentOffset().y());
   // Call Layout; no change to scroll position.
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   EXPECT_EQ(25, test_api.CurrentOffset().y());
   // Change contents of |contents|, call Layout; still no change to scroll
   // position.
   contents->SetPreferredSize(gfx::Size(300, 500));
   contents->InvalidateLayout();
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   EXPECT_EQ(25, test_api.CurrentOffset().y());
 
   // Change |contents| to be shorter than the ScrollView's clipped height.
   // This /will/ change the scroll location due to ConstrainScrollToBounds.
   contents->SetPreferredSize(gfx::Size(300, 50));
-  scroll_view_.Layout();
+  scroll_view_->Layout();
   EXPECT_EQ(0, test_api.CurrentOffset().y());
 }
 
@@ -1046,16 +1051,16 @@
 TEST_F(ScrollViewTest, VerticalOverflowIndicators) {
   const int kWidth = 100;
 
-  ScrollViewTestApi test_api(&scroll_view_);
+  ScrollViewTestApi test_api(scroll_view_.get());
 
   // Set up with vertical scrollbar.
   FixedView* contents = new FixedView;
   contents->SetPreferredSize(gfx::Size(kWidth, kMaxHeight * 5));
-  scroll_view_.SetContents(contents);
-  scroll_view_.ClipHeightTo(0, kMaxHeight);
+  scroll_view_->SetContents(contents);
+  scroll_view_->ClipHeightTo(0, kMaxHeight);
 
   // Make sure the size is set such that no horizontal scrollbar gets shown.
-  scroll_view_.SetSize(
+  scroll_view_->SetSize(
       gfx::Size(kWidth + test_api.GetBaseScrollBar(VERTICAL)->GetThickness(),
                 kMaxHeight));
 
@@ -1064,8 +1069,8 @@
 
   // The vertical scroll bar should be visible and the horizontal scroll bar
   // should not.
-  CheckScrollbarVisibility(scroll_view_, VERTICAL, true);
-  CheckScrollbarVisibility(scroll_view_, HORIZONTAL, false);
+  CheckScrollbarVisibility(scroll_view_.get(), VERTICAL, true);
+  CheckScrollbarVisibility(scroll_view_.get(), HORIZONTAL, false);
 
   // The overflow indicator on the bottom should be visible.
   EXPECT_TRUE(test_api.more_content_bottom()->visible());
@@ -1079,7 +1084,7 @@
 
   // Now scroll the view to someplace in the middle of the scrollable region.
   int offset = kMaxHeight * 2;
-  scroll_view_.ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), offset);
+  scroll_view_->ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), offset);
   EXPECT_EQ(gfx::ScrollOffset(0, offset), test_api.CurrentOffset());
 
   // At this point, both overflow indicators on the top and bottom should be
@@ -1093,7 +1098,7 @@
 
   // Finally scroll the view to end of the scrollable region.
   offset = kMaxHeight * 4;
-  scroll_view_.ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), offset);
+  scroll_view_->ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), offset);
   EXPECT_EQ(gfx::ScrollOffset(0, offset), test_api.CurrentOffset());
 
   // The overflow indicator on the bottom should not be visible.
@@ -1111,15 +1116,15 @@
   const int kWidth = 100;
   const int kHeight = 100;
 
-  ScrollViewTestApi test_api(&scroll_view_);
+  ScrollViewTestApi test_api(scroll_view_.get());
 
   // Set up with horizontal scrollbar.
   FixedView* contents = new FixedView;
   contents->SetPreferredSize(gfx::Size(kWidth * 5, kHeight));
-  scroll_view_.SetContents(contents);
+  scroll_view_->SetContents(contents);
 
   // Make sure the size is set such that no vertical scrollbar gets shown.
-  scroll_view_.SetSize(gfx::Size(
+  scroll_view_->SetSize(gfx::Size(
       kWidth, kHeight + test_api.GetBaseScrollBar(HORIZONTAL)->GetThickness()));
 
   contents->SetBounds(0, 0, kWidth * 5, kHeight);
@@ -1129,8 +1134,8 @@
 
   // The horizontal scroll bar should be visible and the vertical scroll bar
   // should not.
-  CheckScrollbarVisibility(scroll_view_, HORIZONTAL, true);
-  CheckScrollbarVisibility(scroll_view_, VERTICAL, false);
+  CheckScrollbarVisibility(scroll_view_.get(), HORIZONTAL, true);
+  CheckScrollbarVisibility(scroll_view_.get(), VERTICAL, false);
 
   // The overflow indicator on the right should be visible.
   EXPECT_TRUE(test_api.more_content_right()->visible());
@@ -1144,7 +1149,7 @@
 
   // Now scroll the view to someplace in the middle of the scrollable region.
   int offset = kWidth * 2;
-  scroll_view_.ScrollToPosition(test_api.GetBaseScrollBar(HORIZONTAL), offset);
+  scroll_view_->ScrollToPosition(test_api.GetBaseScrollBar(HORIZONTAL), offset);
   EXPECT_EQ(gfx::ScrollOffset(offset, 0), test_api.CurrentOffset());
 
   // At this point, both overflow indicators on the left and right should be
@@ -1158,7 +1163,7 @@
 
   // Finally scroll the view to end of the scrollable region.
   offset = kWidth * 4;
-  scroll_view_.ScrollToPosition(test_api.GetBaseScrollBar(HORIZONTAL), offset);
+  scroll_view_->ScrollToPosition(test_api.GetBaseScrollBar(HORIZONTAL), offset);
   EXPECT_EQ(gfx::ScrollOffset(offset, 0), test_api.CurrentOffset());
 
   // The overflow indicator on the right should not be visible.
@@ -1176,22 +1181,22 @@
   const int kWidth = 100;
   const int kHeight = 100;
 
-  ScrollViewTestApi test_api(&scroll_view_);
+  ScrollViewTestApi test_api(scroll_view_.get());
 
   // Set up with both horizontal and vertical scrollbars.
   FixedView* contents = new FixedView;
   contents->SetPreferredSize(gfx::Size(kWidth * 5, kHeight * 5));
-  scroll_view_.SetContents(contents);
+  scroll_view_->SetContents(contents);
 
   // Make sure the size is set such that both scrollbars are shown.
-  scroll_view_.SetSize(gfx::Size(kWidth, kHeight));
+  scroll_view_->SetSize(gfx::Size(kWidth, kHeight));
 
   // Make sure the initial origin is 0,0
   EXPECT_EQ(gfx::ScrollOffset(0, 0), test_api.CurrentOffset());
 
   // The horizontal and vertical scroll bars should be visible.
-  CheckScrollbarVisibility(scroll_view_, HORIZONTAL, true);
-  CheckScrollbarVisibility(scroll_view_, VERTICAL, true);
+  CheckScrollbarVisibility(scroll_view_.get(), HORIZONTAL, true);
+  CheckScrollbarVisibility(scroll_view_.get(), VERTICAL, true);
 
   // The overflow indicators on the right and bottom should not be visible since
   // they are against the scrollbars.
@@ -1205,8 +1210,8 @@
   // Now scroll the view to someplace in the middle of the horizontal scrollable
   // region.
   int offset_x = kWidth * 2;
-  scroll_view_.ScrollToPosition(test_api.GetBaseScrollBar(HORIZONTAL),
-                                offset_x);
+  scroll_view_->ScrollToPosition(test_api.GetBaseScrollBar(HORIZONTAL),
+                                 offset_x);
   EXPECT_EQ(gfx::ScrollOffset(offset_x, 0), test_api.CurrentOffset());
 
   // Since there is a vertical scrollbar only the overflow indicator on the left
@@ -1220,8 +1225,8 @@
 
   // Next, scroll the view to end of the scrollable region.
   offset_x = kWidth * 4;
-  scroll_view_.ScrollToPosition(test_api.GetBaseScrollBar(HORIZONTAL),
-                                offset_x);
+  scroll_view_->ScrollToPosition(test_api.GetBaseScrollBar(HORIZONTAL),
+                                 offset_x);
   EXPECT_EQ(gfx::ScrollOffset(offset_x, 0), test_api.CurrentOffset());
 
   // The overflow indicator on the right should still not be visible.
@@ -1237,7 +1242,7 @@
   EXPECT_FALSE(test_api.more_content_bottom()->visible());
 
   // Return the view back to the horizontal origin.
-  scroll_view_.ScrollToPosition(test_api.GetBaseScrollBar(HORIZONTAL), 0);
+  scroll_view_->ScrollToPosition(test_api.GetBaseScrollBar(HORIZONTAL), 0);
   EXPECT_EQ(gfx::ScrollOffset(0, 0), test_api.CurrentOffset());
 
   // The overflow indicators on the right and bottom should not be visible since
@@ -1253,7 +1258,7 @@
   // Now scroll the view to somplace in the middle of the vertical scrollable
   // region.
   int offset_y = kHeight * 2;
-  scroll_view_.ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), offset_y);
+  scroll_view_->ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), offset_y);
   EXPECT_EQ(gfx::ScrollOffset(0, offset_y), test_api.CurrentOffset());
 
   // Similar to the above, since there is a horizontal scrollbar only the
@@ -1268,7 +1273,7 @@
 
   // Finally, for the vertical test scroll the region all the way to the end.
   offset_y = kHeight * 4;
-  scroll_view_.ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), offset_y);
+  scroll_view_->ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), offset_y);
   EXPECT_EQ(gfx::ScrollOffset(0, offset_y), test_api.CurrentOffset());
 
   // The overflow indicator on the bottom should still not be visible.
@@ -1286,8 +1291,8 @@
   // Back to the horizontal. Scroll all the way to the end in the horizontal
   // direction.
   offset_x = kWidth * 4;
-  scroll_view_.ScrollToPosition(test_api.GetBaseScrollBar(HORIZONTAL),
-                                offset_x);
+  scroll_view_->ScrollToPosition(test_api.GetBaseScrollBar(HORIZONTAL),
+                                 offset_x);
   EXPECT_EQ(gfx::ScrollOffset(offset_x, offset_y), test_api.CurrentOffset());
 
   // The overflow indicator on the bottom and right should still not be visible.
@@ -1302,19 +1307,19 @@
 TEST_F(ScrollViewTest, VerticalWithHeaderOverflowIndicators) {
   const int kWidth = 100;
 
-  ScrollViewTestApi test_api(&scroll_view_);
+  ScrollViewTestApi test_api(scroll_view_.get());
 
   // Set up with vertical scrollbar and a header.
   FixedView* contents = new FixedView;
   CustomView* header = new CustomView;
   contents->SetPreferredSize(gfx::Size(kWidth, kMaxHeight * 5));
-  scroll_view_.SetContents(contents);
+  scroll_view_->SetContents(contents);
   header->SetPreferredSize(gfx::Size(10, 20));
-  scroll_view_.SetHeader(header);
-  scroll_view_.ClipHeightTo(0, kMaxHeight + header->height());
+  scroll_view_->SetHeader(header);
+  scroll_view_->ClipHeightTo(0, kMaxHeight + header->height());
 
   // Make sure the size is set such that no horizontal scrollbar gets shown.
-  scroll_view_.SetSize(
+  scroll_view_->SetSize(
       gfx::Size(kWidth + test_api.GetBaseScrollBar(VERTICAL)->GetThickness(),
                 kMaxHeight + header->height()));
 
@@ -1323,8 +1328,8 @@
 
   // The vertical scroll bar should be visible and the horizontal scroll bar
   // should not.
-  CheckScrollbarVisibility(scroll_view_, VERTICAL, true);
-  CheckScrollbarVisibility(scroll_view_, HORIZONTAL, false);
+  CheckScrollbarVisibility(scroll_view_.get(), VERTICAL, true);
+  CheckScrollbarVisibility(scroll_view_.get(), HORIZONTAL, false);
 
   // The overflow indicator on the bottom should be visible.
   EXPECT_TRUE(test_api.more_content_bottom()->visible());
@@ -1338,7 +1343,7 @@
 
   // Now scroll the view to someplace in the middle of the scrollable region.
   int offset = kMaxHeight * 2;
-  scroll_view_.ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), offset);
+  scroll_view_->ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), offset);
   EXPECT_EQ(gfx::ScrollOffset(0, offset), test_api.CurrentOffset());
 
   // At this point, only the overflow indicator on the bottom should be visible
@@ -1353,7 +1358,7 @@
 
   // Finally scroll the view to end of the scrollable region.
   offset = test_api.GetBaseScrollBar(VERTICAL)->GetMaxPosition();
-  scroll_view_.ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), offset);
+  scroll_view_->ScrollToPosition(test_api.GetBaseScrollBar(VERTICAL), offset);
   EXPECT_EQ(gfx::ScrollOffset(0, offset), test_api.CurrentOffset());
 
   // The overflow indicator on the bottom should not be visible now.
diff --git a/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc b/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc
index 082ea64..f499e20 100644
--- a/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc
+++ b/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc
@@ -32,7 +32,10 @@
 
 class TabbedPaneTest : public ViewsTestBase {
  public:
-  TabbedPaneTest() {
+  TabbedPaneTest() = default;
+
+  void SetUp() override {
+    ViewsTestBase::SetUp();
     tabbed_pane_ = std::make_unique<TabbedPane>();
     tabbed_pane_->set_owned_by_client();
   }