Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: chrome/browser/cocoa/location_bar_view_mac.mm

Issue 508010: [Mac] Fixes a bug where an ExtensionPopupController object's pointer was neve... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 479
480 // PageActionImageView---------------------------------------------------------- 480 // PageActionImageView----------------------------------------------------------
481 481
482 LocationBarViewMac::PageActionImageView::PageActionImageView( 482 LocationBarViewMac::PageActionImageView::PageActionImageView(
483 LocationBarViewMac* owner, 483 LocationBarViewMac* owner,
484 Profile* profile, 484 Profile* profile,
485 ExtensionAction* page_action) 485 ExtensionAction* page_action)
486 : owner_(owner), 486 : owner_(owner),
487 profile_(profile), 487 profile_(profile),
488 page_action_(page_action), 488 page_action_(page_action),
489 popup_controller_(nil),
489 current_tab_id_(-1), 490 current_tab_id_(-1),
490 preview_enabled_(false) { 491 preview_enabled_(false) {
491 Extension* extension = profile->GetExtensionsService()->GetExtensionById( 492 Extension* extension = profile->GetExtensionsService()->GetExtensionById(
492 page_action->extension_id(), false); 493 page_action->extension_id(), false);
493 DCHECK(extension); 494 DCHECK(extension);
494 495
495 // Load all the icons declared in the manifest. This is the contents of the 496 // Load all the icons declared in the manifest. This is the contents of the
496 // icons array, plus the default_icon property, if any. 497 // icons array, plus the default_icon property, if any.
497 std::vector<std::string> icon_paths(*page_action->icon_paths()); 498 std::vector<std::string> icon_paths(*page_action->icon_paths());
498 if (!page_action_->default_icon_path().empty()) 499 if (!page_action_->default_icon_path().empty())
(...skipping 24 matching lines...) Expand all
523 NSWindow* window = [textField window]; 524 NSWindow* window = [textField window];
524 NSRect relativeBounds = [[window contentView] convertRect:bounds 525 NSRect relativeBounds = [[window contentView] convertRect:bounds
525 fromView:textField]; 526 fromView:textField];
526 NSPoint arrowPoint = [window convertBaseToScreen:NSMakePoint( 527 NSPoint arrowPoint = [window convertBaseToScreen:NSMakePoint(
527 NSMinX(relativeBounds), 528 NSMinX(relativeBounds),
528 NSMinY(relativeBounds))]; 529 NSMinY(relativeBounds))];
529 530
530 // Adjust the anchor point to be at the center of the page action icon. 531 // Adjust the anchor point to be at the center of the page action icon.
531 arrowPoint.x += [GetImage() size].width / 2; 532 arrowPoint.x += [GetImage() size].width / 2;
532 533
533 popupController_ = 534 popup_controller_ =
534 [ExtensionPopupController showURL:page_action_->popup_url() 535 [ExtensionPopupController showURL:page_action_->popup_url()
535 inBrowser:BrowserList::GetLastActive() 536 inBrowser:BrowserList::GetLastActive()
536 anchoredAt:arrowPoint 537 anchoredAt:arrowPoint
537 arrowLocation:kTopRight]; 538 arrowLocation:kTopRight];
538 } else { 539 } else {
539 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( 540 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted(
540 profile_, page_action_->extension_id(), page_action_->id(), 541 profile_, page_action_->extension_id(), page_action_->id(),
541 current_tab_id_, current_url_.spec(), 542 current_tab_id_, current_url_.spec(),
542 1); // TODO(pamg): Add support for middle and right buttons. 543 1); // TODO(pamg): Add support for middle and right buttons.
543 } 544 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 SetVisible(visible); 617 SetVisible(visible);
617 } 618 }
618 619
619 void LocationBarViewMac::PageActionImageView::Observe( 620 void LocationBarViewMac::PageActionImageView::Observe(
620 NotificationType type, 621 NotificationType type,
621 const NotificationSource& source, 622 const NotificationSource& source,
622 const NotificationDetails& details) { 623 const NotificationDetails& details) {
623 switch (type.value) { 624 switch (type.value) {
624 case NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE: 625 case NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE:
625 // If we aren't the host of the popup, then disregard the notification. 626 // If we aren't the host of the popup, then disregard the notification.
626 if (popupController_ && 627 if (popup_controller_ == nil ||
Mark Mentovai 2009/12/21 20:54:32 Same comment about early returns applies here.
Bons 2009/12/21 21:01:41 Done.
627 Details<ExtensionHost>([popupController_ host]) == details) { 628 Details<ExtensionHost>([popup_controller_ host]) != details) {
628 HidePopup(); 629 return;
629 } 630 }
631 HidePopup();
630 break; 632 break;
631 default: 633 default:
632 NOTREACHED() << "Unexpected notification"; 634 NOTREACHED() << "Unexpected notification";
633 break; 635 break;
634 } 636 }
635 } 637 }
636 638
637 void LocationBarViewMac::PageActionImageView::HidePopup() { 639 void LocationBarViewMac::PageActionImageView::HidePopup() {
638 [popupController_ close]; 640 [popup_controller_ close];
639 popupController_ = nil; 641 popup_controller_ = nil;
640 } 642 }
641 643
642 // PageActionViewList----------------------------------------------------------- 644 // PageActionViewList-----------------------------------------------------------
643 645
644 void LocationBarViewMac::PageActionViewList::DeleteAll() { 646 void LocationBarViewMac::PageActionViewList::DeleteAll() {
645 if (!views_.empty()) { 647 if (!views_.empty()) {
646 STLDeleteContainerPointers(views_.begin(), views_.end()); 648 STLDeleteContainerPointers(views_.begin(), views_.end());
647 views_.clear(); 649 views_.clear();
648 } 650 }
649 } 651 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 if (views_[i]->IsVisible()) 724 if (views_[i]->IsVisible())
723 ++result; 725 ++result;
724 } 726 }
725 return result; 727 return result;
726 } 728 }
727 729
728 void LocationBarViewMac::PageActionViewList::OnMousePressed(NSRect iconFrame, 730 void LocationBarViewMac::PageActionViewList::OnMousePressed(NSRect iconFrame,
729 size_t index) { 731 size_t index) {
730 ViewAt(index)->OnMousePressed(iconFrame); 732 ViewAt(index)->OnMousePressed(iconFrame);
731 } 733 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698