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 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 LocationBarView::PageActionImageView::PageActionImageView( | 1177 LocationBarView::PageActionImageView::PageActionImageView( |
1178 LocationBarView* owner, | 1178 LocationBarView* owner, |
1179 Profile* profile, | 1179 Profile* profile, |
1180 const ExtensionAction* page_action, | 1180 const ExtensionAction* page_action, |
1181 const BubblePositioner* bubble_positioner) | 1181 const BubblePositioner* bubble_positioner) |
1182 : LocationBarImageView(bubble_positioner), | 1182 : LocationBarImageView(bubble_positioner), |
1183 owner_(owner), | 1183 owner_(owner), |
1184 profile_(profile), | 1184 profile_(profile), |
1185 page_action_(page_action), | 1185 page_action_(page_action), |
1186 current_tab_id_(-1), | 1186 current_tab_id_(-1), |
1187 tooltip_(page_action_->name()) { | 1187 tooltip_(page_action_->title()) { |
1188 Extension* extension = profile->GetExtensionsService()->GetExtensionById( | 1188 Extension* extension = profile->GetExtensionsService()->GetExtensionById( |
1189 page_action->extension_id()); | 1189 page_action->extension_id()); |
1190 DCHECK(extension); | 1190 DCHECK(extension); |
1191 | 1191 |
1192 // Load the images this view needs asynchronously on the file thread. We'll | 1192 // Load the images this view needs asynchronously on the file thread. We'll |
1193 // get a call back into OnImageLoaded if the image loads successfully. If not, | 1193 // get a call back into OnImageLoaded if the image loads successfully. If not, |
1194 // the ImageView will have no image and will not appear in the Omnibox. | 1194 // the ImageView will have no image and will not appear in the Omnibox. |
1195 DCHECK(!page_action->icon_paths().empty()); | 1195 DCHECK(!page_action->icon_paths().empty()); |
1196 const std::vector<std::string>& icon_paths = page_action->icon_paths(); | 1196 const std::vector<std::string>& icon_paths = page_action->icon_paths(); |
1197 page_action_icons_.resize(icon_paths.size()); | 1197 page_action_icons_.resize(icon_paths.size()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 // executed. See PageActionImageView::OnMousePressed. | 1242 // executed. See PageActionImageView::OnMousePressed. |
1243 current_tab_id_ = ExtensionTabUtil::GetTabId(contents); | 1243 current_tab_id_ = ExtensionTabUtil::GetTabId(contents); |
1244 current_url_ = url; | 1244 current_url_ = url; |
1245 | 1245 |
1246 const ExtensionActionState* state = | 1246 const ExtensionActionState* state = |
1247 contents->GetPageActionState(page_action_); | 1247 contents->GetPageActionState(page_action_); |
1248 bool visible = state != NULL; | 1248 bool visible = state != NULL; |
1249 if (visible) { | 1249 if (visible) { |
1250 // Set the tooltip. | 1250 // Set the tooltip. |
1251 if (state->title().empty()) | 1251 if (state->title().empty()) |
1252 tooltip_ = page_action_->name(); | 1252 tooltip_ = page_action_->title(); |
1253 else | 1253 else |
1254 tooltip_ = state->title(); | 1254 tooltip_ = state->title(); |
1255 // Set the image. | 1255 // Set the image. |
1256 int index = state->icon_index(); | 1256 int index = state->icon_index(); |
1257 // The image index (if not within bounds) will be set to the first image. | 1257 // The image index (if not within bounds) will be set to the first image. |
1258 if (index < 0 || index >= static_cast<int>(page_action_icons_.size())) | 1258 if (index < 0 || index >= static_cast<int>(page_action_icons_.size())) |
1259 index = 0; | 1259 index = 0; |
1260 ImageView::SetImage(page_action_icons_[index]); | 1260 ImageView::SetImage(page_action_icons_[index]); |
1261 } | 1261 } |
1262 SetVisible(visible); | 1262 SetVisible(visible); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 } | 1311 } |
1312 | 1312 |
1313 int LocationBarView::PageActionVisibleCount() { | 1313 int LocationBarView::PageActionVisibleCount() { |
1314 int result = 0; | 1314 int result = 0; |
1315 for (size_t i = 0; i < page_action_image_views_.size(); i++) { | 1315 for (size_t i = 0; i < page_action_image_views_.size(); i++) { |
1316 if (page_action_image_views_[i]->IsVisible()) | 1316 if (page_action_image_views_[i]->IsVisible()) |
1317 ++result; | 1317 ++result; |
1318 } | 1318 } |
1319 return result; | 1319 return result; |
1320 } | 1320 } |
OLD | NEW |