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

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

Issue 269079: Implement new page action API. (Closed)
Patch Set: compile fixes Created 11 years, 2 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/tab_contents/tab_contents.cc ('k') | chrome/chrome.gyp » ('j') | 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) 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 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 1238
1239 void LocationBarView::PageActionImageView::UpdateVisibility( 1239 void LocationBarView::PageActionImageView::UpdateVisibility(
1240 TabContents* contents, GURL url) { 1240 TabContents* contents, GURL url) {
1241 // Save this off so we can pass it back to the extension when the action gets 1241 // Save this off so we can pass it back to the extension when the action gets
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 && !state->hidden();
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_->title(); 1252 tooltip_ = page_action_->title();
1253 else 1253 else
1254 tooltip_ = state->title(); 1254 tooltip_ = state->title();
1255
1255 // Set the image. 1256 // Set the image.
1256 int index = state->icon_index(); 1257 SkBitmap* icon = state->icon();
1257 // The image index (if not within bounds) will be set to the first image. 1258 if (!icon) {
1258 if (index < 0 || index >= static_cast<int>(page_action_icons_.size())) 1259 int index = state->icon_index();
1259 index = 0; 1260 // The image index (if not within bounds) will be set to the first image.
1260 ImageView::SetImage(page_action_icons_[index]); 1261 if (index < 0 || index >= static_cast<int>(page_action_icons_.size()))
1262 index = 0;
1263 icon = &page_action_icons_[index];
1264 }
1265 ImageView::SetImage(icon);
1261 } 1266 }
1262 SetVisible(visible); 1267 SetVisible(visible);
1263 } 1268 }
1264 1269
1265 //////////////////////////////////////////////////////////////////////////////// 1270 ////////////////////////////////////////////////////////////////////////////////
1266 // LocationBarView, LocationBar implementation: 1271 // LocationBarView, LocationBar implementation:
1267 1272
1268 void LocationBarView::ShowFirstRunBubble(bool use_OEM_bubble) { 1273 void LocationBarView::ShowFirstRunBubble(bool use_OEM_bubble) {
1269 // We wait 30 milliseconds to open. It allows less flicker. 1274 // We wait 30 milliseconds to open. It allows less flicker.
1270 Task* task = first_run_bubble_.NewRunnableMethod( 1275 Task* task = first_run_bubble_.NewRunnableMethod(
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 } 1316 }
1312 1317
1313 int LocationBarView::PageActionVisibleCount() { 1318 int LocationBarView::PageActionVisibleCount() {
1314 int result = 0; 1319 int result = 0;
1315 for (size_t i = 0; i < page_action_image_views_.size(); i++) { 1320 for (size_t i = 0; i < page_action_image_views_.size(); i++) {
1316 if (page_action_image_views_[i]->IsVisible()) 1321 if (page_action_image_views_[i]->IsVisible())
1317 ++result; 1322 ++result;
1318 } 1323 }
1319 return result; 1324 return result;
1320 } 1325 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698