| 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/nsimage_cache_mac.h" |
| 9 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
| 10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 11 #include "base/sys_string_conversions.h" | 12 #include "base/sys_string_conversions.h" |
| 12 #include "chrome/app/chrome_dll_resource.h" | 13 #include "chrome/app/chrome_dll_resource.h" |
| 13 #include "chrome/browser/alternate_nav_url_fetcher.h" | 14 #include "chrome/browser/alternate_nav_url_fetcher.h" |
| 14 #import "chrome/browser/app_controller_mac.h" | 15 #import "chrome/browser/app_controller_mac.h" |
| 15 #import "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" | 16 #import "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" |
| 16 #include "chrome/browser/browser_list.h" | 17 #include "chrome/browser/browser_list.h" |
| 17 #import "chrome/browser/cocoa/autocomplete_text_field.h" | 18 #import "chrome/browser/cocoa/autocomplete_text_field.h" |
| 18 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h" | 19 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h" |
| 19 #include "chrome/browser/cocoa/event_utils.h" | 20 #include "chrome/browser/cocoa/event_utils.h" |
| 21 #import "chrome/browser/cocoa/extensions/extension_action_context_menu.h" |
| 20 #import "chrome/browser/cocoa/extensions/extension_popup_controller.h" | 22 #import "chrome/browser/cocoa/extensions/extension_popup_controller.h" |
| 21 #include "chrome/browser/command_updater.h" | 23 #include "chrome/browser/command_updater.h" |
| 22 #include "chrome/browser/extensions/extension_browser_event_router.h" | 24 #include "chrome/browser/extensions/extension_browser_event_router.h" |
| 23 #include "chrome/browser/extensions/extensions_service.h" | 25 #include "chrome/browser/extensions/extensions_service.h" |
| 24 #include "chrome/browser/extensions/extension_tabs_module.h" | 26 #include "chrome/browser/extensions/extension_tabs_module.h" |
| 25 #include "chrome/browser/profile.h" | 27 #include "chrome/browser/profile.h" |
| 26 #include "chrome/browser/search_engines/template_url.h" | 28 #include "chrome/browser/search_engines/template_url.h" |
| 27 #include "chrome/browser/search_engines/template_url_model.h" | 29 #include "chrome/browser/search_engines/template_url_model.h" |
| 28 #include "chrome/browser/tab_contents/navigation_entry.h" | 30 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 29 #include "chrome/browser/tab_contents/tab_contents.h" | 31 #include "chrome/browser/tab_contents/tab_contents.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 toolbar_model, profile, command_updater, field)), | 94 toolbar_model, profile, command_updater, field)), |
| 93 command_updater_(command_updater), | 95 command_updater_(command_updater), |
| 94 field_(field), | 96 field_(field), |
| 95 disposition_(CURRENT_TAB), | 97 disposition_(CURRENT_TAB), |
| 96 security_image_view_(this, profile, toolbar_model), | 98 security_image_view_(this, profile, toolbar_model), |
| 97 page_action_views_(this, profile, toolbar_model), | 99 page_action_views_(this, profile, toolbar_model), |
| 98 profile_(profile), | 100 profile_(profile), |
| 99 browser_(browser), | 101 browser_(browser), |
| 100 toolbar_model_(toolbar_model), | 102 toolbar_model_(toolbar_model), |
| 101 transition_(PageTransition::TYPED) { | 103 transition_(PageTransition::TYPED) { |
| 104 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
| 105 ContentBlockedImageView* content_blocked_view = |
| 106 new ContentBlockedImageView(static_cast<ContentSettingsType>(i), this, |
| 107 profile_); |
| 108 content_blocked_views_.push_back(content_blocked_view); |
| 109 content_blocked_view->SetVisible(false); |
| 110 } |
| 111 |
| 102 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; | 112 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; |
| 103 [cell setSecurityImageView:&security_image_view_]; | 113 [cell setSecurityImageView:&security_image_view_]; |
| 104 [cell setPageActionViewList:&page_action_views_]; | 114 [cell setPageActionViewList:&page_action_views_]; |
| 115 [cell setContentBlockedViewList:&content_blocked_views_]; |
| 105 | 116 |
| 106 registrar_.Add(this, | 117 registrar_.Add(this, |
| 107 NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, | 118 NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, |
| 108 NotificationService::AllSources()); | 119 NotificationService::AllSources()); |
| 109 } | 120 } |
| 110 | 121 |
| 111 LocationBarViewMac::~LocationBarViewMac() { | 122 LocationBarViewMac::~LocationBarViewMac() { |
| 112 // Disconnect from cell in case it outlives us. | 123 // Disconnect from cell in case it outlives us. |
| 113 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; | 124 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; |
| 114 [cell setPageActionViewList:NULL]; | 125 [cell setPageActionViewList:NULL]; |
| 115 [cell setSecurityImageView:NULL]; | 126 [cell setSecurityImageView:NULL]; |
| 116 } | 127 } |
| 117 | 128 |
| 118 std::wstring LocationBarViewMac::GetInputString() const { | 129 std::wstring LocationBarViewMac::GetInputString() const { |
| 119 return location_input_; | 130 return location_input_; |
| 120 } | 131 } |
| 121 | 132 |
| 122 WindowOpenDisposition LocationBarViewMac::GetWindowOpenDisposition() const { | 133 WindowOpenDisposition LocationBarViewMac::GetWindowOpenDisposition() const { |
| 123 return disposition_; | 134 return disposition_; |
| 124 } | 135 } |
| 125 | 136 |
| 137 // TODO(thakis): Ping shess to verify what he wants to verify. |
| 126 // TODO(shess): Verify that this TODO is TODONE. | 138 // TODO(shess): Verify that this TODO is TODONE. |
| 127 // TODO(rohitrao): Fix this to return different types once autocomplete and | 139 // TODO(rohitrao): Fix this to return different types once autocomplete and |
| 128 // the onmibar are implemented. For now, any URL that comes from the | 140 // the onmibar are implemented. For now, any URL that comes from the |
| 129 // LocationBar has to have been entered by the user, and thus is of type | 141 // LocationBar has to have been entered by the user, and thus is of type |
| 130 // PageTransition::TYPED. | 142 // PageTransition::TYPED. |
| 131 PageTransition::Type LocationBarViewMac::GetPageTransition() const { | 143 PageTransition::Type LocationBarViewMac::GetPageTransition() const { |
| 132 return transition_; | 144 return transition_; |
| 133 } | 145 } |
| 134 | 146 |
| 135 void LocationBarViewMac::AcceptInput() { | 147 void LocationBarViewMac::AcceptInput() { |
| 136 WindowOpenDisposition disposition = | 148 WindowOpenDisposition disposition = |
| 137 event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); | 149 event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]); |
| 138 AcceptInputWithDisposition(disposition); | 150 AcceptInputWithDisposition(disposition); |
| 139 } | 151 } |
| 140 | 152 |
| 141 void LocationBarViewMac::AcceptInputWithDisposition( | 153 void LocationBarViewMac::AcceptInputWithDisposition( |
| 142 WindowOpenDisposition disposition) { | 154 WindowOpenDisposition disposition) { |
| 143 edit_view_->model()->AcceptInput(disposition, false); | 155 edit_view_->model()->AcceptInput(disposition, false); |
| 144 } | 156 } |
| 145 | 157 |
| 146 void LocationBarViewMac::FocusLocation() { | 158 void LocationBarViewMac::FocusLocation() { |
| 147 edit_view_->FocusLocation(); | 159 edit_view_->FocusLocation(); |
| 148 } | 160 } |
| 149 | 161 |
| 150 void LocationBarViewMac::FocusSearch() { | 162 void LocationBarViewMac::FocusSearch() { |
| 151 edit_view_->SetForcedQuery(); | 163 edit_view_->SetForcedQuery(); |
| 152 } | 164 } |
| 153 | 165 |
| 154 void LocationBarViewMac::UpdateContentBlockedIcons() { | 166 void LocationBarViewMac::UpdateContentBlockedIcons() { |
| 155 // TODO(pkasting): Implement. | 167 RefreshContentBlockedViews(); |
| 168 [field_ updateCursorAndToolTipRects]; |
| 169 [field_ setNeedsDisplay:YES]; |
| 156 } | 170 } |
| 157 | 171 |
| 158 void LocationBarViewMac::UpdatePageActions() { | 172 void LocationBarViewMac::UpdatePageActions() { |
| 159 size_t count_before = page_action_views_.Count(); | 173 size_t count_before = page_action_views_.Count(); |
| 160 page_action_views_.RefreshViews(); | 174 page_action_views_.RefreshViews(); |
| 161 [field_ resetFieldEditorFrameIfNeeded]; | 175 [field_ resetFieldEditorFrameIfNeeded]; |
| 162 if (page_action_views_.Count() != count_before) { | 176 if (page_action_views_.Count() != count_before) { |
| 163 NotificationService::current()->Notify( | 177 NotificationService::current()->Notify( |
| 164 NotificationType::EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 178 NotificationType::EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 165 Source<LocationBar>(this), | 179 Source<LocationBar>(this), |
| (...skipping 14 matching lines...) Expand all Loading... |
| 180 | 194 |
| 181 void LocationBarViewMac::SaveStateToContents(TabContents* contents) { | 195 void LocationBarViewMac::SaveStateToContents(TabContents* contents) { |
| 182 // TODO(shess): Why SaveStateToContents vs SaveStateToTab? | 196 // TODO(shess): Why SaveStateToContents vs SaveStateToTab? |
| 183 edit_view_->SaveStateToTab(contents); | 197 edit_view_->SaveStateToTab(contents); |
| 184 } | 198 } |
| 185 | 199 |
| 186 void LocationBarViewMac::Update(const TabContents* contents, | 200 void LocationBarViewMac::Update(const TabContents* contents, |
| 187 bool should_restore_state) { | 201 bool should_restore_state) { |
| 188 SetSecurityIcon(toolbar_model_->GetIcon()); | 202 SetSecurityIcon(toolbar_model_->GetIcon()); |
| 189 page_action_views_.RefreshViews(); | 203 page_action_views_.RefreshViews(); |
| 204 RefreshContentBlockedViews(); |
| 190 // AutocompleteEditView restores state if the tab is non-NULL. | 205 // AutocompleteEditView restores state if the tab is non-NULL. |
| 191 edit_view_->Update(should_restore_state ? contents : NULL); | 206 edit_view_->Update(should_restore_state ? contents : NULL); |
| 192 } | 207 } |
| 193 | 208 |
| 194 void LocationBarViewMac::OnAutocompleteAccept(const GURL& url, | 209 void LocationBarViewMac::OnAutocompleteAccept(const GURL& url, |
| 195 WindowOpenDisposition disposition, | 210 WindowOpenDisposition disposition, |
| 196 PageTransition::Type transition, | 211 PageTransition::Type transition, |
| 197 const GURL& alternate_nav_url) { | 212 const GURL& alternate_nav_url) { |
| 198 if (!url.is_valid()) | 213 if (!url.is_valid()) |
| 199 return; | 214 return; |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 NOTREACHED() << "Unexpected notification"; | 505 NOTREACHED() << "Unexpected notification"; |
| 491 break; | 506 break; |
| 492 } | 507 } |
| 493 } | 508 } |
| 494 | 509 |
| 495 void LocationBarViewMac::PostNotification(const NSString* notification) { | 510 void LocationBarViewMac::PostNotification(const NSString* notification) { |
| 496 [[NSNotificationCenter defaultCenter] postNotificationName:notification | 511 [[NSNotificationCenter defaultCenter] postNotificationName:notification |
| 497 object:[NSValue valueWithPointer:this]]; | 512 object:[NSValue valueWithPointer:this]]; |
| 498 } | 513 } |
| 499 | 514 |
| 515 void LocationBarViewMac::RefreshContentBlockedViews() { |
| 516 const TabContents* tab_contents = browser_->GetSelectedTabContents(); |
| 517 for (ContentBlockedViews::iterator it(content_blocked_views_.begin()); |
| 518 it != content_blocked_views_.end(); |
| 519 ++it) { |
| 520 (*it)->SetVisible((!toolbar_model_->input_in_progress() && tab_contents) ? |
| 521 tab_contents->IsContentBlocked((*it)->settings_type()) : false); |
| 522 } |
| 523 } |
| 524 |
| 500 // LocationBarImageView--------------------------------------------------------- | 525 // LocationBarImageView--------------------------------------------------------- |
| 501 | 526 |
| 502 void LocationBarViewMac::LocationBarImageView::SetImage(NSImage* image) { | 527 void LocationBarViewMac::LocationBarImageView::SetImage(NSImage* image) { |
| 503 image_.reset([image retain]); | 528 image_.reset([image retain]); |
| 504 } | 529 } |
| 505 | 530 |
| 506 void LocationBarViewMac::LocationBarImageView::SetImage(SkBitmap* image) { | 531 void LocationBarViewMac::LocationBarImageView::SetImage(SkBitmap* image) { |
| 507 SetImage(gfx::SkBitmapToNSImage(*image)); | 532 SetImage(gfx::SkBitmapToNSImage(*image)); |
| 508 } | 533 } |
| 509 | 534 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 warning_icon_.reset([rb.GetNSImageNamed(IDR_WARNING) retain]); | 586 warning_icon_.reset([rb.GetNSImageNamed(IDR_WARNING) retain]); |
| 562 } | 587 } |
| 563 SetImage(warning_icon_); | 588 SetImage(warning_icon_); |
| 564 break; | 589 break; |
| 565 default: | 590 default: |
| 566 NOTREACHED(); | 591 NOTREACHED(); |
| 567 break; | 592 break; |
| 568 } | 593 } |
| 569 } | 594 } |
| 570 | 595 |
| 571 bool LocationBarViewMac::SecurityImageView::OnMousePressed() { | 596 void LocationBarViewMac::SecurityImageView::OnMousePressed(NSRect bounds) { |
| 572 TabContents* tab = owner_->GetTabContents(); | 597 TabContents* tab = owner_->GetTabContents(); |
| 573 NavigationEntry* nav_entry = tab->controller().GetActiveEntry(); | 598 NavigationEntry* nav_entry = tab->controller().GetActiveEntry(); |
| 574 if (!nav_entry) { | 599 if (!nav_entry) { |
| 575 NOTREACHED(); | 600 NOTREACHED(); |
| 576 return true; | 601 return; |
| 577 } | 602 } |
| 578 tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true); | 603 tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true); |
| 579 return true; | |
| 580 } | 604 } |
| 581 | 605 |
| 582 // PageActionImageView---------------------------------------------------------- | 606 // PageActionImageView---------------------------------------------------------- |
| 583 | 607 |
| 584 LocationBarViewMac::PageActionImageView::PageActionImageView( | 608 LocationBarViewMac::PageActionImageView::PageActionImageView( |
| 585 LocationBarViewMac* owner, | 609 LocationBarViewMac* owner, |
| 586 Profile* profile, | 610 Profile* profile, |
| 587 ExtensionAction* page_action) | 611 ExtensionAction* page_action) |
| 588 : owner_(owner), | 612 : owner_(owner), |
| 589 profile_(profile), | 613 profile_(profile), |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 } else if (image) { | 649 } else if (image) { |
| 626 return [image size]; | 650 return [image size]; |
| 627 } | 651 } |
| 628 // Default value for image size is undefined when preview is not enabled. | 652 // Default value for image size is undefined when preview is not enabled. |
| 629 NOTREACHED(); | 653 NOTREACHED(); |
| 630 return NSMakeSize(0, 0); | 654 return NSMakeSize(0, 0); |
| 631 } | 655 } |
| 632 | 656 |
| 633 // Overridden from LocationBarImageView. Either notify listeners or show a | 657 // Overridden from LocationBarImageView. Either notify listeners or show a |
| 634 // popup depending on the Page Action. | 658 // popup depending on the Page Action. |
| 635 bool LocationBarViewMac::PageActionImageView::OnMousePressed(NSRect bounds) { | 659 void LocationBarViewMac::PageActionImageView::OnMousePressed(NSRect bounds) { |
| 636 if (current_tab_id_ < 0) { | 660 if (current_tab_id_ < 0) { |
| 637 NOTREACHED() << "No current tab."; | 661 NOTREACHED() << "No current tab."; |
| 638 // We don't want other code to try and handle this click. Returning true | 662 // We don't want other code to try and handle this click. Returning true |
| 639 // prevents this by indicating that we handled it. | 663 // prevents this by indicating that we handled it. |
| 640 return true; | 664 return; |
| 641 } | 665 } |
| 642 | 666 |
| 643 if (page_action_->HasPopup(current_tab_id_)) { | 667 if (page_action_->HasPopup(current_tab_id_)) { |
| 644 AutocompleteTextField* textField = owner_->GetAutocompleteTextField(); | 668 AutocompleteTextField* textField = owner_->GetAutocompleteTextField(); |
| 645 NSWindow* window = [textField window]; | 669 NSWindow* window = [textField window]; |
| 646 NSRect relativeBounds = [[window contentView] convertRect:bounds | 670 NSRect relativeBounds = [[window contentView] convertRect:bounds |
| 647 fromView:textField]; | 671 fromView:textField]; |
| 648 NSPoint arrowPoint = [window convertBaseToScreen:NSMakePoint( | 672 NSPoint arrowPoint = [window convertBaseToScreen:NSMakePoint( |
| 649 NSMinX(relativeBounds), | 673 NSMinX(relativeBounds), |
| 650 NSMinY(relativeBounds))]; | 674 NSMinY(relativeBounds))]; |
| 651 | 675 |
| 652 // Adjust the anchor point to be at the center of the page action icon. | 676 // Adjust the anchor point to be at the center of the page action icon. |
| 653 arrowPoint.x += [GetImage() size].width / 2; | 677 arrowPoint.x += [GetImage() size].width / 2; |
| 654 | 678 |
| 655 [ExtensionPopupController showURL:page_action_->GetPopupUrl(current_tab_id_) | 679 [ExtensionPopupController showURL:page_action_->GetPopupUrl(current_tab_id_) |
| 656 inBrowser:BrowserList::GetLastActive() | 680 inBrowser:BrowserList::GetLastActive() |
| 657 anchoredAt:arrowPoint | 681 anchoredAt:arrowPoint |
| 658 arrowLocation:kTopRight]; | 682 arrowLocation:kTopRight]; |
| 659 } else { | 683 } else { |
| 660 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( | 684 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( |
| 661 profile_, page_action_->extension_id(), page_action_->id(), | 685 profile_, page_action_->extension_id(), page_action_->id(), |
| 662 current_tab_id_, current_url_.spec(), | 686 current_tab_id_, current_url_.spec(), |
| 663 1); | 687 1); |
| 664 } | 688 } |
| 665 return true; | |
| 666 } | 689 } |
| 667 | 690 |
| 668 void LocationBarViewMac::PageActionImageView::OnImageLoaded(SkBitmap* image, | 691 void LocationBarViewMac::PageActionImageView::OnImageLoaded(SkBitmap* image, |
| 669 size_t index) { | 692 size_t index) { |
| 670 // We loaded icons()->size() icons, plus one extra if the Page Action had | 693 // We loaded icons()->size() icons, plus one extra if the Page Action had |
| 671 // a default icon. | 694 // a default icon. |
| 672 int total_icons = page_action_->icon_paths()->size(); | 695 int total_icons = page_action_->icon_paths()->size(); |
| 673 if (!page_action_->default_icon_path().empty()) | 696 if (!page_action_->default_icon_path().empty()) |
| 674 total_icons++; | 697 total_icons++; |
| 675 DCHECK(static_cast<int>(index) < total_icons); | 698 DCHECK(static_cast<int>(index) < total_icons); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 SetToolTip(nil); | 779 SetToolTip(nil); |
| 757 return; | 780 return; |
| 758 } | 781 } |
| 759 SetToolTip(base::SysUTF8ToNSString(tooltip)); | 782 SetToolTip(base::SysUTF8ToNSString(tooltip)); |
| 760 } | 783 } |
| 761 | 784 |
| 762 const NSString* LocationBarViewMac::PageActionImageView::GetToolTip() { | 785 const NSString* LocationBarViewMac::PageActionImageView::GetToolTip() { |
| 763 return tooltip_.get(); | 786 return tooltip_.get(); |
| 764 } | 787 } |
| 765 | 788 |
| 789 NSMenu* LocationBarViewMac::PageActionImageView::GetMenu() { |
| 790 if (!profile_) |
| 791 return nil; |
| 792 ExtensionsService* service = profile_->GetExtensionsService(); |
| 793 if (!service) |
| 794 return nil; |
| 795 Extension* extension = service->GetExtensionById( |
| 796 page_action_->extension_id(), false); |
| 797 DCHECK(extension); |
| 798 if (!extension) |
| 799 return nil; |
| 800 return [[[ExtensionActionContextMenu alloc] |
| 801 initWithExtension:extension profile:profile_] autorelease]; |
| 802 } |
| 803 |
| 766 void LocationBarViewMac::PageActionImageView::Observe( | 804 void LocationBarViewMac::PageActionImageView::Observe( |
| 767 NotificationType type, | 805 NotificationType type, |
| 768 const NotificationSource& source, | 806 const NotificationSource& source, |
| 769 const NotificationDetails& details) { | 807 const NotificationDetails& details) { |
| 770 switch (type.value) { | 808 switch (type.value) { |
| 771 case NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE: { | 809 case NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE: { |
| 772 ExtensionPopupController* popup = [ExtensionPopupController popup]; | 810 ExtensionPopupController* popup = [ExtensionPopupController popup]; |
| 773 if (popup && ![popup isClosing]) | 811 if (popup && ![popup isClosing]) |
| 774 [popup close]; | 812 [popup close]; |
| 775 | 813 |
| 776 break; | 814 break; |
| 777 } | 815 } |
| 778 default: | 816 default: |
| 779 NOTREACHED() << "Unexpected notification"; | 817 NOTREACHED() << "Unexpected notification"; |
| 780 break; | 818 break; |
| 781 } | 819 } |
| 782 } | 820 } |
| 783 | 821 |
| 822 // ContentSettingsImageView----------------------------------------------------- |
| 823 |
| 824 LocationBarViewMac::ContentBlockedImageView::ContentBlockedImageView( |
| 825 ContentSettingsType settings_type, |
| 826 LocationBarViewMac* owner, |
| 827 Profile* profile) |
| 828 : settings_type_(settings_type), |
| 829 owner_(owner), |
| 830 profile_(profile) { |
| 831 // TODO(thakis): We should use pdfs for these icons on OSX. |
| 832 // http://crbug.com/35847 |
| 833 static const int kIconIDs[] = { |
| 834 IDR_BLOCKED_COOKIES, |
| 835 IDR_BLOCKED_IMAGES, |
| 836 IDR_BLOCKED_JAVASCRIPT, |
| 837 IDR_BLOCKED_PLUGINS, |
| 838 IDR_BLOCKED_POPUPS, |
| 839 }; |
| 840 DCHECK_EQ(arraysize(kIconIDs), |
| 841 static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES)); |
| 842 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 843 SetImage(rb.GetNSImageNamed(kIconIDs[settings_type])); |
| 844 |
| 845 static const int kTooltipIDs[] = { |
| 846 IDS_BLOCKED_COOKIES_TITLE, |
| 847 IDS_BLOCKED_IMAGES_TITLE, |
| 848 IDS_BLOCKED_JAVASCRIPT_TITLE, |
| 849 IDS_BLOCKED_PLUGINS_TITLE, |
| 850 IDS_BLOCKED_POPUPS_TOOLTIP, |
| 851 }; |
| 852 DCHECK_EQ(arraysize(kTooltipIDs), |
| 853 static_cast<size_t>(CONTENT_SETTINGS_NUM_TYPES)); |
| 854 SetToolTip(l10n_util::GetNSStringWithFixup(kTooltipIDs[settings_type])); |
| 855 } |
| 856 |
| 857 LocationBarViewMac::ContentBlockedImageView::~ContentBlockedImageView() {} |
| 858 |
| 859 void LocationBarViewMac::ContentBlockedImageView::OnMousePressed(NSRect bounds) |
| 860 { |
| 861 // TODO(thakis): Implement. |
| 862 NOTIMPLEMENTED(); |
| 863 } |
| 864 |
| 865 const NSString* LocationBarViewMac::ContentBlockedImageView::GetToolTip() { |
| 866 return tooltip_.get(); |
| 867 } |
| 868 |
| 869 void LocationBarViewMac::ContentBlockedImageView::SetToolTip(NSString* tooltip) |
| 870 { |
| 871 tooltip_.reset([tooltip retain]); |
| 872 } |
| 873 |
| 874 |
| 784 // PageActionViewList----------------------------------------------------------- | 875 // PageActionViewList----------------------------------------------------------- |
| 785 | 876 |
| 786 void LocationBarViewMac::PageActionViewList::DeleteAll() { | 877 void LocationBarViewMac::PageActionViewList::DeleteAll() { |
| 787 if (!views_.empty()) { | 878 if (!views_.empty()) { |
| 788 STLDeleteContainerPointers(views_.begin(), views_.end()); | 879 STLDeleteContainerPointers(views_.begin(), views_.end()); |
| 789 views_.clear(); | 880 views_.clear(); |
| 790 } | 881 } |
| 791 } | 882 } |
| 792 | 883 |
| 793 void LocationBarViewMac::PageActionViewList::RefreshViews() { | 884 void LocationBarViewMac::PageActionViewList::RefreshViews() { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 ++result; | 934 ++result; |
| 844 } | 935 } |
| 845 return result; | 936 return result; |
| 846 } | 937 } |
| 847 | 938 |
| 848 void LocationBarViewMac::PageActionViewList::OnMousePressed(NSRect iconFrame, | 939 void LocationBarViewMac::PageActionViewList::OnMousePressed(NSRect iconFrame, |
| 849 size_t index) { | 940 size_t index) { |
| 850 ViewAt(index)->OnMousePressed(iconFrame); | 941 ViewAt(index)->OnMousePressed(iconFrame); |
| 851 } | 942 } |
| 852 | 943 |
| OLD | NEW |