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

Side by Side Diff: chrome/browser/ui/views/toolbar/toolbar_action_view.cc

Issue 1580983002: Fix the dynamic browser action setIcon path to work with any size icon. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: twiddle constant Created 4 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/toolbar/toolbar_action_view.h" 5 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } else if (state() == views::CustomButton::STATE_DISABLED) { 148 } else if (state() == views::CustomButton::STATE_DISABLED) {
149 SetState(views::CustomButton::STATE_NORMAL); 149 SetState(views::CustomButton::STATE_NORMAL);
150 } 150 }
151 151
152 wants_to_run_ = view_controller_->WantsToRun(web_contents); 152 wants_to_run_ = view_controller_->WantsToRun(web_contents);
153 153
154 gfx::ImageSkia icon( 154 gfx::ImageSkia icon(
155 view_controller_->GetIcon(web_contents, 155 view_controller_->GetIcon(web_contents,
156 GetPreferredSize()).AsImageSkia()); 156 GetPreferredSize()).AsImageSkia());
157 157
158 if (!icon.isNull()) { 158 if (!icon.isNull())
159 gfx::ImageSkia bg = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 159 SetImage(views::Button::STATE_NORMAL, icon);
160 IDR_BROWSER_ACTION);
161 SetImage(views::Button::STATE_NORMAL,
162 gfx::ImageSkiaOperations::CreateSuperimposedImage(bg, icon));
163 }
164 160
165 SetTooltipText(view_controller_->GetTooltip(web_contents)); 161 SetTooltipText(view_controller_->GetTooltip(web_contents));
166 SetAccessibleName(view_controller_->GetAccessibleName(web_contents)); 162 SetAccessibleName(view_controller_->GetAccessibleName(web_contents));
167 163
168 Layout(); // We need to layout since we may have added an icon as a result. 164 Layout(); // We need to layout since we may have added an icon as a result.
169 SchedulePaint(); 165 SchedulePaint();
170 } 166 }
171 167
172 void ToolbarActionView::OnMenuButtonClicked(views::View* sender, 168 void ToolbarActionView::OnMenuButtonClicked(views::View* sender,
173 const gfx::Point& point) { 169 const gfx::Point& point) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 if (menu_controller->in_nested_run()) { 354 if (menu_controller->in_nested_run()) {
359 // There is another menu showing. Close the outermost menu (since we are 355 // There is another menu showing. Close the outermost menu (since we are
360 // shown in the same menu, we don't want to close the whole thing). 356 // shown in the same menu, we don't want to close the whole thing).
361 menu_controller->Cancel(views::MenuController::EXIT_OUTERMOST); 357 menu_controller->Cancel(views::MenuController::EXIT_OUTERMOST);
362 return true; 358 return true;
363 } 359 }
364 } 360 }
365 361
366 return false; 362 return false;
367 } 363 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/extensions/icon_with_badge_image_source.cc ('k') | chrome/common/extensions/api/browser_action.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698