OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/location_bar_view_mac.h" | 5 #import "chrome/browser/cocoa/location_bar_view_mac.h" |
6 | 6 |
7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/nsimage_cache_mac.h" | 10 #include "base/nsimage_cache_mac.h" |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 [field_ updateCursorAndToolTipRects]; | 485 [field_ updateCursorAndToolTipRects]; |
486 [field_ setNeedsDisplay:YES]; | 486 [field_ setNeedsDisplay:YES]; |
487 break; | 487 break; |
488 } | 488 } |
489 default: | 489 default: |
490 NOTREACHED() << "Unexpected notification"; | 490 NOTREACHED() << "Unexpected notification"; |
491 break; | 491 break; |
492 } | 492 } |
493 } | 493 } |
494 | 494 |
495 void LocationBarViewMac::PostNotification(const NSString* notification) { | 495 void LocationBarViewMac::PostNotification(NSString* notification) { |
496 [[NSNotificationCenter defaultCenter] postNotificationName:notification | 496 [[NSNotificationCenter defaultCenter] postNotificationName:notification |
497 object:[NSValue valueWithPointer:this]]; | 497 object:[NSValue valueWithPointer:this]]; |
498 } | 498 } |
499 | 499 |
500 void LocationBarViewMac::RefreshContentSettingsViews() { | 500 void LocationBarViewMac::RefreshContentSettingsViews() { |
501 const TabContents* tab_contents = browser_->GetSelectedTabContents(); | 501 const TabContents* tab_contents = browser_->GetSelectedTabContents(); |
502 for (ContentSettingViews::iterator it(content_setting_views_.begin()); | 502 for (ContentSettingViews::iterator it(content_setting_views_.begin()); |
503 it != content_setting_views_.end(); | 503 it != content_setting_views_.end(); |
504 ++it) { | 504 ++it) { |
505 (*it)->UpdateFromTabContents( | 505 (*it)->UpdateFromTabContents( |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 SetImage(AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_STAR)); | 618 SetImage(AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_STAR)); |
619 tooltip_.reset( | 619 tooltip_.reset( |
620 [l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_STAR) retain]); | 620 [l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_STAR) retain]); |
621 } | 621 } |
622 } | 622 } |
623 | 623 |
624 void LocationBarViewMac::StarIconView::OnMousePressed(NSRect bounds) { | 624 void LocationBarViewMac::StarIconView::OnMousePressed(NSRect bounds) { |
625 command_updater_->ExecuteCommand(IDC_BOOKMARK_PAGE); | 625 command_updater_->ExecuteCommand(IDC_BOOKMARK_PAGE); |
626 } | 626 } |
627 | 627 |
628 const NSString* LocationBarViewMac::StarIconView::GetToolTip() { | 628 NSString* LocationBarViewMac::StarIconView::GetToolTip() { |
629 return tooltip_.get(); | 629 return tooltip_.get(); |
630 } | 630 } |
631 | 631 |
632 // PageActionImageView---------------------------------------------------------- | 632 // PageActionImageView---------------------------------------------------------- |
633 | 633 |
634 LocationBarViewMac::PageActionImageView::PageActionImageView( | 634 LocationBarViewMac::PageActionImageView::PageActionImageView( |
635 LocationBarViewMac* owner, | 635 LocationBarViewMac* owner, |
636 Profile* profile, | 636 Profile* profile, |
637 ExtensionAction* page_action) | 637 ExtensionAction* page_action) |
638 : owner_(owner), | 638 : owner_(owner), |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 } | 784 } |
785 | 785 |
786 void LocationBarViewMac::PageActionImageView::SetToolTip(std::string tooltip) { | 786 void LocationBarViewMac::PageActionImageView::SetToolTip(std::string tooltip) { |
787 if (tooltip.empty()) { | 787 if (tooltip.empty()) { |
788 SetToolTip(nil); | 788 SetToolTip(nil); |
789 return; | 789 return; |
790 } | 790 } |
791 SetToolTip(base::SysUTF8ToNSString(tooltip)); | 791 SetToolTip(base::SysUTF8ToNSString(tooltip)); |
792 } | 792 } |
793 | 793 |
794 const NSString* LocationBarViewMac::PageActionImageView::GetToolTip() { | 794 NSString* LocationBarViewMac::PageActionImageView::GetToolTip() { |
795 return tooltip_.get(); | 795 return tooltip_.get(); |
796 } | 796 } |
797 | 797 |
798 NSMenu* LocationBarViewMac::PageActionImageView::GetMenu() { | 798 NSMenu* LocationBarViewMac::PageActionImageView::GetMenu() { |
799 if (!profile_) | 799 if (!profile_) |
800 return nil; | 800 return nil; |
801 ExtensionsService* service = profile_->GetExtensionsService(); | 801 ExtensionsService* service = profile_->GetExtensionsService(); |
802 if (!service) | 802 if (!service) |
803 return nil; | 803 return nil; |
804 Extension* extension = service->GetExtensionById( | 804 Extension* extension = service->GetExtensionById( |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 // Open bubble. | 867 // Open bubble. |
868 ContentSettingBubbleModel* model = | 868 ContentSettingBubbleModel* model = |
869 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 869 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
870 tabContents, profile_, | 870 tabContents, profile_, |
871 content_setting_image_model_->get_content_settings_type()); | 871 content_setting_image_model_->get_content_settings_type()); |
872 [[ContentBlockedBubbleController showForModel:model | 872 [[ContentBlockedBubbleController showForModel:model |
873 parentWindow:window | 873 parentWindow:window |
874 anchoredAt:anchor] showWindow:nil]; | 874 anchoredAt:anchor] showWindow:nil]; |
875 } | 875 } |
876 | 876 |
877 const NSString* LocationBarViewMac::ContentSettingImageView::GetToolTip() { | 877 NSString* LocationBarViewMac::ContentSettingImageView::GetToolTip() { |
878 return tooltip_.get(); | 878 return tooltip_.get(); |
879 } | 879 } |
880 | 880 |
881 void LocationBarViewMac::ContentSettingImageView::UpdateFromTabContents( | 881 void LocationBarViewMac::ContentSettingImageView::UpdateFromTabContents( |
882 const TabContents* tab_contents) { | 882 const TabContents* tab_contents) { |
883 content_setting_image_model_->UpdateFromTabContents(tab_contents); | 883 content_setting_image_model_->UpdateFromTabContents(tab_contents); |
884 if (content_setting_image_model_->is_visible()) { | 884 if (content_setting_image_model_->is_visible()) { |
885 // TODO(thakis): We should use pdfs for these icons on OSX. | 885 // TODO(thakis): We should use pdfs for these icons on OSX. |
886 // http://crbug.com/35847 | 886 // http://crbug.com/35847 |
887 SetIcon(content_setting_image_model_->get_icon()); | 887 SetIcon(content_setting_image_model_->get_icon()); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 ++result; | 965 ++result; |
966 } | 966 } |
967 return result; | 967 return result; |
968 } | 968 } |
969 | 969 |
970 void LocationBarViewMac::PageActionViewList::OnMousePressed(NSRect iconFrame, | 970 void LocationBarViewMac::PageActionViewList::OnMousePressed(NSRect iconFrame, |
971 size_t index) { | 971 size_t index) { |
972 ViewAt(index)->OnMousePressed(iconFrame); | 972 ViewAt(index)->OnMousePressed(iconFrame); |
973 } | 973 } |
974 | 974 |
OLD | NEW |