Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / views / toolbar / test_toolbar_actions_bar_helper_views.cc
blob0e8b71b4b4f36243118ea251af66e37666da1b0a
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/toolbar/test_toolbar_actions_bar_helper.h"
7 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
8 #include "ui/views/view.h"
10 namespace {
12 // The views-specific implementation of the TestToolbarActionsBarHelper, which
13 // creates and owns a BrowserActionsContainer.
14 class TestToolbarActionsBarHelperViews : public TestToolbarActionsBarHelper {
15 public:
16 TestToolbarActionsBarHelperViews(Browser* browser,
17 TestToolbarActionsBarHelperViews* main_bar);
18 ~TestToolbarActionsBarHelperViews() override;
20 private:
21 // TestToolbarActionsBarHelper:
22 ToolbarActionsBar* GetToolbarActionsBar() override;
24 // The parent of the BrowserActionsContainer, which directly owns the
25 // container as part of the views hierarchy.
26 views::View container_parent_;
28 // The created BrowserActionsContainer. Owned by |container_parent_|.
29 BrowserActionsContainer* browser_actions_container_;
31 DISALLOW_COPY_AND_ASSIGN(TestToolbarActionsBarHelperViews);
34 TestToolbarActionsBarHelperViews::TestToolbarActionsBarHelperViews(
35 Browser* browser,
36 TestToolbarActionsBarHelperViews* main_bar)
37 : browser_actions_container_(
38 new BrowserActionsContainer(
39 browser,
40 main_bar ? main_bar->browser_actions_container_ : nullptr)) {
41 // The BrowserActionsContainer expects to have a parent (and be added to the
42 // view hierarchy), so wrap it in a shell view.
43 container_parent_.set_owned_by_client();
44 container_parent_.AddChildView(browser_actions_container_);
47 TestToolbarActionsBarHelperViews::~TestToolbarActionsBarHelperViews() {}
49 ToolbarActionsBar* TestToolbarActionsBarHelperViews::GetToolbarActionsBar() {
50 return browser_actions_container_->toolbar_actions_bar();
53 } // namespace
55 // static
56 scoped_ptr<TestToolbarActionsBarHelper>
57 TestToolbarActionsBarHelper::Create(Browser* browser,
58 TestToolbarActionsBarHelper* main_bar) {
59 return make_scoped_ptr(new TestToolbarActionsBarHelperViews(
60 browser,
61 static_cast<TestToolbarActionsBarHelperViews*>(main_bar)));