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

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

Issue 10917026: Switch Extensions::TabHelper to use WebContents, WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 8 years, 3 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 | 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"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 } 415 }
416 416
417 CreateUrlApplicationShortcutView::CreateUrlApplicationShortcutView( 417 CreateUrlApplicationShortcutView::CreateUrlApplicationShortcutView(
418 TabContents* tab_contents) 418 TabContents* tab_contents)
419 : CreateApplicationShortcutView(tab_contents->profile()), 419 : CreateApplicationShortcutView(tab_contents->profile()),
420 tab_contents_(tab_contents), 420 tab_contents_(tab_contents),
421 pending_download_(NULL) { 421 pending_download_(NULL) {
422 422
423 web_app::GetShortcutInfoForTab(tab_contents_, &shortcut_info_); 423 web_app::GetShortcutInfoForTab(tab_contents_, &shortcut_info_);
424 const WebApplicationInfo& app_info = 424 const WebApplicationInfo& app_info =
425 tab_contents_->extension_tab_helper()->web_app_info(); 425 extensions::TabHelper::FromWebContents(tab_contents_->web_contents())->
426 web_app_info();
426 if (!app_info.icons.empty()) { 427 if (!app_info.icons.empty()) {
427 web_app::GetIconsInfo(app_info, &unprocessed_icons_); 428 web_app::GetIconsInfo(app_info, &unprocessed_icons_);
428 FetchIcon(); 429 FetchIcon();
429 } 430 }
430 431
431 InitControls(); 432 InitControls();
432 } 433 }
433 434
434 CreateUrlApplicationShortcutView::~CreateUrlApplicationShortcutView() { 435 CreateUrlApplicationShortcutView::~CreateUrlApplicationShortcutView() {
435 if (pending_download_) 436 if (pending_download_)
436 pending_download_->Cancel(); 437 pending_download_->Cancel();
437 } 438 }
438 439
439 bool CreateUrlApplicationShortcutView::Accept() { 440 bool CreateUrlApplicationShortcutView::Accept() {
440 if (!CreateApplicationShortcutView::Accept()) 441 if (!CreateApplicationShortcutView::Accept())
441 return false; 442 return false;
442 443
443 tab_contents_->extension_tab_helper()->SetAppIcon( 444 extensions::TabHelper::FromWebContents(tab_contents_->web_contents())->
444 shortcut_info_.favicon.IsEmpty() ? SkBitmap() : 445 SetAppIcon(shortcut_info_.favicon.IsEmpty()
445 *shortcut_info_.favicon.ToSkBitmap()); 446 ? SkBitmap()
447 : *shortcut_info_.favicon.ToSkBitmap());
446 Browser* browser = 448 Browser* browser =
447 browser::FindBrowserWithWebContents(tab_contents_->web_contents()); 449 browser::FindBrowserWithWebContents(tab_contents_->web_contents());
448 if (browser) 450 if (browser)
449 chrome::ConvertTabToAppWindow(browser, tab_contents_->web_contents()); 451 chrome::ConvertTabToAppWindow(browser, tab_contents_->web_contents());
450 return true; 452 return true;
451 } 453 }
452 454
453 void CreateUrlApplicationShortcutView::FetchIcon() { 455 void CreateUrlApplicationShortcutView::FetchIcon() {
454 // There should only be fetch job at a time. 456 // There should only be fetch job at a time.
455 DCHECK(pending_download_ == NULL); 457 DCHECK(pending_download_ == NULL);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 if (image.IsEmpty()) { 539 if (image.IsEmpty()) {
538 shortcut_info_.favicon = ui::ResourceBundle::GetSharedInstance(). 540 shortcut_info_.favicon = ui::ResourceBundle::GetSharedInstance().
539 GetImageNamed(IDR_APP_DEFAULT_ICON); 541 GetImageNamed(IDR_APP_DEFAULT_ICON);
540 } else { 542 } else {
541 shortcut_info_.favicon = image; 543 shortcut_info_.favicon = image;
542 } 544 }
543 545
544 CHECK(app_info_); 546 CHECK(app_info_);
545 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); 547 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon);
546 } 548 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/tabs/tab_strip_model_unittest.cc ('k') | chrome/browser/ui/views/frame/browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698