Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Side by Side Diff: chrome/browser/ui/views/create_application_shortcut_view.cc

Issue 307873002: Removed the App Info information from the Create App Shortcuts dialog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 CreateApplicationShortcutView::CreateApplicationShortcutView(Profile* profile) 251 CreateApplicationShortcutView::CreateApplicationShortcutView(Profile* profile)
252 : profile_(profile), 252 : profile_(profile),
253 app_info_(NULL), 253 app_info_(NULL),
254 create_shortcuts_label_(NULL), 254 create_shortcuts_label_(NULL),
255 desktop_check_box_(NULL), 255 desktop_check_box_(NULL),
256 menu_check_box_(NULL), 256 menu_check_box_(NULL),
257 quick_launch_check_box_(NULL) {} 257 quick_launch_check_box_(NULL) {}
258 258
259 CreateApplicationShortcutView::~CreateApplicationShortcutView() {} 259 CreateApplicationShortcutView::~CreateApplicationShortcutView() {}
260 260
261 void CreateApplicationShortcutView::InitControls() { 261 void CreateApplicationShortcutView::InitAppInfoControl() {
262 // Create controls
263 app_info_ = new AppInfoView(shortcut_info_.title, shortcut_info_.description, 262 app_info_ = new AppInfoView(shortcut_info_.title, shortcut_info_.description,
264 shortcut_info_.favicon); 263 shortcut_info_.favicon);
264 }
265
266 void CreateApplicationShortcutView::InitDialog() {
265 create_shortcuts_label_ = new views::Label( 267 create_shortcuts_label_ = new views::Label(
266 l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_LABEL)); 268 l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_LABEL));
267 create_shortcuts_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 269 create_shortcuts_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
268 270
269 desktop_check_box_ = AddCheckbox( 271 desktop_check_box_ = AddCheckbox(
270 l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_DESKTOP_CHKBOX), 272 l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_DESKTOP_CHKBOX),
271 profile_->GetPrefs()->GetBoolean(prefs::kWebAppCreateOnDesktop)); 273 profile_->GetPrefs()->GetBoolean(prefs::kWebAppCreateOnDesktop));
272 274
273 menu_check_box_ = NULL; 275 menu_check_box_ = NULL;
274 quick_launch_check_box_ = NULL; 276 quick_launch_check_box_ = NULL;
(...skipping 26 matching lines...) Expand all
301 views::ColumnSet* column_set = layout->AddColumnSet(kHeaderColumnSetId); 303 views::ColumnSet* column_set = layout->AddColumnSet(kHeaderColumnSetId);
302 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, 304 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER,
303 100.0f, views::GridLayout::FIXED, 0, 0); 305 100.0f, views::GridLayout::FIXED, 0, 0);
304 306
305 static const int kTableColumnSetId = 1; 307 static const int kTableColumnSetId = 1;
306 column_set = layout->AddColumnSet(kTableColumnSetId); 308 column_set = layout->AddColumnSet(kTableColumnSetId);
307 column_set->AddPaddingColumn(0, views::kPanelHorizIndentation); 309 column_set->AddPaddingColumn(0, views::kPanelHorizIndentation);
308 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 310 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
309 100.0f, views::GridLayout::USE_PREF, 0, 0); 311 100.0f, views::GridLayout::USE_PREF, 0, 0);
310 312
311 layout->StartRow(0, kHeaderColumnSetId); 313 if (app_info_) {
312 layout->AddView(app_info_); 314 layout->StartRow(0, kHeaderColumnSetId);
315 layout->AddView(app_info_);
316 layout->AddPaddingRow(0, views::kPanelSubVerticalSpacing);
317 }
313 318
314 layout->AddPaddingRow(0, views::kPanelSubVerticalSpacing);
315 layout->StartRow(0, kHeaderColumnSetId); 319 layout->StartRow(0, kHeaderColumnSetId);
316 layout->AddView(create_shortcuts_label_); 320 layout->AddView(create_shortcuts_label_);
317 321
318 layout->AddPaddingRow(0, views::kLabelToControlVerticalSpacing); 322 layout->AddPaddingRow(0, views::kLabelToControlVerticalSpacing);
319 layout->StartRow(0, kTableColumnSetId); 323 layout->StartRow(0, kTableColumnSetId);
320 layout->AddView(desktop_check_box_); 324 layout->AddView(desktop_check_box_);
321 325
322 if (menu_check_box_ != NULL) { 326 if (menu_check_box_ != NULL) {
323 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); 327 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing);
324 layout->StartRow(0, kTableColumnSetId); 328 layout->StartRow(0, kTableColumnSetId);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 const WebApplicationInfo& app_info = 437 const WebApplicationInfo& app_info =
434 extensions::TabHelper::FromWebContents(web_contents_)->web_app_info(); 438 extensions::TabHelper::FromWebContents(web_contents_)->web_app_info();
435 if (!app_info.icons.empty()) { 439 if (!app_info.icons.empty()) {
436 web_app::GetIconsInfo(app_info, &unprocessed_icons_); 440 web_app::GetIconsInfo(app_info, &unprocessed_icons_);
437 FetchIcon(); 441 FetchIcon();
438 } 442 }
439 443
440 // Create URL app shortcuts in the top-level menu. 444 // Create URL app shortcuts in the top-level menu.
441 create_in_chrome_apps_subdir_ = false; 445 create_in_chrome_apps_subdir_ = false;
442 446
443 InitControls(); 447 InitAppInfoControl();
448 InitDialog();
444 } 449 }
445 450
446 CreateUrlApplicationShortcutView::~CreateUrlApplicationShortcutView() { 451 CreateUrlApplicationShortcutView::~CreateUrlApplicationShortcutView() {
447 } 452 }
448 453
449 bool CreateUrlApplicationShortcutView::Accept() { 454 bool CreateUrlApplicationShortcutView::Accept() {
450 if (!CreateApplicationShortcutView::Accept()) 455 if (!CreateApplicationShortcutView::Accept())
451 return false; 456 return false;
452 457
453 // Get the smallest icon in the icon family (should have only 1). 458 // Get the smallest icon in the icon family (should have only 1).
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 } 522 }
518 } 523 }
519 524
520 CreateChromeApplicationShortcutView::CreateChromeApplicationShortcutView( 525 CreateChromeApplicationShortcutView::CreateChromeApplicationShortcutView(
521 Profile* profile, 526 Profile* profile,
522 const extensions::Extension* app, 527 const extensions::Extension* app,
523 const base::Callback<void(bool)>& close_callback) 528 const base::Callback<void(bool)>& close_callback)
524 : CreateApplicationShortcutView(profile), 529 : CreateApplicationShortcutView(profile),
525 close_callback_(close_callback), 530 close_callback_(close_callback),
526 weak_ptr_factory_(this) { 531 weak_ptr_factory_(this) {
527 // Required by InitControls().
528 shortcut_info_.title = base::UTF8ToUTF16(app->name());
529 shortcut_info_.description = base::UTF8ToUTF16(app->description());
530
531 // Place Chrome app shortcuts in the "Chrome Apps" submenu. 532 // Place Chrome app shortcuts in the "Chrome Apps" submenu.
532 create_in_chrome_apps_subdir_ = true; 533 create_in_chrome_apps_subdir_ = true;
533 534
534 InitControls(); 535 // Don't add the info control to dialogs for Chrome apps. In the places where
535 536 // this dialog is created, it is always clear which app the shortcut is for.
536 // Get shortcut information and icon now; they are needed for our UI. 537 InitDialog();
537 web_app::UpdateShortcutInfoAndIconForApp(
538 app, profile,
539 base::Bind(&CreateChromeApplicationShortcutView::OnShortcutInfoLoaded,
benwells 2014/05/29 04:49:34 How come this can be deleted?
sashab 2014/05/29 05:18:02 This loads the app's icon asynchronously, which is
540 weak_ptr_factory_.GetWeakPtr()));
541 } 538 }
542 539
543 CreateChromeApplicationShortcutView::~CreateChromeApplicationShortcutView() {} 540 CreateChromeApplicationShortcutView::~CreateChromeApplicationShortcutView() {}
544 541
545 bool CreateChromeApplicationShortcutView::Accept() { 542 bool CreateChromeApplicationShortcutView::Accept() {
546 if (!close_callback_.is_null()) 543 if (!close_callback_.is_null())
547 close_callback_.Run(true); 544 close_callback_.Run(true);
548 return CreateApplicationShortcutView::Accept(); 545 return CreateApplicationShortcutView::Accept();
549 } 546 }
550 547
551 bool CreateChromeApplicationShortcutView::Cancel() { 548 bool CreateChromeApplicationShortcutView::Cancel() {
552 if (!close_callback_.is_null()) 549 if (!close_callback_.is_null())
553 close_callback_.Run(false); 550 close_callback_.Run(false);
554 return CreateApplicationShortcutView::Cancel(); 551 return CreateApplicationShortcutView::Cancel();
555 } 552 }
556 553
557 // Called when the app's ShortcutInfo (with icon) is loaded. 554 // Called when the app's ShortcutInfo (with icon) is loaded.
558 void CreateChromeApplicationShortcutView::OnShortcutInfoLoaded( 555 void CreateChromeApplicationShortcutView::OnShortcutInfoLoaded(
559 const web_app::ShortcutInfo& shortcut_info) { 556 const web_app::ShortcutInfo& shortcut_info) {
560 shortcut_info_ = shortcut_info; 557 shortcut_info_ = shortcut_info;
561 558
562 CHECK(app_info_); 559 CHECK(app_info_);
563 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon); 560 static_cast<AppInfoView*>(app_info_)->UpdateIcon(shortcut_info_.favicon);
564 } 561 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698