OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" | 9 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h" |
10 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" | 10 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // ToolbarActionButtonController: | 29 // ToolbarActionButtonController: |
30 virtual const std::string& GetId() const override { return id_; } | 30 virtual const std::string& GetId() const override { return id_; } |
31 virtual void SetDelegate(ToolbarActionViewDelegate* delegate) override {} | 31 virtual void SetDelegate(ToolbarActionViewDelegate* delegate) override {} |
32 virtual gfx::Image GetIcon(content::WebContents* web_contents) override { | 32 virtual gfx::Image GetIcon(content::WebContents* web_contents) override { |
33 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 33 return ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
34 IDR_BROWSER_ACTION); | 34 IDR_BROWSER_ACTION); |
35 } | 35 } |
36 virtual gfx::ImageSkia GetIconWithBadge() override { | 36 virtual gfx::ImageSkia GetIconWithBadge() override { |
37 return *GetIcon(nullptr).ToImageSkia(); | 37 return *GetIcon(nullptr).ToImageSkia(); |
38 } | 38 } |
| 39 virtual base::string16 GetActionName() const override { |
| 40 return base::ASCIIToUTF16("Component Action"); |
| 41 } |
39 virtual base::string16 GetAccessibleName(content::WebContents* web_contents) | 42 virtual base::string16 GetAccessibleName(content::WebContents* web_contents) |
40 const override { | 43 const override { |
41 return base::ASCIIToUTF16("Component Action"); | 44 return GetActionName(); |
42 } | 45 } |
43 virtual base::string16 GetTooltip(content::WebContents* web_contents) | 46 virtual base::string16 GetTooltip(content::WebContents* web_contents) |
44 const override { | 47 const override { |
45 return GetAccessibleName(web_contents); | 48 return GetActionName(); |
46 } | 49 } |
47 virtual bool IsEnabled(content::WebContents* web_contents) const override { | 50 virtual bool IsEnabled(content::WebContents* web_contents) const override { |
48 return true; | 51 return true; |
49 } | 52 } |
50 virtual bool HasPopup(content::WebContents* web_contents) const override { | 53 virtual bool HasPopup(content::WebContents* web_contents) const override { |
51 return true; | 54 return true; |
52 } | 55 } |
53 virtual void HidePopup() override {} | 56 virtual void HidePopup() override {} |
54 virtual gfx::NativeView GetPopupNativeView() override { return nullptr; } | 57 virtual gfx::NativeView GetPopupNativeView() override { return nullptr; } |
55 virtual bool CanDrag() const override { return false; } | 58 virtual bool CanDrag() const override { return false; } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 browser_actions_container->GetBrowserActionViewAt(0u); | 136 browser_actions_container->GetBrowserActionViewAt(0u); |
134 ASSERT_EQ(kMockId, view->view_controller()->GetId()); | 137 ASSERT_EQ(kMockId, view->view_controller()->GetId()); |
135 MockComponentAction* mock_component_action = | 138 MockComponentAction* mock_component_action = |
136 static_cast<MockComponentAction*>(view->view_controller()); | 139 static_cast<MockComponentAction*>(view->view_controller()); |
137 | 140 |
138 // Test that clicking on the component action works. | 141 // Test that clicking on the component action works. |
139 EXPECT_EQ(0u, mock_component_action->click_count()); | 142 EXPECT_EQ(0u, mock_component_action->click_count()); |
140 view->Activate(); | 143 view->Activate(); |
141 EXPECT_EQ(1u, mock_component_action->click_count()); | 144 EXPECT_EQ(1u, mock_component_action->click_count()); |
142 } | 145 } |
OLD | NEW |