| 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 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 [field_ updateCursorAndToolTipRects]; | 490 [field_ updateCursorAndToolTipRects]; |
| 491 [field_ setNeedsDisplay:YES]; | 491 [field_ setNeedsDisplay:YES]; |
| 492 break; | 492 break; |
| 493 } | 493 } |
| 494 default: | 494 default: |
| 495 NOTREACHED() << "Unexpected notification"; | 495 NOTREACHED() << "Unexpected notification"; |
| 496 break; | 496 break; |
| 497 } | 497 } |
| 498 } | 498 } |
| 499 | 499 |
| 500 void LocationBarViewMac::PostNotification(const NSString* notification) { | 500 void LocationBarViewMac::PostNotification(NSString* notification) { |
| 501 [[NSNotificationCenter defaultCenter] postNotificationName:notification | 501 [[NSNotificationCenter defaultCenter] postNotificationName:notification |
| 502 object:[NSValue valueWithPointer:this]]; | 502 object:[NSValue valueWithPointer:this]]; |
| 503 } | 503 } |
| 504 | 504 |
| 505 void LocationBarViewMac::RefreshContentSettingsViews() { | 505 void LocationBarViewMac::RefreshContentSettingsViews() { |
| 506 const TabContents* tab_contents = browser_->GetSelectedTabContents(); | 506 const TabContents* tab_contents = browser_->GetSelectedTabContents(); |
| 507 for (ContentSettingViews::iterator it(content_setting_views_.begin()); | 507 for (ContentSettingViews::iterator it(content_setting_views_.begin()); |
| 508 it != content_setting_views_.end(); | 508 it != content_setting_views_.end(); |
| 509 ++it) { | 509 ++it) { |
| 510 (*it)->UpdateFromTabContents( | 510 (*it)->UpdateFromTabContents( |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 SetImage(AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_STAR)); | 623 SetImage(AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_STAR)); |
| 624 tooltip_.reset( | 624 tooltip_.reset( |
| 625 [l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_STAR) retain]); | 625 [l10n_util::GetNSStringWithFixup(IDS_TOOLTIP_STAR) retain]); |
| 626 } | 626 } |
| 627 } | 627 } |
| 628 | 628 |
| 629 void LocationBarViewMac::StarIconView::OnMousePressed(NSRect bounds) { | 629 void LocationBarViewMac::StarIconView::OnMousePressed(NSRect bounds) { |
| 630 command_updater_->ExecuteCommand(IDC_BOOKMARK_PAGE); | 630 command_updater_->ExecuteCommand(IDC_BOOKMARK_PAGE); |
| 631 } | 631 } |
| 632 | 632 |
| 633 const NSString* LocationBarViewMac::StarIconView::GetToolTip() { | 633 NSString* LocationBarViewMac::StarIconView::GetToolTip() { |
| 634 return tooltip_.get(); | 634 return tooltip_.get(); |
| 635 } | 635 } |
| 636 | 636 |
| 637 // PageActionImageView---------------------------------------------------------- | 637 // PageActionImageView---------------------------------------------------------- |
| 638 | 638 |
| 639 LocationBarViewMac::PageActionImageView::PageActionImageView( | 639 LocationBarViewMac::PageActionImageView::PageActionImageView( |
| 640 LocationBarViewMac* owner, | 640 LocationBarViewMac* owner, |
| 641 Profile* profile, | 641 Profile* profile, |
| 642 ExtensionAction* page_action) | 642 ExtensionAction* page_action) |
| 643 : owner_(owner), | 643 : owner_(owner), |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 } | 789 } |
| 790 | 790 |
| 791 void LocationBarViewMac::PageActionImageView::SetToolTip(std::string tooltip) { | 791 void LocationBarViewMac::PageActionImageView::SetToolTip(std::string tooltip) { |
| 792 if (tooltip.empty()) { | 792 if (tooltip.empty()) { |
| 793 SetToolTip(nil); | 793 SetToolTip(nil); |
| 794 return; | 794 return; |
| 795 } | 795 } |
| 796 SetToolTip(base::SysUTF8ToNSString(tooltip)); | 796 SetToolTip(base::SysUTF8ToNSString(tooltip)); |
| 797 } | 797 } |
| 798 | 798 |
| 799 const NSString* LocationBarViewMac::PageActionImageView::GetToolTip() { | 799 NSString* LocationBarViewMac::PageActionImageView::GetToolTip() { |
| 800 return tooltip_.get(); | 800 return tooltip_.get(); |
| 801 } | 801 } |
| 802 | 802 |
| 803 NSMenu* LocationBarViewMac::PageActionImageView::GetMenu() { | 803 NSMenu* LocationBarViewMac::PageActionImageView::GetMenu() { |
| 804 if (!profile_) | 804 if (!profile_) |
| 805 return nil; | 805 return nil; |
| 806 ExtensionsService* service = profile_->GetExtensionsService(); | 806 ExtensionsService* service = profile_->GetExtensionsService(); |
| 807 if (!service) | 807 if (!service) |
| 808 return nil; | 808 return nil; |
| 809 Extension* extension = service->GetExtensionById( | 809 Extension* extension = service->GetExtensionById( |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 // Open bubble. | 872 // Open bubble. |
| 873 ContentSettingBubbleModel* model = | 873 ContentSettingBubbleModel* model = |
| 874 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 874 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
| 875 tabContents, profile_, | 875 tabContents, profile_, |
| 876 content_setting_image_model_->get_content_settings_type()); | 876 content_setting_image_model_->get_content_settings_type()); |
| 877 [[ContentBlockedBubbleController showForModel:model | 877 [[ContentBlockedBubbleController showForModel:model |
| 878 parentWindow:window | 878 parentWindow:window |
| 879 anchoredAt:anchor] showWindow:nil]; | 879 anchoredAt:anchor] showWindow:nil]; |
| 880 } | 880 } |
| 881 | 881 |
| 882 const NSString* LocationBarViewMac::ContentSettingImageView::GetToolTip() { | 882 NSString* LocationBarViewMac::ContentSettingImageView::GetToolTip() { |
| 883 return tooltip_.get(); | 883 return tooltip_.get(); |
| 884 } | 884 } |
| 885 | 885 |
| 886 void LocationBarViewMac::ContentSettingImageView::UpdateFromTabContents( | 886 void LocationBarViewMac::ContentSettingImageView::UpdateFromTabContents( |
| 887 const TabContents* tab_contents) { | 887 const TabContents* tab_contents) { |
| 888 content_setting_image_model_->UpdateFromTabContents(tab_contents); | 888 content_setting_image_model_->UpdateFromTabContents(tab_contents); |
| 889 if (content_setting_image_model_->is_visible()) { | 889 if (content_setting_image_model_->is_visible()) { |
| 890 // TODO(thakis): We should use pdfs for these icons on OSX. | 890 // TODO(thakis): We should use pdfs for these icons on OSX. |
| 891 // http://crbug.com/35847 | 891 // http://crbug.com/35847 |
| 892 SetIcon(content_setting_image_model_->get_icon()); | 892 SetIcon(content_setting_image_model_->get_icon()); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 ++result; | 970 ++result; |
| 971 } | 971 } |
| 972 return result; | 972 return result; |
| 973 } | 973 } |
| 974 | 974 |
| 975 void LocationBarViewMac::PageActionViewList::OnMousePressed(NSRect iconFrame, | 975 void LocationBarViewMac::PageActionViewList::OnMousePressed(NSRect iconFrame, |
| 976 size_t index) { | 976 size_t index) { |
| 977 ViewAt(index)->OnMousePressed(iconFrame); | 977 ViewAt(index)->OnMousePressed(iconFrame); |
| 978 } | 978 } |
| 979 | 979 |
| OLD | NEW |