| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/bookmark_editor_view.h" | 5 #include "chrome/browser/ui/views/bookmark_editor_view.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 132 |
| 133 void BookmarkEditorView::Layout() { | 133 void BookmarkEditorView::Layout() { |
| 134 // Let the grid layout manager lay out most of the dialog... | 134 // Let the grid layout manager lay out most of the dialog... |
| 135 GetLayoutManager()->Layout(this); | 135 GetLayoutManager()->Layout(this); |
| 136 | 136 |
| 137 if (!show_tree_) | 137 if (!show_tree_) |
| 138 return; | 138 return; |
| 139 | 139 |
| 140 // Manually lay out the New Folder button in the same row as the OK/Cancel | 140 // Manually lay out the New Folder button in the same row as the OK/Cancel |
| 141 // buttons... | 141 // buttons... |
| 142 gfx::Rect parent_bounds = GetParent()->GetLocalBounds(); | 142 gfx::Rect parent_bounds = parent()->GetLocalBounds(); |
| 143 gfx::Size prefsize = new_group_button_->GetPreferredSize(); | 143 gfx::Size prefsize = new_group_button_->GetPreferredSize(); |
| 144 int button_y = | 144 int button_y = |
| 145 parent_bounds.bottom() - prefsize.height() - views::kButtonVEdgeMargin; | 145 parent_bounds.bottom() - prefsize.height() - views::kButtonVEdgeMargin; |
| 146 new_group_button_->SetBounds(kPanelHorizMargin, button_y, prefsize.width(), | 146 new_group_button_->SetBounds(kPanelHorizMargin, button_y, prefsize.width(), |
| 147 prefsize.height()); | 147 prefsize.height()); |
| 148 } | 148 } |
| 149 | 149 |
| 150 gfx::Size BookmarkEditorView::GetPreferredSize() { | 150 gfx::Size BookmarkEditorView::GetPreferredSize() { |
| 151 if (!show_tree_) | 151 if (!show_tree_) |
| 152 return views::View::GetPreferredSize(); | 152 return views::View::GetPreferredSize(); |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 } | 396 } |
| 397 } | 397 } |
| 398 | 398 |
| 399 void BookmarkEditorView::BookmarkNodeChildrenReordered( | 399 void BookmarkEditorView::BookmarkNodeChildrenReordered( |
| 400 BookmarkModel* model, const BookmarkNode* node) { | 400 BookmarkModel* model, const BookmarkNode* node) { |
| 401 Reset(); | 401 Reset(); |
| 402 } | 402 } |
| 403 | 403 |
| 404 void BookmarkEditorView::Reset() { | 404 void BookmarkEditorView::Reset() { |
| 405 if (!show_tree_) { | 405 if (!show_tree_) { |
| 406 if (GetParent()) | 406 if (parent()) |
| 407 UserInputChanged(); | 407 UserInputChanged(); |
| 408 return; | 408 return; |
| 409 } | 409 } |
| 410 | 410 |
| 411 new_group_button_->SetEnabled(true); | 411 new_group_button_->SetEnabled(true); |
| 412 | 412 |
| 413 // Do this first, otherwise when we invoke SetModel with the real one | 413 // Do this first, otherwise when we invoke SetModel with the real one |
| 414 // tree_view will try to invoke something on the model we just deleted. | 414 // tree_view will try to invoke something on the model we just deleted. |
| 415 tree_view_->SetModel(NULL); | 415 tree_view_->SetModel(NULL); |
| 416 | 416 |
| 417 EditorNode* root_node = CreateRootNode(); | 417 EditorNode* root_node = CreateRootNode(); |
| 418 tree_model_.reset(new EditorTreeModel(root_node)); | 418 tree_model_.reset(new EditorTreeModel(root_node)); |
| 419 | 419 |
| 420 tree_view_->SetModel(tree_model_.get()); | 420 tree_view_->SetModel(tree_model_.get()); |
| 421 tree_view_->SetController(this); | 421 tree_view_->SetController(this); |
| 422 | 422 |
| 423 context_menu_.reset(); | 423 context_menu_.reset(); |
| 424 | 424 |
| 425 if (GetParent()) | 425 if (parent()) |
| 426 ExpandAndSelect(); | 426 ExpandAndSelect(); |
| 427 } | 427 } |
| 428 GURL BookmarkEditorView::GetInputURL() const { | 428 GURL BookmarkEditorView::GetInputURL() const { |
| 429 return URLFixerUpper::FixupURL(UTF16ToUTF8(url_tf_.text()), std::string()); | 429 return URLFixerUpper::FixupURL(UTF16ToUTF8(url_tf_.text()), std::string()); |
| 430 } | 430 } |
| 431 | 431 |
| 432 std::wstring BookmarkEditorView::GetInputTitle() const { | 432 std::wstring BookmarkEditorView::GetInputTitle() const { |
| 433 return title_tf_.text(); | 433 return title_tf_.text(); |
| 434 } | 434 } |
| 435 | 435 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 break; | 579 break; |
| 580 } | 580 } |
| 581 } | 581 } |
| 582 DCHECK(child_bb_node); | 582 DCHECK(child_bb_node); |
| 583 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle()); | 583 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle()); |
| 584 } | 584 } |
| 585 ApplyNameChangesAndCreateNewGroups(child_bb_node, child_b_node, | 585 ApplyNameChangesAndCreateNewGroups(child_bb_node, child_b_node, |
| 586 parent_b_node, parent_bb_node); | 586 parent_b_node, parent_bb_node); |
| 587 } | 587 } |
| 588 } | 588 } |
| OLD | NEW |