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

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

Powered by Google App Engine
This is Rietveld 408576698