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

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

Issue 789763004: Fix disappearing page actions bug. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor rename. Created 6 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/location_bar_view_mac.h" 5 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 void LocationBarViewMac::UpdatePageActions() { 202 void LocationBarViewMac::UpdatePageActions() {
203 RefreshPageActionDecorations(); 203 RefreshPageActionDecorations();
204 Layout(); 204 Layout();
205 205
206 [field_ updateMouseTracking]; 206 [field_ updateMouseTracking];
207 [field_ setNeedsDisplay:YES]; 207 [field_ setNeedsDisplay:YES];
208 } 208 }
209 209
210 void LocationBarViewMac::InvalidatePageActions() { 210 void LocationBarViewMac::InvalidatePageActions() {
211 DeletePageActionDecorations(); 211 DeletePageActionsAndDecorations();
212 Layout(); 212 Layout();
213 } 213 }
214 214
215 void LocationBarViewMac::UpdateBookmarkStarVisibility() { 215 void LocationBarViewMac::UpdateBookmarkStarVisibility() {
216 star_decoration_->SetVisible(IsStarEnabled()); 216 star_decoration_->SetVisible(IsStarEnabled());
217 } 217 }
218 218
219 bool LocationBarViewMac::ShowPageActionPopup( 219 bool LocationBarViewMac::ShowPageActionPopup(
220 const extensions::Extension* extension, bool grant_active_tab) { 220 const extensions::Extension* extension, bool grant_active_tab) {
221 for (ScopedVector<PageActionDecoration>::iterator iter = 221 for (ScopedVector<PageActionDecoration>::iterator iter =
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { 643 for (size_t i = 0; i < page_action_decorations_.size(); ++i) {
644 if (page_action_decorations_[i]->GetPageAction() == page_action) 644 if (page_action_decorations_[i]->GetPageAction() == page_action)
645 return page_action_decorations_[i]; 645 return page_action_decorations_[i];
646 } 646 }
647 // If |page_action| is the browser action of an extension, no element in 647 // If |page_action| is the browser action of an extension, no element in
648 // |page_action_decorations_| will match. 648 // |page_action_decorations_| will match.
649 NOTREACHED(); 649 NOTREACHED();
650 return NULL; 650 return NULL;
651 } 651 }
652 652
653 void LocationBarViewMac::DeletePageActionDecorations() { 653 void LocationBarViewMac::DeletePageActionsAndDecorations() {
654 // TODO(shess): Deleting these decorations could result in the cell 654 // TODO(shess): Deleting these decorations could result in the cell
655 // refering to them before things are laid out again. Meanwhile, at 655 // refering to them before things are laid out again. Meanwhile, at
656 // least fail safe. 656 // least fail safe.
657 [[field_ cell] clearDecorations]; 657 [[field_ cell] clearDecorations];
658 658
659 page_action_decorations_.clear(); 659 page_action_decorations_.clear();
660 page_actions_.clear();
660 } 661 }
661 662
662 void LocationBarViewMac::OnEditBookmarksEnabledChanged() { 663 void LocationBarViewMac::OnEditBookmarksEnabledChanged() {
663 UpdateBookmarkStarVisibility(); 664 UpdateBookmarkStarVisibility();
664 OnChanged(); 665 OnChanged();
665 } 666 }
666 667
667 void LocationBarViewMac::RefreshPageActionDecorations() { 668 void LocationBarViewMac::RefreshPageActionDecorations() {
668 if (!IsEditable()) { 669 if (!IsEditable()) {
669 DeletePageActionDecorations(); 670 DeletePageActionsAndDecorations();
670 return; 671 return;
671 } 672 }
672 673
673 WebContents* web_contents = GetWebContents(); 674 WebContents* web_contents = GetWebContents();
674 if (!web_contents) { 675 if (!web_contents) {
675 DeletePageActionDecorations(); // Necessary? 676 DeletePageActionsAndDecorations(); // Necessary?
676 return; 677 return;
677 } 678 }
678 679
679 std::vector<ExtensionAction*> new_page_actions = 680 std::vector<ExtensionAction*> new_page_actions =
680 extensions::TabHelper::FromWebContents(web_contents)-> 681 extensions::TabHelper::FromWebContents(web_contents)->
681 location_bar_controller()->GetCurrentActions(); 682 location_bar_controller()->GetCurrentActions();
682 683
683 if (new_page_actions != page_actions_) { 684 if (new_page_actions != page_actions_) {
684 page_actions_.swap(new_page_actions); 685 page_actions_.swap(new_page_actions);
685 DeletePageActionDecorations(); 686 page_action_decorations_.clear();
danduong 2014/12/20 03:21:24 do you have to call [[field_ cell] clearDecoration
erikchen 2014/12/22 20:39:43 Yes, you're right.
686 for (size_t i = 0; i < page_actions_.size(); ++i) { 687 for (size_t i = 0; i < page_actions_.size(); ++i) {
687 page_action_decorations_.push_back( 688 page_action_decorations_.push_back(
688 new PageActionDecoration(this, browser_, page_actions_[i])); 689 new PageActionDecoration(this, browser_, page_actions_[i]));
689 } 690 }
690 691
691 // Move rightmost extensions to the start. 692 // Move rightmost extensions to the start.
692 std::stable_partition(page_action_decorations_.begin(), 693 std::stable_partition(page_action_decorations_.begin(),
693 page_action_decorations_.end(), 694 page_action_decorations_.end(),
694 PageActionHasBookmarkManagerPrivate); 695 PageActionHasBookmarkManagerPrivate);
695 } 696 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 } 758 }
758 759
759 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { 760 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() {
760 bool is_visible = !GetToolbarModel()->input_in_progress() && 761 bool is_visible = !GetToolbarModel()->input_in_progress() &&
761 browser_->search_model()->voice_search_supported(); 762 browser_->search_model()->voice_search_supported();
762 if (mic_search_decoration_->IsVisible() == is_visible) 763 if (mic_search_decoration_->IsVisible() == is_visible)
763 return false; 764 return false;
764 mic_search_decoration_->SetVisible(is_visible); 765 mic_search_decoration_->SetVisible(is_visible);
765 return true; 766 return true;
766 } 767 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698