| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
| 10 #include "chrome/browser/extensions/extension_tab_helper.h" | 10 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 11 #include "chrome/browser/favicon_tab_helper.h" |
| 11 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 14 #include "chrome/browser/ui/web_applications/web_app_ui.h" | 15 #include "chrome/browser/ui/web_applications/web_app_ui.h" |
| 15 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
| 16 #include "chrome/common/extensions/extension.h" | 17 #include "chrome/common/extensions/extension.h" |
| 17 #include "chrome/common/extensions/extension_resource.h" | 18 #include "chrome/common/extensions/extension_resource.h" |
| 18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 19 #include "content/browser/tab_contents/tab_contents.h" | 20 #include "content/browser/tab_contents/tab_contents.h" |
| 20 #include "content/browser/tab_contents/tab_contents_delegate.h" | 21 #include "content/browser/tab_contents/tab_contents_delegate.h" |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 void CreateUrlApplicationShortcutView::FetchIcon() { | 447 void CreateUrlApplicationShortcutView::FetchIcon() { |
| 447 // There should only be fetch job at a time. | 448 // There should only be fetch job at a time. |
| 448 DCHECK(pending_download_ == NULL); | 449 DCHECK(pending_download_ == NULL); |
| 449 | 450 |
| 450 if (unprocessed_icons_.empty()) // No icons to fetch. | 451 if (unprocessed_icons_.empty()) // No icons to fetch. |
| 451 return; | 452 return; |
| 452 | 453 |
| 453 pending_download_ = new IconDownloadCallbackFunctor(this); | 454 pending_download_ = new IconDownloadCallbackFunctor(this); |
| 454 DCHECK(pending_download_); | 455 DCHECK(pending_download_); |
| 455 | 456 |
| 456 tab_contents_->tab_contents()->favicon_helper().DownloadImage( | 457 tab_contents_->favicon_tab_helper()->DownloadImage( |
| 457 unprocessed_icons_.back().url, | 458 unprocessed_icons_.back().url, |
| 458 std::max(unprocessed_icons_.back().width, | 459 std::max(unprocessed_icons_.back().width, |
| 459 unprocessed_icons_.back().height), | 460 unprocessed_icons_.back().height), |
| 460 NewCallback(pending_download_, &IconDownloadCallbackFunctor::Run)); | 461 NewCallback(pending_download_, &IconDownloadCallbackFunctor::Run)); |
| 461 | 462 |
| 462 unprocessed_icons_.pop_back(); | 463 unprocessed_icons_.pop_back(); |
| 463 } | 464 } |
| 464 | 465 |
| 465 void CreateUrlApplicationShortcutView::OnIconDownloaded(bool errored, | 466 void CreateUrlApplicationShortcutView::OnIconDownloaded(bool errored, |
| 466 const SkBitmap& image) { | 467 const SkBitmap& image) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 void CreateChromeApplicationShortcutView::OnImageLoaded( | 520 void CreateChromeApplicationShortcutView::OnImageLoaded( |
| 520 SkBitmap* image, const ExtensionResource& resource, int index) { | 521 SkBitmap* image, const ExtensionResource& resource, int index) { |
| 521 if (image->isNull()) { | 522 if (image->isNull()) { |
| 522 NOTREACHED() << "Corrupt image in profile?"; | 523 NOTREACHED() << "Corrupt image in profile?"; |
| 523 return; | 524 return; |
| 524 } | 525 } |
| 525 shortcut_info_.favicon = *image; | 526 shortcut_info_.favicon = *image; |
| 526 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); | 527 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); |
| 527 } | 528 } |
| 528 | 529 |
| OLD | NEW |