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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Deleted LayoutDelegate and HarmonyLayoutDelegate. Created 3 years, 8 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
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/bookmarks/bookmark_editor_view.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_editor_view.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" 15 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
16 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h" 16 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h"
17 #include "chrome/browser/ui/browser_dialogs.h" 17 #include "chrome/browser/ui/browser_dialogs.h"
18 #include "chrome/browser/ui/views/harmony/layout_delegate.h" 18 #include "chrome/browser/ui/views/harmony/chrome_views_layout_delegate.h"
19 #include "chrome/browser/ui/views/layout_utils.h" 19 #include "chrome/browser/ui/views/layout_utils.h"
20 #include "chrome/grit/generated_resources.h" 20 #include "chrome/grit/generated_resources.h"
21 #include "chrome/grit/locale_settings.h" 21 #include "chrome/grit/locale_settings.h"
22 #include "components/bookmarks/browser/bookmark_model.h" 22 #include "components/bookmarks/browser/bookmark_model.h"
23 #include "components/bookmarks/browser/bookmark_utils.h" 23 #include "components/bookmarks/browser/bookmark_utils.h"
24 #include "components/constrained_window/constrained_window_views.h" 24 #include "components/constrained_window/constrained_window_views.h"
25 #include "components/history/core/browser/history_service.h" 25 #include "components/history/core/browser/history_service.h"
26 #include "components/strings/grit/components_strings.h" 26 #include "components/strings/grit/components_strings.h"
27 #include "components/url_formatter/url_fixer.h" 27 #include "components/url_formatter/url_fixer.h"
28 #include "components/user_prefs/user_prefs.h" 28 #include "components/user_prefs/user_prefs.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 tree_view_->set_context_menu_controller(this); 335 tree_view_->set_context_menu_controller(this);
336 336
337 new_folder_button_.reset(views::MdTextButton::CreateSecondaryUiButton( 337 new_folder_button_.reset(views::MdTextButton::CreateSecondaryUiButton(
338 this, 338 this,
339 l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_NEW_FOLDER_BUTTON))); 339 l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_NEW_FOLDER_BUTTON)));
340 new_folder_button_->set_owned_by_client(); 340 new_folder_button_->set_owned_by_client();
341 new_folder_button_->SetEnabled(false); 341 new_folder_button_->SetEnabled(false);
342 } 342 }
343 343
344 GridLayout* layout = layout_utils::CreatePanelLayout(this); 344 GridLayout* layout = layout_utils::CreatePanelLayout(this);
345 LayoutDelegate* delegate = LayoutDelegate::Get(); 345 ChromeViewsLayoutDelegate* delegate = ChromeViewsLayoutDelegate::Get();
346 346
347 const int labels_column_set_id = 0; 347 const int labels_column_set_id = 0;
348 const int single_column_view_set_id = 1; 348 const int single_column_view_set_id = 1;
349 const int buttons_column_set_id = 2; 349 const int buttons_column_set_id = 2;
350 350
351 views::ColumnSet* column_set = layout->AddColumnSet(labels_column_set_id); 351 views::ColumnSet* column_set = layout->AddColumnSet(labels_column_set_id);
352 column_set->AddColumn(delegate->GetControlLabelGridAlignment(), 352 column_set->AddColumn(delegate->GetControlLabelGridAlignment(),
353 GridLayout::CENTER, 0, GridLayout::USE_PREF, 0, 0); 353 GridLayout::CENTER, 0, GridLayout::USE_PREF, 0, 0);
354 column_set->AddPaddingColumn( 354 column_set->AddPaddingColumn(
355 0, 355 0, delegate->GetDistanceMetric(
356 delegate->GetMetric( 356 ChromeDistanceMetric::RELATED_CONTROL_HORIZONTAL));
357 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING));
358 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, 357 column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
359 GridLayout::USE_PREF, 0, 0); 358 GridLayout::USE_PREF, 0, 0);
360 359
361 column_set = layout->AddColumnSet(single_column_view_set_id); 360 column_set = layout->AddColumnSet(single_column_view_set_id);
362 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, 361 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
363 GridLayout::USE_PREF, 0, 0); 362 GridLayout::USE_PREF, 0, 0);
364 363
365 column_set = layout->AddColumnSet(buttons_column_set_id); 364 column_set = layout->AddColumnSet(buttons_column_set_id);
366 column_set->AddColumn(GridLayout::FILL, GridLayout::LEADING, 0, 365 column_set->AddColumn(GridLayout::FILL, GridLayout::LEADING, 0,
367 GridLayout::USE_PREF, 0, 0); 366 GridLayout::USE_PREF, 0, 0);
368 column_set->AddPaddingColumn( 367 column_set->AddPaddingColumn(
369 1, 368 1, delegate->GetDistanceMetric(
370 delegate->GetMetric( 369 ChromeDistanceMetric::RELATED_CONTROL_HORIZONTAL));
371 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING));
372 column_set->AddColumn(GridLayout::FILL, GridLayout::LEADING, 0, 370 column_set->AddColumn(GridLayout::FILL, GridLayout::LEADING, 0,
373 GridLayout::USE_PREF, 0, 0); 371 GridLayout::USE_PREF, 0, 0);
374 column_set->AddPaddingColumn( 372 column_set->AddPaddingColumn(
375 0, 373 0, delegate->GetDistanceMetric(
376 delegate->GetMetric( 374 ChromeDistanceMetric::RELATED_CONTROL_HORIZONTAL));
377 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING));
378 column_set->AddColumn(GridLayout::FILL, GridLayout::LEADING, 0, 375 column_set->AddColumn(GridLayout::FILL, GridLayout::LEADING, 0,
379 GridLayout::USE_PREF, 0, 0); 376 GridLayout::USE_PREF, 0, 0);
380 column_set->LinkColumnSizes(0, 2, 4, -1); 377 column_set->LinkColumnSizes(0, 2, 4, -1);
381 378
382 layout->StartRow(0, labels_column_set_id); 379 layout->StartRow(0, labels_column_set_id);
383 layout->AddView(title_label_); 380 layout->AddView(title_label_);
384 layout->AddView(title_tf_); 381 layout->AddView(title_tf_);
385 382
386 if (details_.GetNodeType() != BookmarkNode::FOLDER) { 383 if (details_.GetNodeType() != BookmarkNode::FOLDER) {
387 url_label_ = new views::Label( 384 url_label_ = new views::Label(
388 l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_URL_LABEL)); 385 l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_URL_LABEL));
389 386
390 url_tf_ = new views::Textfield; 387 url_tf_ = new views::Textfield;
391 url_tf_->SetText(chrome::FormatBookmarkURLForDisplay(url)); 388 url_tf_->SetText(chrome::FormatBookmarkURLForDisplay(url));
392 url_tf_->set_controller(this); 389 url_tf_->set_controller(this);
393 url_tf_->SetAccessibleName( 390 url_tf_->SetAccessibleName(
394 l10n_util::GetStringUTF16(IDS_BOOKMARK_AX_EDITOR_URL_LABEL)); 391 l10n_util::GetStringUTF16(IDS_BOOKMARK_AX_EDITOR_URL_LABEL));
395 392
396 layout->AddPaddingRow( 393 layout->AddPaddingRow(0,
397 0, 394 delegate->GetDistanceMetric(
398 delegate->GetMetric( 395 ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
399 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
400 396
401 layout->StartRow(0, labels_column_set_id); 397 layout->StartRow(0, labels_column_set_id);
402 layout->AddView(url_label_); 398 layout->AddView(url_label_);
403 layout->AddView(url_tf_); 399 layout->AddView(url_tf_);
404 } 400 }
405 401
406 if (show_tree_) { 402 if (show_tree_) {
407 layout->AddPaddingRow( 403 layout->AddPaddingRow(0,
408 0, 404 delegate->GetDistanceMetric(
409 delegate->GetMetric( 405 ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
410 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
411 layout->StartRow(1, single_column_view_set_id); 406 layout->StartRow(1, single_column_view_set_id);
412 layout->AddView(tree_view_->CreateParentIfNecessary()); 407 layout->AddView(tree_view_->CreateParentIfNecessary());
413 } 408 }
414 409
415 if (delegate->UseExtraDialogPadding()) { 410 if (delegate->UseExtraDialogPadding()) {
416 layout->AddPaddingRow( 411 layout->AddPaddingRow(0,
417 0, 412 delegate->GetDistanceMetric(
418 delegate->GetMetric( 413 ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
419 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
420 } 414 }
421 415
422 if (!show_tree_ || bb_model_->loaded()) 416 if (!show_tree_ || bb_model_->loaded())
423 Reset(); 417 Reset();
424 } 418 }
425 419
426 void BookmarkEditorView::Reset() { 420 void BookmarkEditorView::Reset() {
427 if (!show_tree_) { 421 if (!show_tree_) {
428 if (parent()) 422 if (parent())
429 UserInputChanged(); 423 UserInputChanged();
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 Profile* profile, 670 Profile* profile,
677 const BookmarkEditor::EditDetails& details, 671 const BookmarkEditor::EditDetails& details,
678 BookmarkEditor::Configuration configuration) { 672 BookmarkEditor::Configuration configuration) {
679 DCHECK(profile); 673 DCHECK(profile);
680 BookmarkEditorView* editor = new BookmarkEditorView( 674 BookmarkEditorView* editor = new BookmarkEditorView(
681 profile, details.parent_node, details, configuration); 675 profile, details.parent_node, details, configuration);
682 editor->Show(parent_window); 676 editor->Show(parent_window);
683 } 677 }
684 678
685 } // namespace chrome 679 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698