summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/toolbar_star_toggle.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/views/toolbar_star_toggle.cc')
-rw-r--r--chrome/browser/views/toolbar_star_toggle.cc53
1 files changed, 43 insertions, 10 deletions
diff --git a/chrome/browser/views/toolbar_star_toggle.cc b/chrome/browser/views/toolbar_star_toggle.cc
index 9cd2e7b..6b93067 100644
--- a/chrome/browser/views/toolbar_star_toggle.cc
+++ b/chrome/browser/views/toolbar_star_toggle.cc
@@ -4,12 +4,18 @@
#include "chrome/browser/views/toolbar_star_toggle.h"
+#include "app/l10n_util.h"
#include "app/resource_bundle.h"
+#include "chrome/app/chrome_dll_resource.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_theme_provider.h"
+#include "chrome/browser/bubble_positioner.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/views/browser_dialogs.h"
-#include "chrome/browser/views/toolbar_view.h"
+#include "chrome/browser/view_ids.h"
#include "googleurl/src/gurl.h"
+#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
using base::TimeTicks;
@@ -27,15 +33,42 @@ using base::TimeTicks;
// with the bubble because it has other native windows.
static const int64 kDisallowClickMS = 40;
-ToolbarStarToggle::ToolbarStarToggle(views::ButtonListener* listener,
- ToolbarView* host)
- : ToggleImageButton(listener),
- host_(host),
+ToolbarStarToggle::ToolbarStarToggle(views::ButtonListener* button_listener)
+ : ToggleImageButton(button_listener),
+ profile_(NULL),
+ host_view_(NULL),
+ bubble_positioner_(NULL),
ignore_click_(false) {
}
+void ToolbarStarToggle::Init() {
+ ThemeProvider* tp = profile_->GetThemeProvider();
+
+ set_tag(IDC_BOOKMARK_PAGE);
+ SetTooltipText(l10n_util::GetString(IDS_TOOLTIP_STAR));
+ SetToggledTooltipText(l10n_util::GetString(IDS_TOOLTIP_STARRED));
+ SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_STAR));
+ SetID(VIEW_ID_STAR_BUTTON);
+
+ // Load images.
+ SkColor color = tp->GetColor(BrowserThemeProvider::COLOR_BUTTON_BACKGROUND);
+ SkBitmap* background = tp->GetBitmapNamed(IDR_THEME_BUTTON_BACKGROUND);
+
+ SetImage(views::CustomButton::BS_NORMAL, tp->GetBitmapNamed(IDR_STAR));
+ SetImage(views::CustomButton::BS_HOT, tp->GetBitmapNamed(IDR_STAR_H));
+ SetImage(views::CustomButton::BS_PUSHED, tp->GetBitmapNamed(IDR_STAR_P));
+ SetImage(views::CustomButton::BS_DISABLED, tp->GetBitmapNamed(IDR_STAR_D));
+ SetToggledImage(views::CustomButton::BS_NORMAL,
+ tp->GetBitmapNamed(IDR_STARRED));
+ SetToggledImage(views::CustomButton::BS_HOT,
+ tp->GetBitmapNamed(IDR_STARRED_H));
+ SetToggledImage(views::CustomButton::BS_PUSHED,
+ tp->GetBitmapNamed(IDR_STARRED_P));
+ SetBackground(color, background, tp->GetBitmapNamed(IDR_STAR_MASK));
+}
+
void ToolbarStarToggle::ShowStarBubble(const GURL& url, bool newly_bookmarked) {
- gfx::Rect bounds(host_->GetLocationStackBounds());
+ gfx::Rect bounds(bubble_positioner_->GetLocationStackBounds());
gfx::Point star_location;
views::View::ConvertPointToScreen(this, &star_location);
// The visual center of the star is not centered within the bounds. The star
@@ -49,12 +82,12 @@ void ToolbarStarToggle::ShowStarBubble(const GURL& url, bool newly_bookmarked) {
// order to place the star's central pixel on the right side of the bounds'
// center-line, so that the arrow's center will line up.
//
- // TODO: If the InfoBubble used mirroring transformations maybe this could
- // become symmetric (-1 : 1).
+ // TODO(pkasting): If the InfoBubble used mirroring transformations maybe this
+ // could become symmetric (-1 : 1).
bounds.set_x(star_location.x() + (UILayoutIsRightToLeft() ? -2 : 1));
bounds.set_width(width());
- browser::ShowBookmarkBubbleView(host_->GetWindow(), bounds, this,
- host_->profile(), url, newly_bookmarked);
+ browser::ShowBookmarkBubbleView(host_view_->GetWindow(), bounds, this,
+ profile_, url, newly_bookmarked);
}
bool ToolbarStarToggle::OnMousePressed(const views::MouseEvent& e) {