| 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_) |
| 376 creation_locations.applications_menu_subdir = shortcut_menu_subdir_; | 376 creation_locations.in_applications_menu_chrome_apps_subdir = true; |
| 377 else |
| 378 creation_locations.in_applications_menu_root = true; |
| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 const base::Closure& close_callback) | 514 const base::Closure& close_callback) |
| 512 : CreateApplicationShortcutView(profile), | 515 : CreateApplicationShortcutView(profile), |
| 513 app_(app), | 516 app_(app), |
| 514 close_callback_(close_callback), | 517 close_callback_(close_callback), |
| 515 weak_ptr_factory_(this) { | 518 weak_ptr_factory_(this) { |
| 516 // Required by InitControls(). | 519 // Required by InitControls(). |
| 517 shortcut_info_.title = UTF8ToUTF16(app->name()); | 520 shortcut_info_.title = UTF8ToUTF16(app->name()); |
| 518 shortcut_info_.description = UTF8ToUTF16(app->description()); | 521 shortcut_info_.description = UTF8ToUTF16(app->description()); |
| 519 | 522 |
| 520 // Place Chrome app shortcuts in the "Chrome Apps" submenu. | 523 // Place Chrome app shortcuts in the "Chrome Apps" submenu. |
| 521 shortcut_menu_subdir_ = web_app::GetAppShortcutsSubdirName(); | 524 create_in_chrome_apps_subdir_ = true; |
| 522 | 525 |
| 523 InitControls(); | 526 InitControls(); |
| 524 | 527 |
| 525 // Get shortcut information and icon now; they are needed for our UI. | 528 // Get shortcut information and icon now; they are needed for our UI. |
| 526 web_app::UpdateShortcutInfoAndIconForApp( | 529 web_app::UpdateShortcutInfoAndIconForApp( |
| 527 *app, profile, | 530 *app, profile, |
| 528 base::Bind(&CreateChromeApplicationShortcutView::OnShortcutInfoLoaded, | 531 base::Bind(&CreateChromeApplicationShortcutView::OnShortcutInfoLoaded, |
| 529 weak_ptr_factory_.GetWeakPtr())); | 532 weak_ptr_factory_.GetWeakPtr())); |
| 530 } | 533 } |
| 531 | 534 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 544 } | 547 } |
| 545 | 548 |
| 546 // Called when the app's ShortcutInfo (with icon) is loaded. | 549 // Called when the app's ShortcutInfo (with icon) is loaded. |
| 547 void CreateChromeApplicationShortcutView::OnShortcutInfoLoaded( | 550 void CreateChromeApplicationShortcutView::OnShortcutInfoLoaded( |
| 548 const ShellIntegration::ShortcutInfo& shortcut_info) { | 551 const ShellIntegration::ShortcutInfo& shortcut_info) { |
| 549 shortcut_info_ = shortcut_info; | 552 shortcut_info_ = shortcut_info; |
| 550 | 553 |
| 551 CHECK(app_info_); | 554 CHECK(app_info_); |
| 552 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); | 555 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); |
| 553 } | 556 } |
| OLD | NEW |