| 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 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" |
| 6 | 6 |
| 7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/command_updater.h" | 8 #include "chrome/browser/command_updater.h" |
| 9 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 9 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
| 10 #include "grit/generated_resources.h" | 10 #include "grit/generated_resources.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 StarDecoration::StarDecoration(CommandUpdater* command_updater) | 24 StarDecoration::StarDecoration(CommandUpdater* command_updater) |
| 25 : command_updater_(command_updater) { | 25 : command_updater_(command_updater) { |
| 26 SetVisible(true); | 26 SetVisible(true); |
| 27 SetStarred(false); | 27 SetStarred(false); |
| 28 } | 28 } |
| 29 | 29 |
| 30 StarDecoration::~StarDecoration() { | 30 StarDecoration::~StarDecoration() { |
| 31 } | 31 } |
| 32 | 32 |
| 33 void StarDecoration::SetStarred(bool starred) { | 33 void StarDecoration::SetStarred(bool starred) { |
| 34 starred_ = starred; |
| 34 const int image_id = starred ? IDR_STAR_LIT : IDR_STAR; | 35 const int image_id = starred ? IDR_STAR_LIT : IDR_STAR; |
| 35 const int tip_id = starred ? IDS_TOOLTIP_STARRED : IDS_TOOLTIP_STAR; | 36 const int tip_id = starred ? IDS_TOOLTIP_STARRED : IDS_TOOLTIP_STAR; |
| 36 SetImage(OmniboxViewMac::ImageForResource(image_id)); | 37 SetImage(OmniboxViewMac::ImageForResource(image_id)); |
| 37 tooltip_.reset([l10n_util::GetNSStringWithFixup(tip_id) retain]); | 38 tooltip_.reset([l10n_util::GetNSStringWithFixup(tip_id) retain]); |
| 38 } | 39 } |
| 39 | 40 |
| 40 NSPoint StarDecoration::GetBubblePointInFrame(NSRect frame) { | 41 NSPoint StarDecoration::GetBubblePointInFrame(NSRect frame) { |
| 41 const NSRect draw_frame = GetDrawRectInFrame(frame); | 42 const NSRect draw_frame = GetDrawRectInFrame(frame); |
| 42 return NSMakePoint(NSMidX(draw_frame), | 43 return NSMakePoint(NSMidX(draw_frame), |
| 43 NSMaxY(draw_frame) - kStarPointYOffset); | 44 NSMaxY(draw_frame) - kStarPointYOffset); |
| 44 } | 45 } |
| 45 | 46 |
| 46 bool StarDecoration::AcceptsMousePress() { | 47 bool StarDecoration::AcceptsMousePress() { |
| 47 return true; | 48 return true; |
| 48 } | 49 } |
| 49 | 50 |
| 50 bool StarDecoration::OnMousePressed(NSRect frame) { | 51 bool StarDecoration::OnMousePressed(NSRect frame) { |
| 51 command_updater_->ExecuteCommand(IDC_BOOKMARK_PAGE); | 52 command_updater_->ExecuteCommand(IDC_BOOKMARK_PAGE); |
| 52 return true; | 53 return true; |
| 53 } | 54 } |
| 54 | 55 |
| 55 NSString* StarDecoration::GetToolTip() { | 56 NSString* StarDecoration::GetToolTip() { |
| 56 return tooltip_.get(); | 57 return tooltip_.get(); |
| 57 } | 58 } |
| OLD | NEW |