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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 string16 CreateApplicationShortcutView::GetWindowTitle() const { | 364 string16 CreateApplicationShortcutView::GetWindowTitle() const { |
365 return l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_TITLE); | 365 return l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_TITLE); |
366 } | 366 } |
367 | 367 |
368 bool CreateApplicationShortcutView::Accept() { | 368 bool CreateApplicationShortcutView::Accept() { |
369 if (!IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)) | 369 if (!IsDialogButtonEnabled(ui::DIALOG_BUTTON_OK)) |
370 return false; | 370 return false; |
371 | 371 |
372 ShellIntegration::ShortcutLocations creation_locations; | 372 ShellIntegration::ShortcutLocations creation_locations; |
373 creation_locations.on_desktop = desktop_check_box_->checked(); | 373 creation_locations.on_desktop = desktop_check_box_->checked(); |
374 creation_locations.in_applications_menu = menu_check_box_ == NULL ? false : | 374 if (menu_check_box_ != NULL && menu_check_box_->checked()) { |
375 menu_check_box_->checked(); | 375 if (create_in_chrome_apps_subdir_) { |
gab
2013/10/17 15:13:31
Use the ternary operator here as well (as suggeste
calamity
2013/11/20 05:43:30
Done.
| |
376 creation_locations.applications_menu_subdir = shortcut_menu_subdir_; | 376 creation_locations.applications_menu_location = |
377 ShellIntegration::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS; | |
378 } else { | |
379 creation_locations.applications_menu_location = | |
380 ShellIntegration::APP_MENU_LOCATION_ROOT; | |
381 } | |
382 } | |
377 | 383 |
378 #if defined(OS_WIN) | 384 #if defined(OS_WIN) |
379 creation_locations.in_quick_launch_bar = quick_launch_check_box_ == NULL ? | 385 creation_locations.in_quick_launch_bar = quick_launch_check_box_ == NULL ? |
380 NULL : quick_launch_check_box_->checked(); | 386 NULL : quick_launch_check_box_->checked(); |
381 #elif defined(OS_POSIX) | 387 #elif defined(OS_POSIX) |
382 // Create shortcut in Mac dock or as Linux (gnome/kde) application launcher | 388 // Create shortcut in Mac dock or as Linux (gnome/kde) application launcher |
383 // are not implemented yet. | 389 // are not implemented yet. |
384 creation_locations.in_quick_launch_bar = false; | 390 creation_locations.in_quick_launch_bar = false; |
385 #endif | 391 #endif |
386 | 392 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 weak_ptr_factory_(this) { | 429 weak_ptr_factory_(this) { |
424 | 430 |
425 web_app::GetShortcutInfoForTab(web_contents_, &shortcut_info_); | 431 web_app::GetShortcutInfoForTab(web_contents_, &shortcut_info_); |
426 const WebApplicationInfo& app_info = | 432 const WebApplicationInfo& app_info = |
427 extensions::TabHelper::FromWebContents(web_contents_)->web_app_info(); | 433 extensions::TabHelper::FromWebContents(web_contents_)->web_app_info(); |
428 if (!app_info.icons.empty()) { | 434 if (!app_info.icons.empty()) { |
429 web_app::GetIconsInfo(app_info, &unprocessed_icons_); | 435 web_app::GetIconsInfo(app_info, &unprocessed_icons_); |
430 FetchIcon(); | 436 FetchIcon(); |
431 } | 437 } |
432 | 438 |
433 // NOTE: Leave shortcut_menu_subdir_ blank to create URL app shortcuts in the | 439 // Create URL app shortcuts in the top-level menu. |
434 // top-level menu. | 440 create_in_chrome_apps_subdir_ = false; |
435 | 441 |
436 InitControls(); | 442 InitControls(); |
437 } | 443 } |
438 | 444 |
439 CreateUrlApplicationShortcutView::~CreateUrlApplicationShortcutView() { | 445 CreateUrlApplicationShortcutView::~CreateUrlApplicationShortcutView() { |
440 } | 446 } |
441 | 447 |
442 bool CreateUrlApplicationShortcutView::Accept() { | 448 bool CreateUrlApplicationShortcutView::Accept() { |
443 if (!CreateApplicationShortcutView::Accept()) | 449 if (!CreateApplicationShortcutView::Accept()) |
444 return false; | 450 return false; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
515 const base::Closure& close_callback) | 521 const base::Closure& close_callback) |
516 : CreateApplicationShortcutView(profile), | 522 : CreateApplicationShortcutView(profile), |
517 app_(app), | 523 app_(app), |
518 close_callback_(close_callback), | 524 close_callback_(close_callback), |
519 weak_ptr_factory_(this) { | 525 weak_ptr_factory_(this) { |
520 // Required by InitControls(). | 526 // Required by InitControls(). |
521 shortcut_info_.title = UTF8ToUTF16(app->name()); | 527 shortcut_info_.title = UTF8ToUTF16(app->name()); |
522 shortcut_info_.description = UTF8ToUTF16(app->description()); | 528 shortcut_info_.description = UTF8ToUTF16(app->description()); |
523 | 529 |
524 // Place Chrome app shortcuts in the "Chrome Apps" submenu. | 530 // Place Chrome app shortcuts in the "Chrome Apps" submenu. |
525 shortcut_menu_subdir_ = web_app::GetAppShortcutsSubdirName(); | 531 create_in_chrome_apps_subdir_ = true; |
526 | 532 |
527 InitControls(); | 533 InitControls(); |
528 | 534 |
529 // Get shortcut information and icon now; they are needed for our UI. | 535 // Get shortcut information and icon now; they are needed for our UI. |
530 web_app::UpdateShortcutInfoAndIconForApp( | 536 web_app::UpdateShortcutInfoAndIconForApp( |
531 *app, profile, | 537 *app, profile, |
532 base::Bind(&CreateChromeApplicationShortcutView::OnShortcutInfoLoaded, | 538 base::Bind(&CreateChromeApplicationShortcutView::OnShortcutInfoLoaded, |
533 weak_ptr_factory_.GetWeakPtr())); | 539 weak_ptr_factory_.GetWeakPtr())); |
534 } | 540 } |
535 | 541 |
(...skipping 12 matching lines...) Expand all Loading... | |
548 } | 554 } |
549 | 555 |
550 // Called when the app's ShortcutInfo (with icon) is loaded. | 556 // Called when the app's ShortcutInfo (with icon) is loaded. |
551 void CreateChromeApplicationShortcutView::OnShortcutInfoLoaded( | 557 void CreateChromeApplicationShortcutView::OnShortcutInfoLoaded( |
552 const ShellIntegration::ShortcutInfo& shortcut_info) { | 558 const ShellIntegration::ShortcutInfo& shortcut_info) { |
553 shortcut_info_ = shortcut_info; | 559 shortcut_info_ = shortcut_info; |
554 | 560 |
555 CHECK(app_info_); | 561 CHECK(app_info_); |
556 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); | 562 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); |
557 } | 563 } |
OLD | NEW |