| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/views/bookmark_manager_view.h" | 5 #include "chrome/browser/views/bookmark_manager_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/gfx/canvas.h" | 9 #include "app/gfx/canvas.h" |
| 10 #include "app/gfx/color_utils.h" | 10 #include "app/gfx/color_utils.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 views::MenuButton* organize_menu_button = new views::MenuButton( | 175 views::MenuButton* organize_menu_button = new views::MenuButton( |
| 176 NULL, l10n_util::GetString(IDS_BOOKMARK_MANAGER_ORGANIZE_MENU), | 176 NULL, l10n_util::GetString(IDS_BOOKMARK_MANAGER_ORGANIZE_MENU), |
| 177 this, true); | 177 this, true); |
| 178 organize_menu_button->SetID(kOrganizeMenuButtonID); | 178 organize_menu_button->SetID(kOrganizeMenuButtonID); |
| 179 | 179 |
| 180 views::MenuButton* tools_menu_button = new views::MenuButton( | 180 views::MenuButton* tools_menu_button = new views::MenuButton( |
| 181 NULL, l10n_util::GetString(IDS_BOOKMARK_MANAGER_TOOLS_MENU), | 181 NULL, l10n_util::GetString(IDS_BOOKMARK_MANAGER_TOOLS_MENU), |
| 182 this, true); | 182 this, true); |
| 183 tools_menu_button->SetID(kToolsMenuButtonID); | 183 tools_menu_button->SetID(kToolsMenuButtonID); |
| 184 | 184 |
| 185 split_view_ = new views::SingleSplitView(tree_view_, table_view_); | 185 split_view_ = new views::SingleSplitView(tree_view_, table_view_, |
| 186 views::SingleSplitView::HORIZONTAL_SPLIT); |
| 186 split_view_->set_background( | 187 split_view_->set_background( |
| 187 views::Background::CreateSolidBackground(kBackgroundColorBottom)); | 188 views::Background::CreateSolidBackground(kBackgroundColorBottom)); |
| 188 | 189 |
| 189 views::GridLayout* layout = new views::GridLayout(this); | 190 views::GridLayout* layout = new views::GridLayout(this); |
| 190 SetLayoutManager(layout); | 191 SetLayoutManager(layout); |
| 191 const int top_id = 1; | 192 const int top_id = 1; |
| 192 const int split_cs_id = 2; | 193 const int split_cs_id = 2; |
| 193 layout->SetInsets(2, 0, 0, 0); // 2px padding above content. | 194 layout->SetInsets(2, 0, 0, 0); // 2px padding above content. |
| 194 views::ColumnSet* column_set = layout->AddColumnSet(top_id); | 195 views::ColumnSet* column_set = layout->AddColumnSet(top_id); |
| 195 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, | 196 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 std::wstring BookmarkManagerView::GetWindowTitle() const { | 343 std::wstring BookmarkManagerView::GetWindowTitle() const { |
| 343 return l10n_util::GetString(IDS_BOOKMARK_MANAGER_TITLE); | 344 return l10n_util::GetString(IDS_BOOKMARK_MANAGER_TITLE); |
| 344 } | 345 } |
| 345 | 346 |
| 346 std::wstring BookmarkManagerView::GetWindowName() const { | 347 std::wstring BookmarkManagerView::GetWindowName() const { |
| 347 return prefs::kBookmarkManagerPlacement; | 348 return prefs::kBookmarkManagerPlacement; |
| 348 } | 349 } |
| 349 | 350 |
| 350 void BookmarkManagerView::WindowClosing() { | 351 void BookmarkManagerView::WindowClosing() { |
| 351 g_browser_process->local_state()->SetInteger( | 352 g_browser_process->local_state()->SetInteger( |
| 352 prefs::kBookmarkManagerSplitLocation, split_view_->divider_x()); | 353 prefs::kBookmarkManagerSplitLocation, split_view_->divider_offset()); |
| 353 } | 354 } |
| 354 | 355 |
| 355 bool BookmarkManagerView::AcceleratorPressed( | 356 bool BookmarkManagerView::AcceleratorPressed( |
| 356 const views::Accelerator& accelerator) { | 357 const views::Accelerator& accelerator) { |
| 357 // Ctrl-W to close bookmark manager. | 358 // Ctrl-W to close bookmark manager. |
| 358 DCHECK(accelerator.GetKeyCode() == 'W' && accelerator.IsCtrlDown()); | 359 DCHECK(accelerator.GetKeyCode() == 'W' && accelerator.IsCtrlDown()); |
| 359 window()->Close(); | 360 window()->Close(); |
| 360 return true; | 361 return true; |
| 361 } | 362 } |
| 362 | 363 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 prefs::kBookmarkManagerSplitLocation); | 638 prefs::kBookmarkManagerSplitLocation); |
| 638 if (split_x == -1) { | 639 if (split_x == -1) { |
| 639 // First time running the bookmark manager, give a third of the width to | 640 // First time running the bookmark manager, give a third of the width to |
| 640 // the tree. | 641 // the tree. |
| 641 split_x = split_view_->width() / 3; | 642 split_x = split_view_->width() / 3; |
| 642 } | 643 } |
| 643 int min_split_size = split_view_->width() / 8; | 644 int min_split_size = split_view_->width() / 8; |
| 644 // Make sure the user can see both the tree/table. | 645 // Make sure the user can see both the tree/table. |
| 645 split_x = std::min(split_view_->width() - min_split_size, | 646 split_x = std::min(split_view_->width() - min_split_size, |
| 646 std::max(min_split_size, split_x)); | 647 std::max(min_split_size, split_x)); |
| 647 split_view_->set_divider_x(split_x); | 648 split_view_->set_divider_offset(split_x); |
| 648 if (!GetBookmarkModel()->IsLoaded()) { | 649 if (!GetBookmarkModel()->IsLoaded()) { |
| 649 search_tf_->SetReadOnly(true); | 650 search_tf_->SetReadOnly(true); |
| 650 return; | 651 return; |
| 651 } | 652 } |
| 652 | 653 |
| 653 LoadedImpl(); | 654 LoadedImpl(); |
| 654 } | 655 } |
| 655 | 656 |
| 656 void BookmarkManagerView::LoadedImpl() { | 657 void BookmarkManagerView::LoadedImpl() { |
| 657 BookmarkModel* bookmark_model = GetBookmarkModel(); | 658 BookmarkModel* bookmark_model = GetBookmarkModel(); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 file_type_info.extensions.resize(1); | 780 file_type_info.extensions.resize(1); |
| 780 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); | 781 file_type_info.extensions[0].push_back(FILE_PATH_LITERAL("html")); |
| 781 file_type_info.include_all_files = true; | 782 file_type_info.include_all_files = true; |
| 782 select_file_dialog_ = SelectFileDialog::Create(this); | 783 select_file_dialog_ = SelectFileDialog::Create(this); |
| 783 select_file_dialog_->SelectFile( | 784 select_file_dialog_->SelectFile( |
| 784 SelectFileDialog::SELECT_SAVEAS_FILE, std::wstring(), | 785 SelectFileDialog::SELECT_SAVEAS_FILE, std::wstring(), |
| 785 FilePath(FILE_PATH_LITERAL("bookmarks.html")), &file_type_info, 0, | 786 FilePath(FILE_PATH_LITERAL("bookmarks.html")), &file_type_info, 0, |
| 786 L"html", GetWidget()->GetNativeView(), | 787 L"html", GetWidget()->GetNativeView(), |
| 787 reinterpret_cast<void*>(IDS_BOOKMARK_MANAGER_EXPORT_MENU)); | 788 reinterpret_cast<void*>(IDS_BOOKMARK_MANAGER_EXPORT_MENU)); |
| 788 } | 789 } |
| OLD | NEW |