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

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: Comments from wittman. 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 200 }
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() {
211 DeletePageActionDecorations();
212 Layout();
213 }
214
215 void LocationBarViewMac::UpdateBookmarkStarVisibility() { 210 void LocationBarViewMac::UpdateBookmarkStarVisibility() {
216 star_decoration_->SetVisible(IsStarEnabled()); 211 star_decoration_->SetVisible(IsStarEnabled());
217 } 212 }
218 213
219 bool LocationBarViewMac::ShowPageActionPopup( 214 bool LocationBarViewMac::ShowPageActionPopup(
220 const extensions::Extension* extension, bool grant_active_tab) { 215 const extensions::Extension* extension, bool grant_active_tab) {
221 for (ScopedVector<PageActionDecoration>::iterator iter = 216 for (ScopedVector<PageActionDecoration>::iterator iter =
222 page_action_decorations_.begin(); 217 page_action_decorations_.begin();
223 iter != page_action_decorations_.end(); ++iter) { 218 iter != page_action_decorations_.end(); ++iter) {
224 if ((*iter)->GetExtension() == extension) 219 if ((*iter)->GetExtension() == extension)
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 } 660 }
666 661
667 void LocationBarViewMac::RefreshPageActionDecorations() { 662 void LocationBarViewMac::RefreshPageActionDecorations() {
668 if (!IsEditable()) { 663 if (!IsEditable()) {
669 DeletePageActionDecorations(); 664 DeletePageActionDecorations();
670 return; 665 return;
671 } 666 }
672 667
673 WebContents* web_contents = GetWebContents(); 668 WebContents* web_contents = GetWebContents();
674 if (!web_contents) { 669 if (!web_contents) {
675 DeletePageActionDecorations(); // Necessary? 670 DeletePageActionDecorations();
676 return; 671 return;
677 } 672 }
678 673
679 std::vector<ExtensionAction*> new_page_actions = 674 std::vector<ExtensionAction*> new_page_actions =
680 extensions::TabHelper::FromWebContents(web_contents)-> 675 extensions::TabHelper::FromWebContents(web_contents)->
681 location_bar_controller()->GetCurrentActions(); 676 location_bar_controller()->GetCurrentActions();
682 677
683 if (new_page_actions != page_actions_) { 678 if (PageActionsDiffer(new_page_actions)) {
684 page_actions_.swap(new_page_actions);
685 DeletePageActionDecorations(); 679 DeletePageActionDecorations();
686 for (size_t i = 0; i < page_actions_.size(); ++i) { 680 for (size_t i = 0; i < new_page_actions.size(); ++i) {
687 page_action_decorations_.push_back( 681 page_action_decorations_.push_back(
688 new PageActionDecoration(this, browser_, page_actions_[i])); 682 new PageActionDecoration(this, browser_, new_page_actions[i]));
689 } 683 }
690 684
691 // Move rightmost extensions to the start. 685 // Move rightmost extensions to the start.
692 std::stable_partition(page_action_decorations_.begin(), 686 std::stable_partition(page_action_decorations_.begin(),
693 page_action_decorations_.end(), 687 page_action_decorations_.end(),
694 PageActionHasBookmarkManagerPrivate); 688 PageActionHasBookmarkManagerPrivate);
695 } 689 }
696 690
697 GURL url = GetToolbarModel()->GetURL(); 691 GURL url = GetToolbarModel()->GetURL();
698 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { 692 for (size_t i = 0; i < page_action_decorations_.size(); ++i) {
699 page_action_decorations_[i]->UpdateVisibility( 693 page_action_decorations_[i]->UpdateVisibility(
700 GetToolbarModel()->input_in_progress() ? NULL : web_contents); 694 GetToolbarModel()->input_in_progress() ? NULL : web_contents);
701 } 695 }
702 } 696 }
703 697
698 bool LocationBarViewMac::PageActionsDiffer(
699 const std::vector<ExtensionAction*>& page_actions) const {
700 if (page_action_decorations_.size() != page_actions.size())
701 return true;
702
703 for (size_t index = 0; index < page_actions.size(); ++index) {
704 PageActionDecoration* decoration = page_action_decorations_[index];
705 if (decoration->GetPageAction() != page_actions[index])
706 return true;
707 }
708
709 return false;
710 }
711
704 bool LocationBarViewMac::RefreshContentSettingsDecorations() { 712 bool LocationBarViewMac::RefreshContentSettingsDecorations() {
705 const bool input_in_progress = GetToolbarModel()->input_in_progress(); 713 const bool input_in_progress = GetToolbarModel()->input_in_progress();
706 WebContents* web_contents = input_in_progress ? 714 WebContents* web_contents = input_in_progress ?
707 NULL : browser_->tab_strip_model()->GetActiveWebContents(); 715 NULL : browser_->tab_strip_model()->GetActiveWebContents();
708 bool icons_updated = false; 716 bool icons_updated = false;
709 for (size_t i = 0; i < content_setting_decorations_.size(); ++i) { 717 for (size_t i = 0; i < content_setting_decorations_.size(); ++i) {
710 icons_updated |= 718 icons_updated |=
711 content_setting_decorations_[i]->UpdateFromWebContents(web_contents); 719 content_setting_decorations_[i]->UpdateFromWebContents(web_contents);
712 } 720 }
713 return icons_updated; 721 return icons_updated;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 } 765 }
758 766
759 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { 767 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() {
760 bool is_visible = !GetToolbarModel()->input_in_progress() && 768 bool is_visible = !GetToolbarModel()->input_in_progress() &&
761 browser_->search_model()->voice_search_supported(); 769 browser_->search_model()->voice_search_supported();
762 if (mic_search_decoration_->IsVisible() == is_visible) 770 if (mic_search_decoration_->IsVisible() == is_visible)
763 return false; 771 return false;
764 mic_search_decoration_->SetVisible(is_visible); 772 mic_search_decoration_->SetVisible(is_visible);
765 return true; 773 return true;
766 } 774 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h ('k') | chrome/browser/ui/location_bar/location_bar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698