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