OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/views/location_bar_view.h" | 5 #include "chrome/browser/views/location_bar_view.h" |
6 | 6 |
7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 if (!page_action_image_views_.empty()) { | 648 if (!page_action_image_views_.empty()) { |
649 for (size_t i = 0; i < page_action_image_views_.size(); ++i) | 649 for (size_t i = 0; i < page_action_image_views_.size(); ++i) |
650 RemoveChildView(page_action_image_views_[i]); | 650 RemoveChildView(page_action_image_views_[i]); |
651 STLDeleteContainerPointers(page_action_image_views_.begin(), | 651 STLDeleteContainerPointers(page_action_image_views_.begin(), |
652 page_action_image_views_.end()); | 652 page_action_image_views_.end()); |
653 page_action_image_views_.clear(); | 653 page_action_image_views_.clear(); |
654 } | 654 } |
655 } | 655 } |
656 | 656 |
657 void LocationBarView::RefreshPageActionViews() { | 657 void LocationBarView::RefreshPageActionViews() { |
658 std::vector<PageAction*> page_actions; | 658 std::vector<ContextualAction*> page_actions; |
659 if (profile_->GetExtensionsService()) | 659 if (profile_->GetExtensionsService()) |
660 page_actions = profile_->GetExtensionsService()->GetPageActions(); | 660 page_actions = profile_->GetExtensionsService()->GetPageActions(); |
661 | 661 |
662 // On startup we sometimes haven't loaded any extensions. This makes sure | 662 // On startup we sometimes haven't loaded any extensions. This makes sure |
663 // we catch up when the extensions (and any page actions) load. | 663 // we catch up when the extensions (and any page actions) load. |
664 if (page_actions.size() != page_action_image_views_.size()) { | 664 if (page_actions.size() != page_action_image_views_.size()) { |
665 DeletePageActionViews(); // Delete the old views (if any). | 665 DeletePageActionViews(); // Delete the old views (if any). |
666 | 666 |
667 page_action_image_views_.resize(page_actions.size()); | 667 page_action_image_views_.resize(page_actions.size()); |
668 | 668 |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 ShowInfoBubbleImpl(text, GetColor( | 1185 ShowInfoBubbleImpl(text, GetColor( |
1186 model_->GetSecurityLevel() == ToolbarModel::SECURE, | 1186 model_->GetSecurityLevel() == ToolbarModel::SECURE, |
1187 SECURITY_INFO_BUBBLE_TEXT)); | 1187 SECURITY_INFO_BUBBLE_TEXT)); |
1188 } | 1188 } |
1189 | 1189 |
1190 // PageActionImageView---------------------------------------------------------- | 1190 // PageActionImageView---------------------------------------------------------- |
1191 | 1191 |
1192 LocationBarView::PageActionImageView::PageActionImageView( | 1192 LocationBarView::PageActionImageView::PageActionImageView( |
1193 LocationBarView* owner, | 1193 LocationBarView* owner, |
1194 Profile* profile, | 1194 Profile* profile, |
1195 const PageAction* page_action, | 1195 const ContextualAction* page_action, |
1196 const BubblePositioner* bubble_positioner) | 1196 const BubblePositioner* bubble_positioner) |
1197 : LocationBarImageView(bubble_positioner), | 1197 : LocationBarImageView(bubble_positioner), |
1198 owner_(owner), | 1198 owner_(owner), |
1199 profile_(profile), | 1199 profile_(profile), |
1200 page_action_(page_action), | 1200 page_action_(page_action), |
1201 current_tab_id_(-1), | 1201 current_tab_id_(-1), |
1202 tooltip_(page_action_->name()) { | 1202 tooltip_(page_action_->name()) { |
1203 Extension* extension = profile->GetExtensionsService()->GetExtensionById( | 1203 Extension* extension = profile->GetExtensionsService()->GetExtensionById( |
1204 page_action->extension_id()); | 1204 page_action->extension_id()); |
1205 DCHECK(extension); | 1205 DCHECK(extension); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 owner_->UpdatePageActions(); | 1252 owner_->UpdatePageActions(); |
1253 } | 1253 } |
1254 | 1254 |
1255 void LocationBarView::PageActionImageView::UpdateVisibility( | 1255 void LocationBarView::PageActionImageView::UpdateVisibility( |
1256 TabContents* contents, GURL url) { | 1256 TabContents* contents, GURL url) { |
1257 // Save this off so we can pass it back to the extension when the action gets | 1257 // Save this off so we can pass it back to the extension when the action gets |
1258 // executed. See PageActionImageView::OnMousePressed. | 1258 // executed. See PageActionImageView::OnMousePressed. |
1259 current_tab_id_ = ExtensionTabUtil::GetTabId(contents); | 1259 current_tab_id_ = ExtensionTabUtil::GetTabId(contents); |
1260 current_url_ = url; | 1260 current_url_ = url; |
1261 | 1261 |
1262 const PageActionState* state = contents->GetPageActionState(page_action_); | 1262 const ContextualActionState* state = |
| 1263 contents->GetPageActionState(page_action_); |
1263 bool visible = state != NULL; | 1264 bool visible = state != NULL; |
1264 if (visible) { | 1265 if (visible) { |
1265 // Set the tooltip. | 1266 // Set the tooltip. |
1266 if (state->title().empty()) | 1267 if (state->title().empty()) |
1267 tooltip_ = page_action_->name(); | 1268 tooltip_ = page_action_->name(); |
1268 else | 1269 else |
1269 tooltip_ = state->title(); | 1270 tooltip_ = state->title(); |
1270 // Set the image. | 1271 // Set the image. |
1271 int index = state->icon_index(); | 1272 int index = state->icon_index(); |
1272 // The image index (if not within bounds) will be set to the first image. | 1273 // The image index (if not within bounds) will be set to the first image. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1326 } | 1327 } |
1327 | 1328 |
1328 int LocationBarView::PageActionVisibleCount() { | 1329 int LocationBarView::PageActionVisibleCount() { |
1329 int result = 0; | 1330 int result = 0; |
1330 for (size_t i = 0; i < page_action_image_views_.size(); i++) { | 1331 for (size_t i = 0; i < page_action_image_views_.size(); i++) { |
1331 if (page_action_image_views_[i]->IsVisible()) | 1332 if (page_action_image_views_[i]->IsVisible()) |
1332 ++result; | 1333 ++result; |
1333 } | 1334 } |
1334 return result; | 1335 return result; |
1335 } | 1336 } |
OLD | NEW |