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

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

Issue 9586018: Add support for multiple icon sizes for Mac platform apps (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix build Created 8 years, 9 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 | Annotate | Revision Log
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/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/extensions/extension_browser_event_router.h" 8 #include "chrome/browser/extensions/extension_browser_event_router.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_tab_util.h" 10 #include "chrome/browser/extensions/extension_tab_util.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 views::MenuModelAdapter menu_model_adapter(context_menu_model.get()); 170 views::MenuModelAdapter menu_model_adapter(context_menu_model.get());
171 menu_runner_.reset(new views::MenuRunner(menu_model_adapter.CreateMenu())); 171 menu_runner_.reset(new views::MenuRunner(menu_model_adapter.CreateMenu()));
172 gfx::Point screen_loc; 172 gfx::Point screen_loc;
173 views::View::ConvertPointToScreen(this, &screen_loc); 173 views::View::ConvertPointToScreen(this, &screen_loc);
174 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc, size()), 174 if (menu_runner_->RunMenuAt(GetWidget(), NULL, gfx::Rect(screen_loc, size()),
175 views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS) == 175 views::MenuItemView::TOPLEFT, views::MenuRunner::HAS_MNEMONICS) ==
176 views::MenuRunner::MENU_DELETED) 176 views::MenuRunner::MENU_DELETED)
177 return; 177 return;
178 } 178 }
179 179
180 void PageActionImageView::OnImageLoaded( 180 void PageActionImageView::OnImageLoaded(const gfx::Image& image,
181 SkBitmap* image, const ExtensionResource& resource, int index) { 181 const std::string& extension_id,
182 int index) {
182 // We loaded icons()->size() icons, plus one extra if the page action had 183 // We loaded icons()->size() icons, plus one extra if the page action had
183 // a default icon. 184 // a default icon.
184 int total_icons = static_cast<int>(page_action_->icon_paths()->size()); 185 int total_icons = static_cast<int>(page_action_->icon_paths()->size());
185 if (!page_action_->default_icon_path().empty()) 186 if (!page_action_->default_icon_path().empty())
186 total_icons++; 187 total_icons++;
187 DCHECK(index < total_icons); 188 DCHECK(index < total_icons);
188 189
189 // Map the index of the loaded image back to its name. If we ever get an 190 // Map the index of the loaded image back to its name. If we ever get an
190 // index greater than the number of icons, it must be the default icon. 191 // index greater than the number of icons, it must be the default icon.
191 if (image) { 192 if (!image.IsEmpty()) {
193 const SkBitmap* bitmap = image.ToSkBitmap();
192 if (index < static_cast<int>(page_action_->icon_paths()->size())) 194 if (index < static_cast<int>(page_action_->icon_paths()->size()))
193 page_action_icons_[page_action_->icon_paths()->at(index)] = *image; 195 page_action_icons_[page_action_->icon_paths()->at(index)] = *bitmap;
194 else 196 else
195 page_action_icons_[page_action_->default_icon_path()] = *image; 197 page_action_icons_[page_action_->default_icon_path()] = *bitmap;
196 } 198 }
197 199
198 // During object construction (before the parent has been set) we are already 200 // During object construction (before the parent has been set) we are already
199 // in a UpdatePageActions call, so we don't need to start another one (and 201 // in a UpdatePageActions call, so we don't need to start another one (and
200 // doing so causes crash described in http://crbug.com/57333). 202 // doing so causes crash described in http://crbug.com/57333).
201 if (parent()) 203 if (parent())
202 owner_->UpdatePageActions(); 204 owner_->UpdatePageActions();
203 } 205 }
204 206
205 bool PageActionImageView::AcceleratorPressed( 207 bool PageActionImageView::AcceleratorPressed(
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 const Extension* unloaded_extension = 281 const Extension* unloaded_extension =
280 content::Details<UnloadedExtensionInfo>(details)->extension; 282 content::Details<UnloadedExtensionInfo>(details)->extension;
281 if (page_action_ == unloaded_extension ->page_action()) 283 if (page_action_ == unloaded_extension ->page_action())
282 owner_->UpdatePageActions(); 284 owner_->UpdatePageActions();
283 } 285 }
284 286
285 void PageActionImageView::HidePopup() { 287 void PageActionImageView::HidePopup() {
286 if (popup_) 288 if (popup_)
287 popup_->GetWidget()->Close(); 289 popup_->GetWidget()->Close();
288 } 290 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/page_action_image_view.h ('k') | chrome/browser/ui/web_applications/web_app_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698