| 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/basictypes.h" | |
| 10 #include "base/logging.h" | 9 #include "base/logging.h" |
| 11 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 13 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 15 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
| 17 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h" | 16 #include "chrome/browser/ui/bookmarks/bookmark_utils_desktop.h" |
| 18 #include "chrome/browser/ui/browser_dialogs.h" | 17 #include "chrome/browser/ui/browser_dialogs.h" |
| 19 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 expanded_nodes.begin()); i != expanded_nodes.end(); ++i) { | 473 expanded_nodes.begin()); i != expanded_nodes.end(); ++i) { |
| 475 EditorNode* editor_node = | 474 EditorNode* editor_node = |
| 476 FindNodeWithID(tree_model_->GetRoot(), (*i)->id()); | 475 FindNodeWithID(tree_model_->GetRoot(), (*i)->id()); |
| 477 if (editor_node) | 476 if (editor_node) |
| 478 tree_view_->Expand(editor_node); | 477 tree_view_->Expand(editor_node); |
| 479 } | 478 } |
| 480 | 479 |
| 481 const BookmarkNode* to_select = parent_; | 480 const BookmarkNode* to_select = parent_; |
| 482 if (details_.type == EditDetails::EXISTING_NODE) | 481 if (details_.type == EditDetails::EXISTING_NODE) |
| 483 to_select = details_.existing_node->parent(); | 482 to_select = details_.existing_node->parent(); |
| 484 int64 folder_id_to_select = to_select->id(); | 483 int64_t folder_id_to_select = to_select->id(); |
| 485 EditorNode* b_node = | 484 EditorNode* b_node = |
| 486 FindNodeWithID(tree_model_->GetRoot(), folder_id_to_select); | 485 FindNodeWithID(tree_model_->GetRoot(), folder_id_to_select); |
| 487 if (!b_node) | 486 if (!b_node) |
| 488 b_node = tree_model_->GetRoot()->GetChild(0); // Bookmark bar node. | 487 b_node = tree_model_->GetRoot()->GetChild(0); // Bookmark bar node. |
| 489 | 488 |
| 490 tree_view_->SetSelectedNode(b_node); | 489 tree_view_->SetSelectedNode(b_node); |
| 491 } | 490 } |
| 492 | 491 |
| 493 BookmarkEditorView::EditorNode* BookmarkEditorView::CreateRootNode() { | 492 BookmarkEditorView::EditorNode* BookmarkEditorView::CreateRootNode() { |
| 494 EditorNode* root_node = new EditorNode(base::string16(), 0); | 493 EditorNode* root_node = new EditorNode(base::string16(), 0); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 511 EditorNode* new_b_node = new EditorNode(child_bb_node->GetTitle(), | 510 EditorNode* new_b_node = new EditorNode(child_bb_node->GetTitle(), |
| 512 child_bb_node->id()); | 511 child_bb_node->id()); |
| 513 b_node->Add(new_b_node, b_node->child_count()); | 512 b_node->Add(new_b_node, b_node->child_count()); |
| 514 CreateNodes(child_bb_node, new_b_node); | 513 CreateNodes(child_bb_node, new_b_node); |
| 515 } | 514 } |
| 516 } | 515 } |
| 517 } | 516 } |
| 518 | 517 |
| 519 BookmarkEditorView::EditorNode* BookmarkEditorView::FindNodeWithID( | 518 BookmarkEditorView::EditorNode* BookmarkEditorView::FindNodeWithID( |
| 520 BookmarkEditorView::EditorNode* node, | 519 BookmarkEditorView::EditorNode* node, |
| 521 int64 id) { | 520 int64_t id) { |
| 522 if (node->value == id) | 521 if (node->value == id) |
| 523 return node; | 522 return node; |
| 524 for (int i = 0; i < node->child_count(); ++i) { | 523 for (int i = 0; i < node->child_count(); ++i) { |
| 525 EditorNode* result = FindNodeWithID(node->GetChild(i), id); | 524 EditorNode* result = FindNodeWithID(node->GetChild(i), id); |
| 526 if (result) | 525 if (result) |
| 527 return result; | 526 return result; |
| 528 } | 527 } |
| 529 return NULL; | 528 return NULL; |
| 530 } | 529 } |
| 531 | 530 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 Profile* profile, | 651 Profile* profile, |
| 653 const BookmarkEditor::EditDetails& details, | 652 const BookmarkEditor::EditDetails& details, |
| 654 BookmarkEditor::Configuration configuration) { | 653 BookmarkEditor::Configuration configuration) { |
| 655 DCHECK(profile); | 654 DCHECK(profile); |
| 656 BookmarkEditorView* editor = new BookmarkEditorView( | 655 BookmarkEditorView* editor = new BookmarkEditorView( |
| 657 profile, details.parent_node, details, configuration); | 656 profile, details.parent_node, details, configuration); |
| 658 editor->Show(parent_window); | 657 editor->Show(parent_window); |
| 659 } | 658 } |
| 660 | 659 |
| 661 } // namespace chrome | 660 } // namespace chrome |
| OLD | NEW |