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

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

Issue 11411180: move favicon download code from chrome/ into content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix order Created 8 years 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/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_download_helper.h"
15 #include "chrome/browser/favicon/favicon_util.h" 14 #include "chrome/browser/favicon/favicon_util.h"
16 #include "chrome/browser/history/select_favicon_frames.h" 15 #include "chrome/browser/history/select_favicon_frames.h"
17 #include "chrome/browser/prefs/pref_service.h" 16 #include "chrome/browser/prefs/pref_service.h"
18 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_commands.h" 19 #include "chrome/browser/ui/browser_commands.h"
21 #include "chrome/browser/ui/browser_finder.h" 20 #include "chrome/browser/ui/browser_finder.h"
22 #include "chrome/browser/ui/web_applications/web_app_ui.h" 21 #include "chrome/browser/ui/web_applications/web_app_ui.h"
23 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 22 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
24 #include "chrome/common/chrome_constants.h" 23 #include "chrome/common/chrome_constants.h"
25 #include "chrome/common/extensions/extension.h" 24 #include "chrome/common/extensions/extension.h"
26 #include "chrome/common/extensions/extension_resource.h" 25 #include "chrome/common/extensions/extension_resource.h"
27 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
28 #include "content/public/browser/render_view_host.h" 27 #include "content/public/browser/render_view_host.h"
29 #include "content/public/browser/render_widget_host_view.h" 28 #include "content/public/browser/render_widget_host_view.h"
30 #include "content/public/browser/web_contents.h" 29 #include "content/public/browser/web_contents.h"
31 #include "content/public/browser/web_contents_delegate.h" 30 #include "googleurl/src/gurl.h"
32 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
33 #include "grit/locale_settings.h" 32 #include "grit/locale_settings.h"
34 #include "grit/theme_resources.h" 33 #include "grit/theme_resources.h"
35 #include "net/base/load_flags.h" 34 #include "net/base/load_flags.h"
36 #include "net/url_request/url_request.h" 35 #include "net/url_request/url_request.h"
37 #include "third_party/skia/include/core/SkBitmap.h" 36 #include "third_party/skia/include/core/SkBitmap.h"
38 #include "third_party/skia/include/core/SkPaint.h" 37 #include "third_party/skia/include/core/SkPaint.h"
39 #include "third_party/skia/include/core/SkRect.h" 38 #include "third_party/skia/include/core/SkRect.h"
40 #include "ui/base/l10n/l10n_util.h" 39 #include "ui/base/l10n/l10n_util.h"
41 #include "ui/base/layout.h" 40 #include "ui/base/layout.h"
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 return true; 437 return true;
439 } 438 }
440 439
441 void CreateUrlApplicationShortcutView::FetchIcon() { 440 void CreateUrlApplicationShortcutView::FetchIcon() {
442 // There should only be fetch job at a time. 441 // There should only be fetch job at a time.
443 DCHECK_EQ(-1, pending_download_id_); 442 DCHECK_EQ(-1, pending_download_id_);
444 443
445 if (unprocessed_icons_.empty()) // No icons to fetch. 444 if (unprocessed_icons_.empty()) // No icons to fetch.
446 return; 445 return;
447 446
448 if (!download_helper_.get()) 447 pending_download_id_ = web_contents_->DownloadFavicon(
449 download_helper_.reset(new FaviconDownloadHelper(web_contents_, this));
450
451 pending_download_id_ = download_helper_->DownloadFavicon(
452 unprocessed_icons_.back().url, 448 unprocessed_icons_.back().url,
453 std::max(unprocessed_icons_.back().width, 449 std::max(unprocessed_icons_.back().width,
454 unprocessed_icons_.back().height)); 450 unprocessed_icons_.back().height),
451 base::Bind(&CreateUrlApplicationShortcutView::DidDownloadFavicon,
452 base::Unretained(this)));
455 453
456 unprocessed_icons_.pop_back(); 454 unprocessed_icons_.pop_back();
457 } 455 }
458 456
459 void CreateUrlApplicationShortcutView::OnDidDownloadFavicon( 457 void CreateUrlApplicationShortcutView::DidDownloadFavicon(
460 int id, 458 int id,
461 const GURL& image_url, 459 const GURL& image_url,
462 bool errored, 460 bool errored,
463 int requested_size, 461 int requested_size,
464 const std::vector<SkBitmap>& bitmaps) { 462 const std::vector<SkBitmap>& bitmaps) {
465 if (id != pending_download_id_) 463 if (id != pending_download_id_)
466 return; 464 return;
467 pending_download_id_ = -1; 465 pending_download_id_ = -1;
468 466
469 SkBitmap image; 467 SkBitmap image;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 if (image.IsEmpty()) { 534 if (image.IsEmpty()) {
537 shortcut_info_.favicon = ui::ResourceBundle::GetSharedInstance(). 535 shortcut_info_.favicon = ui::ResourceBundle::GetSharedInstance().
538 GetImageNamed(IDR_APP_DEFAULT_ICON); 536 GetImageNamed(IDR_APP_DEFAULT_ICON);
539 } else { 537 } else {
540 shortcut_info_.favicon = image; 538 shortcut_info_.favicon = image;
541 } 539 }
542 540
543 CHECK(app_info_); 541 CHECK(app_info_);
544 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); 542 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon);
545 } 543 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/create_application_shortcut_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