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 <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <cmath> | 9 #include <cmath> |
10 #include <utility> | 10 #include <utility> |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 378 |
379 #if defined(OS_WIN) | 379 #if defined(OS_WIN) |
380 creation_locations.in_quick_launch_bar = quick_launch_check_box_ == nullptr ? | 380 creation_locations.in_quick_launch_bar = quick_launch_check_box_ == nullptr ? |
381 false : quick_launch_check_box_->checked(); | 381 false : quick_launch_check_box_->checked(); |
382 #elif defined(OS_POSIX) | 382 #elif defined(OS_POSIX) |
383 // Create shortcut in Mac dock or as Linux (gnome/kde) application launcher | 383 // Create shortcut in Mac dock or as Linux (gnome/kde) application launcher |
384 // are not implemented yet. | 384 // are not implemented yet. |
385 creation_locations.in_quick_launch_bar = false; | 385 creation_locations.in_quick_launch_bar = false; |
386 #endif | 386 #endif |
387 | 387 |
388 web_app::CreateShortcutsWithInfo( | 388 web_app::CreateShortcutsWithInfo(web_app::SHORTCUT_CREATION_BY_USER, |
389 web_app::SHORTCUT_CREATION_BY_USER, creation_locations, | 389 creation_locations, |
390 std::move(shortcut_info_), file_handlers_info_); | 390 std::move(shortcut_info_)); |
391 return true; | 391 return true; |
392 } | 392 } |
393 | 393 |
394 views::Checkbox* CreateApplicationShortcutView::AddCheckbox( | 394 views::Checkbox* CreateApplicationShortcutView::AddCheckbox( |
395 const base::string16& text, bool checked) { | 395 const base::string16& text, bool checked) { |
396 views::Checkbox* checkbox = new views::Checkbox(text); | 396 views::Checkbox* checkbox = new views::Checkbox(text); |
397 checkbox->SetChecked(checked); | 397 checkbox->SetChecked(checked); |
398 checkbox->set_listener(this); | 398 checkbox->set_listener(this); |
399 return checkbox; | 399 return checkbox; |
400 } | 400 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 const extensions::Extension* app, | 514 const extensions::Extension* app, |
515 const base::Callback<void(bool)>& close_callback) | 515 const base::Callback<void(bool)>& close_callback) |
516 : CreateApplicationShortcutView(profile), | 516 : CreateApplicationShortcutView(profile), |
517 close_callback_(close_callback), | 517 close_callback_(close_callback), |
518 weak_ptr_factory_(this) { | 518 weak_ptr_factory_(this) { |
519 // Place Chrome app shortcuts in the "Chrome Apps" submenu. | 519 // Place Chrome app shortcuts in the "Chrome Apps" submenu. |
520 create_in_chrome_apps_subdir_ = true; | 520 create_in_chrome_apps_subdir_ = true; |
521 | 521 |
522 InitControls(DIALOG_LAYOUT_APP_SHORTCUT); | 522 InitControls(DIALOG_LAYOUT_APP_SHORTCUT); |
523 | 523 |
524 // Get shortcut, icon and file handler information; they are needed for | 524 // Get shortcut and icon information; needed for creating the shortcut. |
525 // creating the shortcut. | 525 web_app::GetShortcutInfoForApp( |
526 web_app::GetInfoForApp( | 526 app, profile, |
527 app, | |
528 profile, | |
529 base::Bind(&CreateChromeApplicationShortcutView::OnAppInfoLoaded, | 527 base::Bind(&CreateChromeApplicationShortcutView::OnAppInfoLoaded, |
530 weak_ptr_factory_.GetWeakPtr())); | 528 weak_ptr_factory_.GetWeakPtr())); |
531 } | 529 } |
532 | 530 |
533 CreateChromeApplicationShortcutView::~CreateChromeApplicationShortcutView() {} | 531 CreateChromeApplicationShortcutView::~CreateChromeApplicationShortcutView() {} |
534 | 532 |
535 bool CreateChromeApplicationShortcutView::Accept() { | 533 bool CreateChromeApplicationShortcutView::Accept() { |
536 if (!close_callback_.is_null()) | 534 if (!close_callback_.is_null()) |
537 close_callback_.Run(true); | 535 close_callback_.Run(true); |
538 return CreateApplicationShortcutView::Accept(); | 536 return CreateApplicationShortcutView::Accept(); |
539 } | 537 } |
540 | 538 |
541 bool CreateChromeApplicationShortcutView::Cancel() { | 539 bool CreateChromeApplicationShortcutView::Cancel() { |
542 if (!close_callback_.is_null()) | 540 if (!close_callback_.is_null()) |
543 close_callback_.Run(false); | 541 close_callback_.Run(false); |
544 return CreateApplicationShortcutView::Cancel(); | 542 return CreateApplicationShortcutView::Cancel(); |
545 } | 543 } |
546 | 544 |
547 void CreateChromeApplicationShortcutView::OnAppInfoLoaded( | 545 void CreateChromeApplicationShortcutView::OnAppInfoLoaded( |
548 std::unique_ptr<web_app::ShortcutInfo> shortcut_info, | 546 std::unique_ptr<web_app::ShortcutInfo> shortcut_info) { |
549 const extensions::FileHandlersInfo& file_handlers_info) { | |
550 shortcut_info_ = std::move(shortcut_info); | 547 shortcut_info_ = std::move(shortcut_info); |
551 file_handlers_info_ = file_handlers_info; | |
552 } | 548 } |
OLD | NEW |