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

Side by Side Diff: chrome/browser/ui/views/create_application_shortcut_view.cc

Issue 11786003: Move Icons out of Extension class (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_unref_browser_action
Patch Set: License year update Created 7 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/create_application_shortcut_view.h" 5 #include "chrome/browser/ui/views/create_application_shortcut_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "base/win/windows_version.h" 12 #include "base/win/windows_version.h"
13 #include "chrome/browser/extensions/tab_helper.h" 13 #include "chrome/browser/extensions/tab_helper.h"
14 #include "chrome/browser/favicon/favicon_util.h" 14 #include "chrome/browser/favicon/favicon_util.h"
15 #include "chrome/browser/history/select_favicon_frames.h" 15 #include "chrome/browser/history/select_favicon_frames.h"
16 #include "chrome/browser/prefs/pref_service.h" 16 #include "chrome/browser/prefs/pref_service.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_commands.h" 19 #include "chrome/browser/ui/browser_commands.h"
20 #include "chrome/browser/ui/browser_finder.h" 20 #include "chrome/browser/ui/browser_finder.h"
21 #include "chrome/browser/ui/web_applications/web_app_ui.h" 21 #include "chrome/browser/ui/web_applications/web_app_ui.h"
22 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 22 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
23 #include "chrome/common/chrome_constants.h" 23 #include "chrome/common/chrome_constants.h"
24 #include "chrome/common/extensions/api/icons/icons_handler.h"
24 #include "chrome/common/extensions/extension.h" 25 #include "chrome/common/extensions/extension.h"
25 #include "chrome/common/extensions/extension_resource.h" 26 #include "chrome/common/extensions/extension_resource.h"
26 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
27 #include "content/public/browser/render_view_host.h" 28 #include "content/public/browser/render_view_host.h"
28 #include "content/public/browser/render_widget_host_view.h" 29 #include "content/public/browser/render_widget_host_view.h"
29 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
30 #include "googleurl/src/gurl.h" 31 #include "googleurl/src/gurl.h"
31 #include "grit/generated_resources.h" 32 #include "grit/generated_resources.h"
32 #include "grit/locale_settings.h" 33 #include "grit/locale_settings.h"
33 #include "grit/theme_resources.h" 34 #include "grit/theme_resources.h"
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 app_(app), 489 app_(app),
489 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) { 490 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) {
490 web_app::UpdateShortcutInfoForApp(*app, profile, &shortcut_info_); 491 web_app::UpdateShortcutInfoForApp(*app, profile, &shortcut_info_);
491 // The icon will be resized to |max_size|. 492 // The icon will be resized to |max_size|.
492 const gfx::Size max_size(kAppIconSize, kAppIconSize); 493 const gfx::Size max_size(kAppIconSize, kAppIconSize);
493 494
494 // Look for an icon. If there is no icon at the ideal size, 495 // Look for an icon. If there is no icon at the ideal size,
495 // we will resize whatever we can get. Making a large icon smaller 496 // we will resize whatever we can get. Making a large icon smaller
496 // is prefered to making a small icon larger, so look for a larger 497 // is prefered to making a small icon larger, so look for a larger
497 // icon first: 498 // icon first:
498 ExtensionResource icon_resource = app_->GetIconResource( 499 ExtensionResource icon_resource = extensions::IconsInfo::GetIconResource(
500 app_,
499 kAppIconSize, 501 kAppIconSize,
500 ExtensionIconSet::MATCH_BIGGER); 502 ExtensionIconSet::MATCH_BIGGER);
501 503
502 // If no icon exists that is the desired size or larger, get the 504 // If no icon exists that is the desired size or larger, get the
503 // largest icon available: 505 // largest icon available:
504 if (icon_resource.empty()) { 506 if (icon_resource.empty()) {
505 icon_resource = app_->GetIconResource( 507 icon_resource = extensions::IconsInfo::GetIconResource(
508 app_,
506 kAppIconSize, 509 kAppIconSize,
507 ExtensionIconSet::MATCH_SMALLER); 510 ExtensionIconSet::MATCH_SMALLER);
508 } 511 }
509 512
510 InitControls(); 513 InitControls();
511 514
512 // tracker_.LoadImage() can call OnImageLoaded() before it returns if the 515 // tracker_.LoadImage() can call OnImageLoaded() before it returns if the
513 // image is cached. This is very rare. app_info_ must be initialized 516 // image is cached. This is very rare. app_info_ must be initialized
514 // when OnImageLoaded() is called, so we check it here. 517 // when OnImageLoaded() is called, so we check it here.
515 CHECK(app_info_); 518 CHECK(app_info_);
(...skipping 13 matching lines...) Expand all
529 if (image.IsEmpty()) { 532 if (image.IsEmpty()) {
530 shortcut_info_.favicon = ui::ResourceBundle::GetSharedInstance(). 533 shortcut_info_.favicon = ui::ResourceBundle::GetSharedInstance().
531 GetImageNamed(IDR_APP_DEFAULT_ICON); 534 GetImageNamed(IDR_APP_DEFAULT_ICON);
532 } else { 535 } else {
533 shortcut_info_.favicon = image; 536 shortcut_info_.favicon = image;
534 } 537 }
535 538
536 CHECK(app_info_); 539 CHECK(app_info_);
537 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); 540 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon);
538 } 541 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698