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