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"
12 // The views-specific implementation of the TestToolbarActionsBarHelper, which
13 // creates and owns a BrowserActionsContainer.
14 class TestToolbarActionsBarHelperViews
: public TestToolbarActionsBarHelper
{
16 TestToolbarActionsBarHelperViews(Browser
* browser
,
17 TestToolbarActionsBarHelperViews
* main_bar
);
18 ~TestToolbarActionsBarHelperViews() override
;
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(
36 TestToolbarActionsBarHelperViews
* main_bar
)
37 : browser_actions_container_(
38 new BrowserActionsContainer(
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();
56 scoped_ptr
<TestToolbarActionsBarHelper
>
57 TestToolbarActionsBarHelper::Create(Browser
* browser
,
58 TestToolbarActionsBarHelper
* main_bar
) {
59 return make_scoped_ptr(new TestToolbarActionsBarHelperViews(
61 static_cast<TestToolbarActionsBarHelperViews
*>(main_bar
)));