This source file includes following definitions.
- GetAccessibleState
- GetPreferredSize
- Layout
- UpdateVisibility
#include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
#include "chrome/common/extensions/manifest_handlers/icons_handler.h"
#include "ui/accessibility/ax_view_state.h"
using content::WebContents;
PageActionWithBadgeView::PageActionWithBadgeView(
PageActionImageView* image_view) {
image_view_ = image_view;
AddChildView(image_view_);
LocationBarView::InitTouchableLocationBarChildView(this);
}
void PageActionWithBadgeView::GetAccessibleState(
ui::AXViewState* state) {
state->role = ui::AX_ROLE_GROUP;
}
gfx::Size PageActionWithBadgeView::GetPreferredSize() {
return gfx::Size(extensions::IconsInfo::kPageActionIconMaxSize,
extensions::IconsInfo::kPageActionIconMaxSize);
}
void PageActionWithBadgeView::Layout() {
const gfx::ImageSkia& image = image_view()->GetImage();
int y = (image.height() + 1) % 2;
image_view_->SetBounds(0, y, width(), height());
}
void PageActionWithBadgeView::UpdateVisibility(WebContents* contents,
const GURL& url) {
image_view_->UpdateVisibility(contents, url);
SetVisible(image_view_->visible());
}