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

Side by Side Diff: chrome/browser/ui/views/location_bar/page_action_image_view.cc

Issue 1214243003: [Extensions UI] Clean up extension icon generation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/skia/ImageSkia Created 5 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/location_bar/page_action_image_view.h" 5 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/extensions/extension_action.h" 8 #include "chrome/browser/extensions/extension_action.h"
9 #include "chrome/browser/platform_util.h" 9 #include "chrome/browser/platform_util.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 (!preview_enabled_ && !extension_action()->GetIsVisible(tab_id))) { 97 (!preview_enabled_ && !extension_action()->GetIsVisible(tab_id))) {
98 SetVisible(false); 98 SetVisible(false);
99 return; 99 return;
100 } 100 }
101 101
102 // Set the tooltip. 102 // Set the tooltip.
103 tooltip_ = extension_action()->GetTitle(tab_id); 103 tooltip_ = extension_action()->GetTitle(tab_id);
104 SetTooltipText(base::UTF8ToUTF16(tooltip_)); 104 SetTooltipText(base::UTF8ToUTF16(tooltip_));
105 105
106 // Set the image. 106 // Set the image.
107 gfx::Image icon = view_controller_->GetIcon(contents); 107 gfx::Image icon = view_controller_->GetIcon(contents, GetPreferredSize());
108 if (!icon.IsEmpty()) 108 if (!icon.IsEmpty())
109 SetImage(*icon.ToImageSkia()); 109 SetImage(*icon.ToImageSkia());
110 110
111 SetVisible(true); 111 SetVisible(true);
112 } 112 }
113 113
114 void PageActionImageView::PaintChildren(const ui::PaintContext& context) {
115 View::PaintChildren(context);
116 int tab_id = SessionTabHelper::IdForTab(GetCurrentWebContents());
117 if (tab_id >= 0) {
118 ui::PaintRecorder recorder(context);
119 view_controller_->extension_action()->PaintBadge(recorder.canvas(),
120 GetLocalBounds(), tab_id);
121 }
122 }
123
124 void PageActionImageView::UpdateState() { 114 void PageActionImageView::UpdateState() {
125 UpdateVisibility(GetCurrentWebContents()); 115 UpdateVisibility(GetCurrentWebContents());
126 } 116 }
127 117
128 views::View* PageActionImageView::GetAsView() { 118 views::View* PageActionImageView::GetAsView() {
129 return this; 119 return this;
130 } 120 }
131 121
132 bool PageActionImageView::IsMenuRunning() const { 122 bool PageActionImageView::IsMenuRunning() const {
133 return menu_runner_.get() != nullptr; 123 return menu_runner_.get() != nullptr;
(...skipping 30 matching lines...) Expand all
164 nullptr, // No menu button for page action views. 154 nullptr, // No menu button for page action views.
165 gfx::Rect(screen_loc, size()), 155 gfx::Rect(screen_loc, size()),
166 views::MENU_ANCHOR_TOPLEFT, 156 views::MENU_ANCHOR_TOPLEFT,
167 source_type) == views::MenuRunner::MENU_DELETED) { 157 source_type) == views::MenuRunner::MENU_DELETED) {
168 return; 158 return;
169 } 159 }
170 160
171 menu_runner_.reset(); 161 menu_runner_.reset();
172 view_controller_->OnContextMenuClosed(); 162 view_controller_->OnContextMenuClosed();
173 } 163 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698