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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 10544185: Order the script badges in the location bar consistently (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: revert scoped_ptr change, rebase Created 8 years, 6 months 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
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 return; 1021 return;
1022 1022
1023 // Remember the previous visibility of the page actions so that we can 1023 // Remember the previous visibility of the page actions so that we can
1024 // notify when this changes. 1024 // notify when this changes.
1025 std::map<ExtensionAction*, bool> old_visibility; 1025 std::map<ExtensionAction*, bool> old_visibility;
1026 for (PageActionViews::const_iterator i(page_action_views_.begin()); 1026 for (PageActionViews::const_iterator i(page_action_views_.begin());
1027 i != page_action_views_.end(); ++i) { 1027 i != page_action_views_.end(); ++i) {
1028 old_visibility[(*i)->image_view()->page_action()] = (*i)->visible(); 1028 old_visibility[(*i)->image_view()->page_action()] = (*i)->visible();
1029 } 1029 }
1030 1030
1031 std::vector<ExtensionAction*> page_actions; 1031 std::vector<ExtensionAction*> new_page_actions;
1032 1032
1033 TabContents* tab_contents = GetTabContents(); 1033 TabContents* tab_contents = GetTabContents();
1034 if (tab_contents) { 1034 if (tab_contents) {
1035 extensions::LocationBarController* controller = 1035 extensions::LocationBarController* controller =
1036 tab_contents->extension_tab_helper()->location_bar_controller(); 1036 tab_contents->extension_tab_helper()->location_bar_controller();
1037 page_actions.swap(*controller->GetCurrentActions()); 1037 new_page_actions = controller->GetCurrentActions();
1038 } 1038 }
1039 1039
1040 // On startup we sometimes haven't loaded any extensions. This makes sure 1040 // On startup we sometimes haven't loaded any extensions. This makes sure
1041 // we catch up when the extensions (and any page actions) load. 1041 // we catch up when the extensions (and any page actions) load.
1042 if (page_actions.size() != page_action_views_.size()) { 1042 if (page_actions_ != new_page_actions) {
1043 page_actions_.swap(new_page_actions);
1043 DeletePageActionViews(); // Delete the old views (if any). 1044 DeletePageActionViews(); // Delete the old views (if any).
1044 1045
1045 page_action_views_.resize(page_actions.size()); 1046 page_action_views_.resize(page_actions_.size());
1046 View* right_anchor = chrome_to_mobile_view_; 1047 View* right_anchor = chrome_to_mobile_view_;
1047 if (!right_anchor) 1048 if (!right_anchor)
1048 right_anchor = star_view_; 1049 right_anchor = star_view_;
1049 if (!right_anchor) 1050 if (!right_anchor)
1050 right_anchor = action_box_button_view_; 1051 right_anchor = action_box_button_view_;
1051 DCHECK(right_anchor); 1052 DCHECK(right_anchor);
1052 1053
1053 // Add the page actions in reverse order, so that the child views are 1054 // Add the page actions in reverse order, so that the child views are
1054 // inserted in left-to-right order for accessibility. 1055 // inserted in left-to-right order for accessibility.
1055 for (int i = page_actions.size() - 1; i >= 0; --i) { 1056 for (int i = page_actions_.size() - 1; i >= 0; --i) {
1056 page_action_views_[i] = new PageActionWithBadgeView( 1057 page_action_views_[i] = new PageActionWithBadgeView(
1057 delegate_->CreatePageActionImageView(this, page_actions[i])); 1058 delegate_->CreatePageActionImageView(this, page_actions_[i]));
1058 page_action_views_[i]->SetVisible(false); 1059 page_action_views_[i]->SetVisible(false);
1059 AddChildViewAt(page_action_views_[i], GetIndexOf(right_anchor)); 1060 AddChildViewAt(page_action_views_[i], GetIndexOf(right_anchor));
1060 } 1061 }
1061 } 1062 }
1062 1063
1063 WebContents* contents = GetWebContentsFromDelegate(delegate_); 1064 WebContents* contents = GetWebContentsFromDelegate(delegate_);
1064 if (!page_action_views_.empty() && contents) { 1065 if (!page_action_views_.empty() && contents) {
1065 Browser* browser = 1066 Browser* browser =
1066 browser::FindBrowserForController(&contents->GetController(), NULL); 1067 browser::FindBrowserForController(&contents->GetController(), NULL);
1067 GURL url = browser->GetActiveWebContents()->GetURL(); 1068 GURL url = browser->GetActiveWebContents()->GetURL();
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 int LocationBarView::GetInternalHeight(bool use_preferred_size) { 1367 int LocationBarView::GetInternalHeight(bool use_preferred_size) {
1367 int total_height = 1368 int total_height =
1368 use_preferred_size ? GetPreferredSize().height() : height(); 1369 use_preferred_size ? GetPreferredSize().height() : height();
1369 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); 1370 return std::max(total_height - (kVerticalEdgeThickness * 2), 0);
1370 } 1371 }
1371 1372
1372 bool LocationBarView::HasValidSuggestText() const { 1373 bool LocationBarView::HasValidSuggestText() const {
1373 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && 1374 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() &&
1374 !suggested_text_view_->text().empty(); 1375 !suggested_text_view_->text().empty();
1375 } 1376 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/location_bar_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698