summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/views/location_bar/page_action_with_badge_view.cc
blob: c0be1c9b096539cac166895ca007fedd13045392 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h"

#include "chrome/browser/extensions/extension_action.h"
#include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
#include "ui/accessibility/ax_view_state.h"
#include "ui/views/layout/fill_layout.h"

PageActionWithBadgeView::PageActionWithBadgeView(
    PageActionImageView* image_view) : image_view_(image_view) {
  AddChildView(image_view_);
  SetLayoutManager(new views::FillLayout());
}

void PageActionWithBadgeView::GetAccessibleState(
    ui::AXViewState* state) {
  state->role = ui::AX_ROLE_GROUP;
}

gfx::Size PageActionWithBadgeView::GetPreferredSize() const {
  return gfx::Size(ExtensionAction::ActionIconSize(),
                   ExtensionAction::ActionIconSize());
}

void PageActionWithBadgeView::UpdateVisibility(content::WebContents* contents) {
  image_view_->UpdateVisibility(contents);
  SetVisible(image_view_->visible());
}

const char* PageActionWithBadgeView::GetClassName() const {
  return "PageActionWithBadgeView";
}