OLD | NEW |
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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 Profile* profile, | 525 Profile* profile, |
526 const extensions::Extension* app, | 526 const extensions::Extension* app, |
527 const base::Callback<void(bool)>& close_callback) | 527 const base::Callback<void(bool)>& close_callback) |
528 : CreateApplicationShortcutView(profile), | 528 : CreateApplicationShortcutView(profile), |
529 close_callback_(close_callback), | 529 close_callback_(close_callback), |
530 weak_ptr_factory_(this) { | 530 weak_ptr_factory_(this) { |
531 // Place Chrome app shortcuts in the "Chrome Apps" submenu. | 531 // Place Chrome app shortcuts in the "Chrome Apps" submenu. |
532 create_in_chrome_apps_subdir_ = true; | 532 create_in_chrome_apps_subdir_ = true; |
533 | 533 |
534 InitControls(DIALOG_LAYOUT_APP_SHORTCUT); | 534 InitControls(DIALOG_LAYOUT_APP_SHORTCUT); |
| 535 |
| 536 // Get shortcut information and icon; they are needed for creating the |
| 537 // shortcut. |
| 538 web_app::UpdateShortcutInfoAndIconForApp( |
| 539 app, |
| 540 profile, |
| 541 base::Bind(&CreateChromeApplicationShortcutView::OnShortcutInfoLoaded, |
| 542 weak_ptr_factory_.GetWeakPtr())); |
535 } | 543 } |
536 | 544 |
537 CreateChromeApplicationShortcutView::~CreateChromeApplicationShortcutView() {} | 545 CreateChromeApplicationShortcutView::~CreateChromeApplicationShortcutView() {} |
538 | 546 |
539 bool CreateChromeApplicationShortcutView::Accept() { | 547 bool CreateChromeApplicationShortcutView::Accept() { |
540 if (!close_callback_.is_null()) | 548 if (!close_callback_.is_null()) |
541 close_callback_.Run(true); | 549 close_callback_.Run(true); |
542 return CreateApplicationShortcutView::Accept(); | 550 return CreateApplicationShortcutView::Accept(); |
543 } | 551 } |
544 | 552 |
545 bool CreateChromeApplicationShortcutView::Cancel() { | 553 bool CreateChromeApplicationShortcutView::Cancel() { |
546 if (!close_callback_.is_null()) | 554 if (!close_callback_.is_null()) |
547 close_callback_.Run(false); | 555 close_callback_.Run(false); |
548 return CreateApplicationShortcutView::Cancel(); | 556 return CreateApplicationShortcutView::Cancel(); |
549 } | 557 } |
| 558 |
| 559 // Called when the app's ShortcutInfo (with icon) is loaded. |
| 560 void CreateChromeApplicationShortcutView::OnShortcutInfoLoaded( |
| 561 const web_app::ShortcutInfo& shortcut_info) { |
| 562 shortcut_info_ = shortcut_info; |
| 563 } |
OLD | NEW |