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

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

Issue 242150: Implement browserAction.setIcon(ImageData) for extensions. (Closed)
Patch Set: common function 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
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-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/browser_actions_container.h" 5 #include "chrome/browser/views/browser_actions_container.h"
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "chrome/browser/extensions/extension_browser_event_router.h" 10 #include "chrome/browser/extensions/extension_browser_event_router.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 void BrowserActionImageView::OnImageLoaded(SkBitmap* image, size_t index) { 153 void BrowserActionImageView::OnImageLoaded(SkBitmap* image, size_t index) {
154 DCHECK(index < browser_action_icons_.size()); 154 DCHECK(index < browser_action_icons_.size());
155 browser_action_icons_[index] = *image; 155 browser_action_icons_[index] = *image;
156 if (index == browser_action_icons_.size() - 1) { 156 if (index == browser_action_icons_.size() - 1) {
157 OnStateUpdated(); 157 OnStateUpdated();
158 tracker_ = NULL; // The tracker object will delete itself when we return. 158 tracker_ = NULL; // The tracker object will delete itself when we return.
159 } 159 }
160 } 160 }
161 161
162 void BrowserActionImageView::OnStateUpdated() { 162 void BrowserActionImageView::OnStateUpdated() {
163 SkBitmap* image = &browser_action_icons_[browser_action_state_->icon_index()]; 163 SkBitmap* image = browser_action_state_->icon();
164 if (!image)
165 image = &browser_action_icons_[browser_action_state_->icon_index()];
164 SetIcon(*image); 166 SetIcon(*image);
165 SetTooltipText(ASCIIToWide(browser_action_state_->title())); 167 SetTooltipText(ASCIIToWide(browser_action_state_->title()));
166 panel_->OnBrowserActionVisibilityChanged(); 168 panel_->OnBrowserActionVisibilityChanged();
167 SchedulePaint(); 169 SchedulePaint();
168 } 170 }
169 171
170 void BrowserActionImageView::Observe(NotificationType type, 172 void BrowserActionImageView::Observe(NotificationType type,
171 const NotificationSource& source, 173 const NotificationSource& source,
172 const NotificationDetails& details) { 174 const NotificationDetails& details) {
173 if (type == NotificationType::EXTENSION_BROWSER_ACTION_UPDATED) { 175 if (type == NotificationType::EXTENSION_BROWSER_ACTION_UPDATED) {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 // text was too large. 490 // text was too large.
489 rect.fLeft += kPadding; 491 rect.fLeft += kPadding;
490 rect.fRight -= kPadding; 492 rect.fRight -= kPadding;
491 canvas->clipRect(rect); 493 canvas->clipRect(rect);
492 canvas->drawText(text.c_str(), text.size(), 494 canvas->drawText(text.c_str(), text.size(),
493 rect.fLeft + (rect.width() - text_width) / 2, 495 rect.fLeft + (rect.width() - text_width) / 2,
494 rect.fTop + kTextSize + 1, 496 rect.fTop + kTextSize + 1,
495 text_paint); 497 text_paint);
496 canvas->restore(); 498 canvas->restore();
497 } 499 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browser_actions_api.cc ('k') | chrome/common/extensions/api/extension_api.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698