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

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: Significant clean up. 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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 } 665 }
666 666
667 void LocationBarViewMac::RefreshPageActionDecorations() { 667 void LocationBarViewMac::RefreshPageActionDecorations() {
668 if (!IsEditable()) { 668 if (!IsEditable()) {
669 DeletePageActionDecorations(); 669 DeletePageActionDecorations();
670 return; 670 return;
671 } 671 }
672 672
673 WebContents* web_contents = GetWebContents(); 673 WebContents* web_contents = GetWebContents();
674 if (!web_contents) { 674 if (!web_contents) {
675 DeletePageActionDecorations(); // Necessary? 675 DeletePageActionDecorations();
676 return; 676 return;
677 } 677 }
678 678
679 std::vector<ExtensionAction*> new_page_actions = 679 std::vector<ExtensionAction*> new_page_actions =
680 extensions::TabHelper::FromWebContents(web_contents)-> 680 extensions::TabHelper::FromWebContents(web_contents)->
681 location_bar_controller()->GetCurrentActions(); 681 location_bar_controller()->GetCurrentActions();
682 682
683 if (new_page_actions != page_actions_) { 683 if (PageActionsDiffer(new_page_actions)) {
684 page_actions_.swap(new_page_actions);
685 DeletePageActionDecorations(); 684 DeletePageActionDecorations();
686 for (size_t i = 0; i < page_actions_.size(); ++i) { 685 for (size_t i = 0; i < new_page_actions.size(); ++i) {
687 page_action_decorations_.push_back( 686 page_action_decorations_.push_back(
688 new PageActionDecoration(this, browser_, page_actions_[i])); 687 new PageActionDecoration(this, browser_, new_page_actions[i]));
689 } 688 }
690 689
691 // Move rightmost extensions to the start. 690 // Move rightmost extensions to the start.
692 std::stable_partition(page_action_decorations_.begin(), 691 std::stable_partition(page_action_decorations_.begin(),
693 page_action_decorations_.end(), 692 page_action_decorations_.end(),
694 PageActionHasBookmarkManagerPrivate); 693 PageActionHasBookmarkManagerPrivate);
695 } 694 }
696 695
697 GURL url = GetToolbarModel()->GetURL(); 696 GURL url = GetToolbarModel()->GetURL();
698 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { 697 for (size_t i = 0; i < page_action_decorations_.size(); ++i) {
699 page_action_decorations_[i]->UpdateVisibility( 698 page_action_decorations_[i]->UpdateVisibility(
700 GetToolbarModel()->input_in_progress() ? NULL : web_contents); 699 GetToolbarModel()->input_in_progress() ? NULL : web_contents);
701 } 700 }
702 } 701 }
703 702
703 bool LocationBarViewMac::PageActionsDiffer(
704 const std::vector<ExtensionAction*>& page_actions) {
705 if (page_action_decorations_.size() != page_actions.size())
706 return true;
707
708 for (size_t index = 0; index < page_actions.size(); ++index) {
709 PageActionDecoration* decoration = page_action_decorations_[index];
710 if (decoration->GetPageAction() != page_actions[index])
711 return true;
712 }
713
714 return false;
715 }
716
704 bool LocationBarViewMac::RefreshContentSettingsDecorations() { 717 bool LocationBarViewMac::RefreshContentSettingsDecorations() {
705 const bool input_in_progress = GetToolbarModel()->input_in_progress(); 718 const bool input_in_progress = GetToolbarModel()->input_in_progress();
706 WebContents* web_contents = input_in_progress ? 719 WebContents* web_contents = input_in_progress ?
707 NULL : browser_->tab_strip_model()->GetActiveWebContents(); 720 NULL : browser_->tab_strip_model()->GetActiveWebContents();
708 bool icons_updated = false; 721 bool icons_updated = false;
709 for (size_t i = 0; i < content_setting_decorations_.size(); ++i) { 722 for (size_t i = 0; i < content_setting_decorations_.size(); ++i) {
710 icons_updated |= 723 icons_updated |=
711 content_setting_decorations_[i]->UpdateFromWebContents(web_contents); 724 content_setting_decorations_[i]->UpdateFromWebContents(web_contents);
712 } 725 }
713 return icons_updated; 726 return icons_updated;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 } 770 }
758 771
759 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() { 772 bool LocationBarViewMac::UpdateMicSearchDecorationVisibility() {
760 bool is_visible = !GetToolbarModel()->input_in_progress() && 773 bool is_visible = !GetToolbarModel()->input_in_progress() &&
761 browser_->search_model()->voice_search_supported(); 774 browser_->search_model()->voice_search_supported();
762 if (mic_search_decoration_->IsVisible() == is_visible) 775 if (mic_search_decoration_->IsVisible() == is_visible)
763 return false; 776 return false;
764 mic_search_decoration_->SetVisible(is_visible); 777 mic_search_decoration_->SetVisible(is_visible);
765 return true; 778 return true;
766 } 779 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698