| 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/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_provider.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 Loading... |
| 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 ChromeLayoutProvider* provider = ChromeLayoutProvider::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(provider->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, |
| 355 delegate->GetMetric( | 355 provider->GetDistanceMetric(views::DISTANCE_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, |
| 369 delegate->GetMetric( | 368 provider->GetDistanceMetric(views::DISTANCE_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, |
| 375 delegate->GetMetric( | 373 provider->GetDistanceMetric(views::DISTANCE_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, provider->GetDistanceMetric( |
| 396 0, | 393 views::DISTANCE_RELATED_CONTROL_VERTICAL)); |
| 397 delegate->GetMetric( | |
| 398 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); | |
| 399 | 394 |
| 400 layout->StartRow(0, labels_column_set_id); | 395 layout->StartRow(0, labels_column_set_id); |
| 401 layout->AddView(url_label_); | 396 layout->AddView(url_label_); |
| 402 layout->AddView(url_tf_); | 397 layout->AddView(url_tf_); |
| 403 } | 398 } |
| 404 | 399 |
| 405 if (show_tree_) { | 400 if (show_tree_) { |
| 406 layout->AddPaddingRow( | 401 layout->AddPaddingRow(0, provider->GetDistanceMetric( |
| 407 0, | 402 views::DISTANCE_RELATED_CONTROL_VERTICAL)); |
| 408 delegate->GetMetric( | |
| 409 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); | |
| 410 layout->StartRow(1, single_column_view_set_id); | 403 layout->StartRow(1, single_column_view_set_id); |
| 411 layout->AddView(tree_view_->CreateParentIfNecessary()); | 404 layout->AddView(tree_view_->CreateParentIfNecessary()); |
| 412 } | 405 } |
| 413 | 406 |
| 414 if (delegate->UseExtraDialogPadding()) { | 407 if (provider->UseExtraDialogPadding()) { |
| 415 layout->AddPaddingRow( | 408 layout->AddPaddingRow(0, provider->GetDistanceMetric( |
| 416 0, | 409 views::DISTANCE_RELATED_CONTROL_VERTICAL)); |
| 417 delegate->GetMetric( | |
| 418 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); | |
| 419 } | 410 } |
| 420 | 411 |
| 421 if (!show_tree_ || bb_model_->loaded()) | 412 if (!show_tree_ || bb_model_->loaded()) |
| 422 Reset(); | 413 Reset(); |
| 423 } | 414 } |
| 424 | 415 |
| 425 void BookmarkEditorView::Reset() { | 416 void BookmarkEditorView::Reset() { |
| 426 if (!show_tree_) { | 417 if (!show_tree_) { |
| 427 if (parent()) | 418 if (parent()) |
| 428 UserInputChanged(); | 419 UserInputChanged(); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 Profile* profile, | 666 Profile* profile, |
| 676 const BookmarkEditor::EditDetails& details, | 667 const BookmarkEditor::EditDetails& details, |
| 677 BookmarkEditor::Configuration configuration) { | 668 BookmarkEditor::Configuration configuration) { |
| 678 DCHECK(profile); | 669 DCHECK(profile); |
| 679 BookmarkEditorView* editor = new BookmarkEditorView( | 670 BookmarkEditorView* editor = new BookmarkEditorView( |
| 680 profile, details.parent_node, details, configuration); | 671 profile, details.parent_node, details, configuration); |
| 681 editor->Show(parent_window); | 672 editor->Show(parent_window); |
| 682 } | 673 } |
| 683 | 674 |
| 684 } // namespace chrome | 675 } // namespace chrome |
| OLD | NEW |