OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" | 5 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
6 | 6 |
| 7 #include "chrome/browser/extensions/extension_action.h" |
7 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 8 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
8 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 9 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
9 #include "chrome/common/extensions/manifest_handlers/icons_handler.h" | |
10 #include "ui/accessibility/ax_view_state.h" | 10 #include "ui/accessibility/ax_view_state.h" |
11 | 11 |
12 using content::WebContents; | 12 using content::WebContents; |
13 | 13 |
14 PageActionWithBadgeView::PageActionWithBadgeView( | 14 PageActionWithBadgeView::PageActionWithBadgeView( |
15 PageActionImageView* image_view) { | 15 PageActionImageView* image_view) { |
16 image_view_ = image_view; | 16 image_view_ = image_view; |
17 AddChildView(image_view_); | 17 AddChildView(image_view_); |
18 LocationBarView::InitTouchableLocationBarChildView(this); | 18 LocationBarView::InitTouchableLocationBarChildView(this); |
19 } | 19 } |
20 | 20 |
21 void PageActionWithBadgeView::GetAccessibleState( | 21 void PageActionWithBadgeView::GetAccessibleState( |
22 ui::AXViewState* state) { | 22 ui::AXViewState* state) { |
23 state->role = ui::AX_ROLE_GROUP; | 23 state->role = ui::AX_ROLE_GROUP; |
24 } | 24 } |
25 | 25 |
26 gfx::Size PageActionWithBadgeView::GetPreferredSize() { | 26 gfx::Size PageActionWithBadgeView::GetPreferredSize() { |
27 return gfx::Size(extensions::IconsInfo::kPageActionIconMaxSize, | 27 return gfx::Size(ExtensionAction::kPageActionIconMaxSize, |
28 extensions::IconsInfo::kPageActionIconMaxSize); | 28 ExtensionAction::kPageActionIconMaxSize); |
29 } | 29 } |
30 | 30 |
31 void PageActionWithBadgeView::Layout() { | 31 void PageActionWithBadgeView::Layout() { |
32 // We have 25 pixels of vertical space in the Omnibox to play with, so even | 32 // We have 25 pixels of vertical space in the Omnibox to play with, so even |
33 // sized icons (such as 16x16) have either a 5 or a 4 pixel whitespace | 33 // sized icons (such as 16x16) have either a 5 or a 4 pixel whitespace |
34 // (padding) above and below. It looks better to have the extra pixel above | 34 // (padding) above and below. It looks better to have the extra pixel above |
35 // the icon than below it, so we add a pixel. http://crbug.com/25708. | 35 // the icon than below it, so we add a pixel. http://crbug.com/25708. |
36 const gfx::ImageSkia& image = image_view()->GetImage(); | 36 const gfx::ImageSkia& image = image_view()->GetImage(); |
37 int y = (image.height() + 1) % 2; // Even numbers: 1px padding. Odd: 0px. | 37 int y = (image.height() + 1) % 2; // Even numbers: 1px padding. Odd: 0px. |
38 image_view_->SetBounds(0, y, width(), height()); | 38 image_view_->SetBounds(0, y, width(), height()); |
39 } | 39 } |
40 | 40 |
41 void PageActionWithBadgeView::UpdateVisibility(WebContents* contents, | 41 void PageActionWithBadgeView::UpdateVisibility(WebContents* contents, |
42 const GURL& url) { | 42 const GURL& url) { |
43 image_view_->UpdateVisibility(contents, url); | 43 image_view_->UpdateVisibility(contents, url); |
44 SetVisible(image_view_->visible()); | 44 SetVisible(image_view_->visible()); |
45 } | 45 } |
OLD | NEW |