| OLD | NEW |
| 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 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 // Remember the previous visibility of the page actions so that we can | 1144 // Remember the previous visibility of the page actions so that we can |
| 1145 // notify when this changes. | 1145 // notify when this changes. |
| 1146 std::map<ExtensionAction*, bool> old_visibility; | 1146 std::map<ExtensionAction*, bool> old_visibility; |
| 1147 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 1147 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
| 1148 i != page_action_views_.end(); ++i) { | 1148 i != page_action_views_.end(); ++i) { |
| 1149 old_visibility[(*i)->image_view()->page_action()] = (*i)->visible(); | 1149 old_visibility[(*i)->image_view()->page_action()] = (*i)->visible(); |
| 1150 } | 1150 } |
| 1151 | 1151 |
| 1152 std::vector<ExtensionAction*> new_page_actions; | 1152 std::vector<ExtensionAction*> new_page_actions; |
| 1153 | 1153 |
| 1154 TabContents* tab_contents = GetTabContents(); | 1154 WebContents* contents = GetWebContentsFromDelegate(delegate_); |
| 1155 if (tab_contents) { | 1155 if (contents) { |
| 1156 extensions::TabHelper* extensions_tab_helper = |
| 1157 extensions::TabHelper::FromWebContents(contents); |
| 1156 extensions::LocationBarController* controller = | 1158 extensions::LocationBarController* controller = |
| 1157 tab_contents->extension_tab_helper()->location_bar_controller(); | 1159 extensions_tab_helper->location_bar_controller(); |
| 1158 new_page_actions = controller->GetCurrentActions(); | 1160 new_page_actions = controller->GetCurrentActions(); |
| 1159 } | 1161 } |
| 1160 | 1162 |
| 1161 // On startup we sometimes haven't loaded any extensions. This makes sure | 1163 // On startup we sometimes haven't loaded any extensions. This makes sure |
| 1162 // we catch up when the extensions (and any page actions) load. | 1164 // we catch up when the extensions (and any page actions) load. |
| 1163 if (page_actions_ != new_page_actions) { | 1165 if (page_actions_ != new_page_actions) { |
| 1164 page_actions_.swap(new_page_actions); | 1166 page_actions_.swap(new_page_actions); |
| 1165 DeletePageActionViews(); // Delete the old views (if any). | 1167 DeletePageActionViews(); // Delete the old views (if any). |
| 1166 | 1168 |
| 1167 page_action_views_.resize(page_actions_.size()); | 1169 page_action_views_.resize(page_actions_.size()); |
| 1168 View* right_anchor = star_view_; | 1170 View* right_anchor = star_view_; |
| 1169 if (!right_anchor) | 1171 if (!right_anchor) |
| 1170 right_anchor = action_box_button_view_; | 1172 right_anchor = action_box_button_view_; |
| 1171 DCHECK(right_anchor); | 1173 DCHECK(right_anchor); |
| 1172 | 1174 |
| 1173 // Add the page actions in reverse order, so that the child views are | 1175 // Add the page actions in reverse order, so that the child views are |
| 1174 // inserted in left-to-right order for accessibility. | 1176 // inserted in left-to-right order for accessibility. |
| 1175 for (int i = page_actions_.size() - 1; i >= 0; --i) { | 1177 for (int i = page_actions_.size() - 1; i >= 0; --i) { |
| 1176 page_action_views_[i] = new PageActionWithBadgeView( | 1178 page_action_views_[i] = new PageActionWithBadgeView( |
| 1177 delegate_->CreatePageActionImageView(this, page_actions_[i])); | 1179 delegate_->CreatePageActionImageView(this, page_actions_[i])); |
| 1178 page_action_views_[i]->SetVisible(false); | 1180 page_action_views_[i]->SetVisible(false); |
| 1179 AddChildViewAt(page_action_views_[i], GetIndexOf(right_anchor)); | 1181 AddChildViewAt(page_action_views_[i], GetIndexOf(right_anchor)); |
| 1180 } | 1182 } |
| 1181 } | 1183 } |
| 1182 | 1184 |
| 1183 WebContents* contents = GetWebContentsFromDelegate(delegate_); | |
| 1184 if (!page_action_views_.empty() && contents) { | 1185 if (!page_action_views_.empty() && contents) { |
| 1185 Browser* browser = browser::FindBrowserWithWebContents(contents); | 1186 Browser* browser = browser::FindBrowserWithWebContents(contents); |
| 1186 GURL url = chrome::GetActiveWebContents(browser)->GetURL(); | 1187 GURL url = chrome::GetActiveWebContents(browser)->GetURL(); |
| 1187 | 1188 |
| 1188 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 1189 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
| 1189 i != page_action_views_.end(); ++i) { | 1190 i != page_action_views_.end(); ++i) { |
| 1190 (*i)->UpdateVisibility(model_->input_in_progress() ? NULL : contents, | 1191 (*i)->UpdateVisibility(model_->input_in_progress() ? NULL : contents, |
| 1191 url); | 1192 url); |
| 1192 | 1193 |
| 1193 // Check if the visibility of the action changed and notify if it did. | 1194 // Check if the visibility of the action changed and notify if it did. |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 } | 1534 } |
| 1534 | 1535 |
| 1535 void LocationBarView::CleanupFadeAnimation() { | 1536 void LocationBarView::CleanupFadeAnimation() { |
| 1536 // Since we're no longer animating we don't need our layer. | 1537 // Since we're no longer animating we don't need our layer. |
| 1537 SetPaintToLayer(false); | 1538 SetPaintToLayer(false); |
| 1538 // Bubble labels don't need a transparent background anymore. | 1539 // Bubble labels don't need a transparent background anymore. |
| 1539 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); | 1540 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); |
| 1540 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); | 1541 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); |
| 1541 } | 1542 } |
| 1542 #endif // USE_AURA | 1543 #endif // USE_AURA |
| OLD | NEW |