| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_editor_view.h" | 5 #include "chrome/browser/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 "chrome/app/locales/locale_settings.h" | 10 #include "chrome/app/locales/locale_settings.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 void BookmarkEditorView::OnTreeViewSelectionChanged( | 145 void BookmarkEditorView::OnTreeViewSelectionChanged( |
| 146 ChromeViews::TreeView* tree_view) { | 146 ChromeViews::TreeView* tree_view) { |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool BookmarkEditorView::CanEdit(ChromeViews::TreeView* tree_view, | 149 bool BookmarkEditorView::CanEdit(ChromeViews::TreeView* tree_view, |
| 150 ChromeViews::TreeModelNode* node) { | 150 ChromeViews::TreeModelNode* node) { |
| 151 // Only allow editting of children of the bookmark bar node and other node. | 151 // Only allow editting of children of the bookmark bar node and other node. |
| 152 BookmarkNode* bb_node = tree_model_->AsNode(node); | 152 EditorNode* bb_node = tree_model_->AsNode(node); |
| 153 return (bb_node->GetParent() && bb_node->GetParent()->GetParent()); | 153 return (bb_node->GetParent() && bb_node->GetParent()->GetParent()); |
| 154 } | 154 } |
| 155 | 155 |
| 156 void BookmarkEditorView::ContentsChanged(TextField* sender, | 156 void BookmarkEditorView::ContentsChanged(TextField* sender, |
| 157 const std::wstring& new_contents) { | 157 const std::wstring& new_contents) { |
| 158 UserInputChanged(); | 158 UserInputChanged(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void BookmarkEditorView::ButtonPressed(NativeButton* sender) { | 161 void BookmarkEditorView::ButtonPressed(NativeButton* sender) { |
| 162 DCHECK(sender); | 162 DCHECK(sender); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 context_menu_->AppendMenuItemWithLabel(IDS_EDIT, | 216 context_menu_->AppendMenuItemWithLabel(IDS_EDIT, |
| 217 l10n_util::GetString(IDS_EDIT)); | 217 l10n_util::GetString(IDS_EDIT)); |
| 218 context_menu_->AppendMenuItemWithLabel( | 218 context_menu_->AppendMenuItemWithLabel( |
| 219 IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM, | 219 IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM, |
| 220 l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM)); | 220 l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM)); |
| 221 context_menu_->RunMenuAt(x, y); | 221 context_menu_->RunMenuAt(x, y); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void BookmarkEditorView::Init() { | 224 void BookmarkEditorView::Init() { |
| 225 tree_view_.SetContextMenuController(this); | 225 tree_view_.SetContextMenuController(this); |
| 226 bb_model_ = profile_->GetBookmarkBarModel(); | 226 bb_model_ = profile_->GetBookmarkModel(); |
| 227 DCHECK(bb_model_); | 227 DCHECK(bb_model_); |
| 228 bb_model_->AddObserver(this); | 228 bb_model_->AddObserver(this); |
| 229 | 229 |
| 230 tree_view_.SetRootShown(false); | 230 tree_view_.SetRootShown(false); |
| 231 // Tell View not to delete all Views declared by value. | 231 // Tell View not to delete all Views declared by value. |
| 232 tree_view_.SetParentOwned(false); | 232 tree_view_.SetParentOwned(false); |
| 233 new_group_button_.SetParentOwned(false); | 233 new_group_button_.SetParentOwned(false); |
| 234 url_tf_.SetParentOwned(false); | 234 url_tf_.SetParentOwned(false); |
| 235 title_tf_.SetParentOwned(false); | 235 title_tf_.SetParentOwned(false); |
| 236 | 236 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 | 288 |
| 289 layout->StartRow(1, single_column_view_set_id); | 289 layout->StartRow(1, single_column_view_set_id); |
| 290 layout->AddView(&tree_view_); | 290 layout->AddView(&tree_view_); |
| 291 | 291 |
| 292 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 292 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
| 293 | 293 |
| 294 if (bb_model_->IsLoaded()) | 294 if (bb_model_->IsLoaded()) |
| 295 Loaded(bb_model_); | 295 Loaded(bb_model_); |
| 296 } | 296 } |
| 297 | 297 |
| 298 void BookmarkEditorView::Loaded(BookmarkBarModel* model) { | 298 void BookmarkEditorView::Loaded(BookmarkModel* model) { |
| 299 Reset(true); | 299 Reset(true); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void BookmarkEditorView::BookmarkNodeMoved(BookmarkBarModel* model, | 302 void BookmarkEditorView::BookmarkNodeMoved(BookmarkModel* model, |
| 303 BookmarkBarNode* old_parent, | 303 BookmarkNode* old_parent, |
| 304 int old_index, | 304 int old_index, |
| 305 BookmarkBarNode* new_parent, | 305 BookmarkNode* new_parent, |
| 306 int new_index) { | 306 int new_index) { |
| 307 Reset(false); | 307 Reset(false); |
| 308 } | 308 } |
| 309 | 309 |
| 310 void BookmarkEditorView::BookmarkNodeAdded(BookmarkBarModel* model, | 310 void BookmarkEditorView::BookmarkNodeAdded(BookmarkModel* model, |
| 311 BookmarkBarNode* parent, | 311 BookmarkNode* parent, |
| 312 int index) { | 312 int index) { |
| 313 Reset(false); | 313 Reset(false); |
| 314 } | 314 } |
| 315 | 315 |
| 316 void BookmarkEditorView::BookmarkNodeRemoved(BookmarkBarModel* model, | 316 void BookmarkEditorView::BookmarkNodeRemoved(BookmarkModel* model, |
| 317 BookmarkBarNode* parent, | 317 BookmarkNode* parent, |
| 318 int index) { | 318 int index) { |
| 319 Reset(false); | 319 Reset(false); |
| 320 } | 320 } |
| 321 | 321 |
| 322 void BookmarkEditorView::Reset(bool first_time) { | 322 void BookmarkEditorView::Reset(bool first_time) { |
| 323 BookmarkBarNode* node_editing = bb_model_->GetNodeByURL(url_); | 323 BookmarkNode* node_editing = bb_model_->GetNodeByURL(url_); |
| 324 | 324 |
| 325 // If the title is empty we need to fetch it from the node. | 325 // If the title is empty we need to fetch it from the node. |
| 326 if (first_time && title_.empty()) { | 326 if (first_time && title_.empty()) { |
| 327 if (node_editing) { | 327 if (node_editing) { |
| 328 title_ = node_editing->GetTitle(); | 328 title_ = node_editing->GetTitle(); |
| 329 title_tf_.SetText(title_); | 329 title_tf_.SetText(title_); |
| 330 } | 330 } |
| 331 } | 331 } |
| 332 | 332 |
| 333 // Do this first, otherwise when we invoke SetModel with the real one | 333 // Do this first, otherwise when we invoke SetModel with the real one |
| 334 // tree_view will try to invoke something on the model we just deleted. | 334 // tree_view will try to invoke something on the model we just deleted. |
| 335 tree_view_.SetModel(NULL); | 335 tree_view_.SetModel(NULL); |
| 336 | 336 |
| 337 BookmarkNode* root_node = CreateRootNode(); | 337 EditorNode* root_node = CreateRootNode(); |
| 338 tree_model_.reset(new BookmarkTreeModel(root_node)); | 338 tree_model_.reset(new EditorTreeModel(root_node)); |
| 339 | 339 |
| 340 tree_view_.SetModel(tree_model_.get()); | 340 tree_view_.SetModel(tree_model_.get()); |
| 341 tree_view_.SetController(this); | 341 tree_view_.SetController(this); |
| 342 | 342 |
| 343 new_group_button_.SetEnabled(true); | 343 new_group_button_.SetEnabled(true); |
| 344 | 344 |
| 345 context_menu_.reset(); | 345 context_menu_.reset(); |
| 346 | 346 |
| 347 if (GetParent()) { | 347 if (GetParent()) { |
| 348 ExpandAndSelect(); | 348 ExpandAndSelect(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 367 if (!url.is_valid()) | 367 if (!url.is_valid()) |
| 368 url_tf_.SetBackgroundColor(kErrorColor); | 368 url_tf_.SetBackgroundColor(kErrorColor); |
| 369 else | 369 else |
| 370 url_tf_.SetDefaultBackgroundColor(); | 370 url_tf_.SetDefaultBackgroundColor(); |
| 371 GetDialogClientView()->UpdateDialogButtons(); | 371 GetDialogClientView()->UpdateDialogButtons(); |
| 372 } | 372 } |
| 373 | 373 |
| 374 void BookmarkEditorView::NewGroup() { | 374 void BookmarkEditorView::NewGroup() { |
| 375 // Create a new entry parented to the selected item, or the bookmark | 375 // Create a new entry parented to the selected item, or the bookmark |
| 376 // bar if nothing is selected. | 376 // bar if nothing is selected. |
| 377 BookmarkNode* parent = tree_model_->AsNode(tree_view_.GetSelectedNode()); | 377 EditorNode* parent = tree_model_->AsNode(tree_view_.GetSelectedNode()); |
| 378 if (!parent) { | 378 if (!parent) { |
| 379 NOTREACHED(); | 379 NOTREACHED(); |
| 380 return; | 380 return; |
| 381 } | 381 } |
| 382 | 382 |
| 383 tree_view_.StartEditing(AddNewGroup(parent)); | 383 tree_view_.StartEditing(AddNewGroup(parent)); |
| 384 } | 384 } |
| 385 | 385 |
| 386 BookmarkEditorView::BookmarkNode* BookmarkEditorView::AddNewGroup( | 386 BookmarkEditorView::EditorNode* BookmarkEditorView::AddNewGroup( |
| 387 BookmarkNode* parent) { | 387 EditorNode* parent) { |
| 388 BookmarkNode* new_node = new BookmarkNode(); | 388 EditorNode* new_node = new EditorNode(); |
| 389 new_node->SetTitle(l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME)); | 389 new_node->SetTitle(l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME)); |
| 390 new_node->value = 0; | 390 new_node->value = 0; |
| 391 // new_node is now owned by parent. | 391 // new_node is now owned by parent. |
| 392 tree_model_->Add(parent, parent->GetChildCount(), new_node); | 392 tree_model_->Add(parent, parent->GetChildCount(), new_node); |
| 393 return new_node; | 393 return new_node; |
| 394 } | 394 } |
| 395 | 395 |
| 396 void BookmarkEditorView::ExpandAndSelect() { | 396 void BookmarkEditorView::ExpandAndSelect() { |
| 397 tree_view_.ExpandAll(); | 397 tree_view_.ExpandAll(); |
| 398 | 398 |
| 399 BookmarkBarNode* to_select = bb_model_->GetNodeByURL(url_); | 399 BookmarkNode* to_select = bb_model_->GetNodeByURL(url_); |
| 400 int group_id_to_select = | 400 int group_id_to_select = |
| 401 to_select ? to_select->GetParent()->id() : | 401 to_select ? to_select->GetParent()->id() : |
| 402 bb_model_->GetParentForNewNodes()->id(); | 402 bb_model_->GetParentForNewNodes()->id(); |
| 403 | 403 |
| 404 DCHECK(group_id_to_select); // GetMostRecentParent should never return NULL. | 404 DCHECK(group_id_to_select); // GetMostRecentParent should never return NULL. |
| 405 BookmarkNode* b_node = | 405 EditorNode* b_node = |
| 406 FindNodeWithID(tree_model_->GetRoot(), group_id_to_select); | 406 FindNodeWithID(tree_model_->GetRoot(), group_id_to_select); |
| 407 if (!b_node) | 407 if (!b_node) |
| 408 b_node = tree_model_->GetRoot()->GetChild(0); // Bookmark bar node. | 408 b_node = tree_model_->GetRoot()->GetChild(0); // Bookmark bar node. |
| 409 | 409 |
| 410 tree_view_.SetSelectedNode(b_node); | 410 tree_view_.SetSelectedNode(b_node); |
| 411 } | 411 } |
| 412 | 412 |
| 413 BookmarkEditorView::BookmarkNode* BookmarkEditorView::CreateRootNode() { | 413 BookmarkEditorView::EditorNode* BookmarkEditorView::CreateRootNode() { |
| 414 BookmarkNode* root_node = new BookmarkNode(std::wstring(), 0); | 414 EditorNode* root_node = new EditorNode(std::wstring(), 0); |
| 415 BookmarkBarNode* bb_root_node = bb_model_->root_node(); | 415 BookmarkNode* bb_root_node = bb_model_->root_node(); |
| 416 CreateNodes(bb_root_node, root_node); | 416 CreateNodes(bb_root_node, root_node); |
| 417 DCHECK(root_node->GetChildCount() == 2); | 417 DCHECK(root_node->GetChildCount() == 2); |
| 418 DCHECK(bb_root_node->GetChild(0)->GetType() == | 418 DCHECK(bb_root_node->GetChild(0)->GetType() == |
| 419 history::StarredEntry::BOOKMARK_BAR); | 419 history::StarredEntry::BOOKMARK_BAR); |
| 420 DCHECK(bb_root_node->GetChild(1)->GetType() == history::StarredEntry::OTHER); | 420 DCHECK(bb_root_node->GetChild(1)->GetType() == history::StarredEntry::OTHER); |
| 421 return root_node; | 421 return root_node; |
| 422 } | 422 } |
| 423 | 423 |
| 424 void BookmarkEditorView::CreateNodes(BookmarkBarNode* bb_node, | 424 void BookmarkEditorView::CreateNodes(BookmarkNode* bb_node, |
| 425 BookmarkEditorView::BookmarkNode* b_node) { | 425 BookmarkEditorView::EditorNode* b_node) { |
| 426 for (int i = 0; i < bb_node->GetChildCount(); ++i) { | 426 for (int i = 0; i < bb_node->GetChildCount(); ++i) { |
| 427 BookmarkBarNode* child_bb_node = bb_node->GetChild(i); | 427 BookmarkNode* child_bb_node = bb_node->GetChild(i); |
| 428 if (child_bb_node->is_folder()) { | 428 if (child_bb_node->is_folder()) { |
| 429 BookmarkNode* new_b_node = new BookmarkNode(child_bb_node->GetTitle(), | 429 EditorNode* new_b_node = new EditorNode(child_bb_node->GetTitle(), |
| 430 child_bb_node->id()); | 430 child_bb_node->id()); |
| 431 b_node->Add(b_node->GetChildCount(), new_b_node); | 431 b_node->Add(b_node->GetChildCount(), new_b_node); |
| 432 CreateNodes(child_bb_node, new_b_node); | 432 CreateNodes(child_bb_node, new_b_node); |
| 433 } | 433 } |
| 434 } | 434 } |
| 435 } | 435 } |
| 436 | 436 |
| 437 BookmarkEditorView::BookmarkNode* BookmarkEditorView::FindNodeWithID( | 437 BookmarkEditorView::EditorNode* BookmarkEditorView::FindNodeWithID( |
| 438 BookmarkEditorView::BookmarkNode* node, | 438 BookmarkEditorView::EditorNode* node, |
| 439 int id) { | 439 int id) { |
| 440 if (node->value == id) | 440 if (node->value == id) |
| 441 return node; | 441 return node; |
| 442 for (int i = 0; i < node->GetChildCount(); ++i) { | 442 for (int i = 0; i < node->GetChildCount(); ++i) { |
| 443 BookmarkNode* result = FindNodeWithID(node->GetChild(i), id); | 443 EditorNode* result = FindNodeWithID(node->GetChild(i), id); |
| 444 if (result) | 444 if (result) |
| 445 return result; | 445 return result; |
| 446 } | 446 } |
| 447 return NULL; | 447 return NULL; |
| 448 } | 448 } |
| 449 | 449 |
| 450 void BookmarkEditorView::ApplyEdits() { | 450 void BookmarkEditorView::ApplyEdits() { |
| 451 DCHECK(bb_model_->IsLoaded()); | 451 DCHECK(bb_model_->IsLoaded()); |
| 452 | 452 |
| 453 if (!tree_view_.GetSelectedNode()) { | 453 if (!tree_view_.GetSelectedNode()) { |
| 454 NOTREACHED(); | 454 NOTREACHED(); |
| 455 return; | 455 return; |
| 456 } | 456 } |
| 457 ApplyEdits(tree_model_->AsNode(tree_view_.GetSelectedNode())); | 457 ApplyEdits(tree_model_->AsNode(tree_view_.GetSelectedNode())); |
| 458 } | 458 } |
| 459 | 459 |
| 460 void BookmarkEditorView::ApplyEdits(BookmarkNode* parent) { | 460 void BookmarkEditorView::ApplyEdits(EditorNode* parent) { |
| 461 DCHECK(parent); | 461 DCHECK(parent); |
| 462 | 462 |
| 463 // We're going to apply edits to the bookmark bar model, which will call us | 463 // We're going to apply edits to the bookmark bar model, which will call us |
| 464 // back. Normally when a structural edit occurs we reset the tree model. | 464 // back. Normally when a structural edit occurs we reset the tree model. |
| 465 // We don't want to do that here, so we remove ourselves as an observer. | 465 // We don't want to do that here, so we remove ourselves as an observer. |
| 466 bb_model_->RemoveObserver(this); | 466 bb_model_->RemoveObserver(this); |
| 467 | 467 |
| 468 GURL new_url(GetInputURL()); | 468 GURL new_url(GetInputURL()); |
| 469 std::wstring new_title(GetInputTitle()); | 469 std::wstring new_title(GetInputTitle()); |
| 470 | 470 |
| 471 BookmarkBarNode* old_node = bb_model_->GetNodeByURL(url_); | 471 BookmarkNode* old_node = bb_model_->GetNodeByURL(url_); |
| 472 BookmarkBarNode* old_parent = old_node ? old_node->GetParent() : NULL; | 472 BookmarkNode* old_parent = old_node ? old_node->GetParent() : NULL; |
| 473 const int old_index = old_parent ? old_parent->IndexOfChild(old_node) : -1; | 473 const int old_index = old_parent ? old_parent->IndexOfChild(old_node) : -1; |
| 474 | 474 |
| 475 if (url_ != new_url) { | 475 if (url_ != new_url) { |
| 476 // The URL has changed, unstar the old url. | 476 // The URL has changed, unstar the old url. |
| 477 bb_model_->SetURLStarred(url_, std::wstring(), false); | 477 bb_model_->SetURLStarred(url_, std::wstring(), false); |
| 478 } | 478 } |
| 479 | 479 |
| 480 // Create the new groups and update the titles. | 480 // Create the new groups and update the titles. |
| 481 BookmarkBarNode* new_parent = NULL; | 481 BookmarkNode* new_parent = NULL; |
| 482 ApplyNameChangesAndCreateNewGroups( | 482 ApplyNameChangesAndCreateNewGroups( |
| 483 bb_model_->root_node(), tree_model_->GetRoot(), parent, &new_parent); | 483 bb_model_->root_node(), tree_model_->GetRoot(), parent, &new_parent); |
| 484 | 484 |
| 485 if (!new_parent) { | 485 if (!new_parent) { |
| 486 // Bookmarks must be parented. | 486 // Bookmarks must be parented. |
| 487 NOTREACHED(); | 487 NOTREACHED(); |
| 488 return; | 488 return; |
| 489 } | 489 } |
| 490 | 490 |
| 491 BookmarkBarNode* current_node = bb_model_->GetNodeByURL(new_url); | 491 BookmarkNode* current_node = bb_model_->GetNodeByURL(new_url); |
| 492 | 492 |
| 493 if (current_node) { | 493 if (current_node) { |
| 494 // There's already a node with the URL. | 494 // There's already a node with the URL. |
| 495 bb_model_->SetTitle(current_node, new_title); | 495 bb_model_->SetTitle(current_node, new_title); |
| 496 if (new_parent == old_parent) { | 496 if (new_parent == old_parent) { |
| 497 // Parent hasn't changed. | 497 // Parent hasn't changed. |
| 498 bb_model_->Move(current_node, new_parent, old_index); | 498 bb_model_->Move(current_node, new_parent, old_index); |
| 499 } else { | 499 } else { |
| 500 // Parent changed, move to end of new parent. | 500 // Parent changed, move to end of new parent. |
| 501 bb_model_->Move(current_node, new_parent, new_parent->GetChildCount()); | 501 bb_model_->Move(current_node, new_parent, new_parent->GetChildCount()); |
| 502 } | 502 } |
| 503 } else { | 503 } else { |
| 504 // Adding a new URL. | 504 // Adding a new URL. |
| 505 if (new_parent == old_parent) { | 505 if (new_parent == old_parent) { |
| 506 // Parent hasn't changed. Place newly created bookmark at the same | 506 // Parent hasn't changed. Place newly created bookmark at the same |
| 507 // location as last bookmark. | 507 // location as last bookmark. |
| 508 bb_model_->AddURL(new_parent, old_index, new_title, new_url); | 508 bb_model_->AddURL(new_parent, old_index, new_title, new_url); |
| 509 } else { | 509 } else { |
| 510 // Parent changed, put bookmark at end of new parent. | 510 // Parent changed, put bookmark at end of new parent. |
| 511 bb_model_->AddURL(new_parent, new_parent->GetChildCount(), new_title, | 511 bb_model_->AddURL(new_parent, new_parent->GetChildCount(), new_title, |
| 512 new_url); | 512 new_url); |
| 513 } | 513 } |
| 514 } | 514 } |
| 515 } | 515 } |
| 516 | 516 |
| 517 void BookmarkEditorView::ApplyNameChangesAndCreateNewGroups( | 517 void BookmarkEditorView::ApplyNameChangesAndCreateNewGroups( |
| 518 BookmarkBarNode* bb_node, | 518 BookmarkNode* bb_node, |
| 519 BookmarkEditorView::BookmarkNode* b_node, | 519 BookmarkEditorView::EditorNode* b_node, |
| 520 BookmarkEditorView::BookmarkNode* parent_b_node, | 520 BookmarkEditorView::EditorNode* parent_b_node, |
| 521 BookmarkBarNode** parent_bb_node) { | 521 BookmarkNode** parent_bb_node) { |
| 522 if (parent_b_node == b_node) | 522 if (parent_b_node == b_node) |
| 523 *parent_bb_node = bb_node; | 523 *parent_bb_node = bb_node; |
| 524 for (int i = 0; i < b_node->GetChildCount(); ++i) { | 524 for (int i = 0; i < b_node->GetChildCount(); ++i) { |
| 525 BookmarkNode* child_b_node = b_node->GetChild(i); | 525 EditorNode* child_b_node = b_node->GetChild(i); |
| 526 BookmarkBarNode* child_bb_node = NULL; | 526 BookmarkNode* child_bb_node = NULL; |
| 527 if (child_b_node->value == 0) { | 527 if (child_b_node->value == 0) { |
| 528 // New group. | 528 // New group. |
| 529 child_bb_node = bb_model_->AddGroup(bb_node, | 529 child_bb_node = bb_model_->AddGroup(bb_node, |
| 530 bb_node->GetChildCount(), child_b_node->GetTitle()); | 530 bb_node->GetChildCount(), child_b_node->GetTitle()); |
| 531 } else { | 531 } else { |
| 532 // Existing node, reset the title (BBModel ignores changes if the title | 532 // Existing node, reset the title (BBModel ignores changes if the title |
| 533 // is the same). | 533 // is the same). |
| 534 for (int j = 0; j < bb_node->GetChildCount(); ++j) { | 534 for (int j = 0; j < bb_node->GetChildCount(); ++j) { |
| 535 BookmarkBarNode* node = bb_node->GetChild(j); | 535 BookmarkNode* node = bb_node->GetChild(j); |
| 536 if (node->is_folder() && node->id() == child_b_node->value) { | 536 if (node->is_folder() && node->id() == child_b_node->value) { |
| 537 child_bb_node = node; | 537 child_bb_node = node; |
| 538 break; | 538 break; |
| 539 } | 539 } |
| 540 } | 540 } |
| 541 DCHECK(child_bb_node); | 541 DCHECK(child_bb_node); |
| 542 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle()); | 542 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle()); |
| 543 } | 543 } |
| 544 ApplyNameChangesAndCreateNewGroups(child_bb_node, child_b_node, | 544 ApplyNameChangesAndCreateNewGroups(child_bb_node, child_b_node, |
| 545 parent_b_node, parent_bb_node); | 545 parent_b_node, parent_bb_node); |
| 546 } | 546 } |
| 547 } | 547 } |
| 548 | 548 |
| OLD | NEW |