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

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: 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"
27 #include "content/public/browser/favicon_download_delegate.h"
28 #include "content/public/browser/render_view_host.h" 28 #include "content/public/browser/render_view_host.h"
29 #include "content/public/browser/render_widget_host_view.h" 29 #include "content/public/browser/render_widget_host_view.h"
30 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
31 #include "content/public/browser/web_contents_delegate.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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 GetDialogClientView()->UpdateDialogButtons(); 402 GetDialogClientView()->UpdateDialogButtons();
404 } 403 }
405 404
406 CreateUrlApplicationShortcutView::CreateUrlApplicationShortcutView( 405 CreateUrlApplicationShortcutView::CreateUrlApplicationShortcutView(
407 content::WebContents* web_contents) 406 content::WebContents* web_contents)
408 : CreateApplicationShortcutView( 407 : CreateApplicationShortcutView(
409 Profile::FromBrowserContext(web_contents->GetBrowserContext())), 408 Profile::FromBrowserContext(web_contents->GetBrowserContext())),
410 web_contents_(web_contents), 409 web_contents_(web_contents),
411 pending_download_id_(-1) { 410 pending_download_id_(-1) {
412 411
412 web_contents_->RegisterFaviconDelegate(this);
413 web_app::GetShortcutInfoForTab(web_contents_, &shortcut_info_); 413 web_app::GetShortcutInfoForTab(web_contents_, &shortcut_info_);
414 const WebApplicationInfo& app_info = 414 const WebApplicationInfo& app_info =
415 extensions::TabHelper::FromWebContents(web_contents_)->web_app_info(); 415 extensions::TabHelper::FromWebContents(web_contents_)->web_app_info();
416 if (!app_info.icons.empty()) { 416 if (!app_info.icons.empty()) {
417 web_app::GetIconsInfo(app_info, &unprocessed_icons_); 417 web_app::GetIconsInfo(app_info, &unprocessed_icons_);
418 FetchIcon(); 418 FetchIcon();
419 } 419 }
420 420
421 InitControls(); 421 InitControls();
422 } 422 }
(...skipping 15 matching lines...) Expand all
438 return true; 438 return true;
439 } 439 }
440 440
441 void CreateUrlApplicationShortcutView::FetchIcon() { 441 void CreateUrlApplicationShortcutView::FetchIcon() {
442 // There should only be fetch job at a time. 442 // There should only be fetch job at a time.
443 DCHECK_EQ(-1, pending_download_id_); 443 DCHECK_EQ(-1, pending_download_id_);
444 444
445 if (unprocessed_icons_.empty()) // No icons to fetch. 445 if (unprocessed_icons_.empty()) // No icons to fetch.
446 return; 446 return;
447 447
448 if (!download_helper_.get()) 448 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, 449 unprocessed_icons_.back().url,
453 std::max(unprocessed_icons_.back().width, 450 std::max(unprocessed_icons_.back().width,
454 unprocessed_icons_.back().height)); 451 unprocessed_icons_.back().height));
455 452
456 unprocessed_icons_.pop_back(); 453 unprocessed_icons_.pop_back();
457 } 454 }
458 455
459 void CreateUrlApplicationShortcutView::OnDidDownloadFavicon( 456 void CreateUrlApplicationShortcutView::DidDownloadFavicon(
460 int id, 457 int id,
461 const GURL& image_url, 458 const GURL& image_url,
462 bool errored, 459 bool errored,
463 int requested_size, 460 int requested_size,
464 const std::vector<SkBitmap>& bitmaps) { 461 const std::vector<SkBitmap>& bitmaps) {
465 if (id != pending_download_id_) 462 if (id != pending_download_id_)
466 return; 463 return;
467 pending_download_id_ = -1; 464 pending_download_id_ = -1;
468 465
469 SkBitmap image; 466 SkBitmap image;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 if (image.IsEmpty()) { 539 if (image.IsEmpty()) {
543 shortcut_info_.favicon = ui::ResourceBundle::GetSharedInstance(). 540 shortcut_info_.favicon = ui::ResourceBundle::GetSharedInstance().
544 GetImageNamed(IDR_APP_DEFAULT_ICON); 541 GetImageNamed(IDR_APP_DEFAULT_ICON);
545 } else { 542 } else {
546 shortcut_info_.favicon = image; 543 shortcut_info_.favicon = image;
547 } 544 }
548 545
549 CHECK(app_info_); 546 CHECK(app_info_);
550 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); 547 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon);
551 } 548 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698