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

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: Latest master + Yoyo's requests 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 app_(app), 488 app_(app),
488 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) { 489 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)) {
489 web_app::UpdateShortcutInfoForApp(*app, profile, &shortcut_info_); 490 web_app::UpdateShortcutInfoForApp(*app, profile, &shortcut_info_);
490 // The icon will be resized to |max_size|. 491 // The icon will be resized to |max_size|.
491 const gfx::Size max_size(kAppIconSize, kAppIconSize); 492 const gfx::Size max_size(kAppIconSize, kAppIconSize);
492 493
493 // Look for an icon. If there is no icon at the ideal size, 494 // Look for an icon. If there is no icon at the ideal size,
494 // we will resize whatever we can get. Making a large icon smaller 495 // we will resize whatever we can get. Making a large icon smaller
495 // is prefered to making a small icon larger, so look for a larger 496 // is prefered to making a small icon larger, so look for a larger
496 // icon first: 497 // icon first:
497 ExtensionResource icon_resource = app_->GetIconResource( 498 ExtensionResource icon_resource = extensions::IconsInfo::GetIconResource(
499 app_,
498 kAppIconSize, 500 kAppIconSize,
499 ExtensionIconSet::MATCH_BIGGER); 501 ExtensionIconSet::MATCH_BIGGER);
500 502
501 // If no icon exists that is the desired size or larger, get the 503 // If no icon exists that is the desired size or larger, get the
502 // largest icon available: 504 // largest icon available:
503 if (icon_resource.empty()) { 505 if (icon_resource.empty()) {
504 icon_resource = app_->GetIconResource( 506 icon_resource = extensions::IconsInfo::GetIconResource(
507 app_,
505 kAppIconSize, 508 kAppIconSize,
506 ExtensionIconSet::MATCH_SMALLER); 509 ExtensionIconSet::MATCH_SMALLER);
507 } 510 }
508 511
509 InitControls(); 512 InitControls();
510 513
511 // tracker_.LoadImage() can call OnImageLoaded() before it returns if the 514 // tracker_.LoadImage() can call OnImageLoaded() before it returns if the
512 // image is cached. This is very rare. app_info_ must be initialized 515 // image is cached. This is very rare. app_info_ must be initialized
513 // when OnImageLoaded() is called, so we check it here. 516 // when OnImageLoaded() is called, so we check it here.
514 CHECK(app_info_); 517 CHECK(app_info_);
(...skipping 13 matching lines...) Expand all
528 if (image.IsEmpty()) { 531 if (image.IsEmpty()) {
529 shortcut_info_.favicon = ui::ResourceBundle::GetSharedInstance(). 532 shortcut_info_.favicon = ui::ResourceBundle::GetSharedInstance().
530 GetImageNamed(IDR_APP_DEFAULT_ICON); 533 GetImageNamed(IDR_APP_DEFAULT_ICON);
531 } else { 534 } else {
532 shortcut_info_.favicon = image; 535 shortcut_info_.favicon = image;
533 } 536 }
534 537
535 CHECK(app_info_); 538 CHECK(app_info_);
536 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); 539 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon);
537 } 540 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698