Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc

Issue 7012005: Revert "Revert 84829 - Initial implementation of "Synced Bookmarks" folder." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed 82349 as well Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/bookmarks/bookmark_editor_view.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_editor_view.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h"
8 #include "base/logging.h" 9 #include "base/logging.h"
9 #include "base/string_util.h" 10 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/bookmarks/bookmark_model.h" 12 #include "chrome/browser/bookmarks/bookmark_model.h"
12 #include "chrome/browser/bookmarks/bookmark_utils.h" 13 #include "chrome/browser/bookmarks/bookmark_utils.h"
13 #include "chrome/browser/history/history.h" 14 #include "chrome/browser/history/history.h"
14 #include "chrome/browser/net/url_fixer_upper.h" 15 #include "chrome/browser/net/url_fixer_upper.h"
15 #include "chrome/browser/prefs/pref_service.h" 16 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
18 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
19 #include "grit/chromium_strings.h" 21 #include "grit/chromium_strings.h"
20 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
21 #include "grit/locale_settings.h" 23 #include "grit/locale_settings.h"
22 #include "net/base/net_util.h" 24 #include "net/base/net_util.h"
23 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
24 #include "views/background.h" 26 #include "views/background.h"
25 #include "views/controls/button/native_button.h" 27 #include "views/controls/button/native_button.h"
26 #include "views/controls/label.h" 28 #include "views/controls/label.h"
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 if (!b_node) 480 if (!b_node)
479 b_node = tree_model_->GetRoot()->GetChild(0); // Bookmark bar node. 481 b_node = tree_model_->GetRoot()->GetChild(0); // Bookmark bar node.
480 482
481 tree_view_->SetSelectedNode(b_node); 483 tree_view_->SetSelectedNode(b_node);
482 } 484 }
483 485
484 BookmarkEditorView::EditorNode* BookmarkEditorView::CreateRootNode() { 486 BookmarkEditorView::EditorNode* BookmarkEditorView::CreateRootNode() {
485 EditorNode* root_node = new EditorNode(std::wstring(), 0); 487 EditorNode* root_node = new EditorNode(std::wstring(), 0);
486 const BookmarkNode* bb_root_node = bb_model_->root_node(); 488 const BookmarkNode* bb_root_node = bb_model_->root_node();
487 CreateNodes(bb_root_node, root_node); 489 CreateNodes(bb_root_node, root_node);
488 DCHECK(root_node->child_count() == 2); 490 if (CommandLine::ForCurrentProcess()->HasSwitch(
489 DCHECK(bb_root_node->GetChild(0)->type() == BookmarkNode::BOOKMARK_BAR); 491 switches::kEnableSyncedBookmarksFolder)) {
490 DCHECK(bb_root_node->GetChild(1)->type() == BookmarkNode::OTHER_NODE); 492 DCHECK(root_node->child_count() == 3);
Yaron 2011/05/12 00:39:55 Are we concerned about the case of you going back
sky 2011/05/12 15:37:19 We generally show a warning to the user if they at
Yaron 2011/05/12 18:19:22 I see. Well, I changed it to allow 2-3 or nodes wh
493 DCHECK(bb_root_node->GetChild(0)->type() == BookmarkNode::BOOKMARK_BAR);
494 DCHECK(bb_root_node->GetChild(1)->type() == BookmarkNode::OTHER_NODE);
495 DCHECK(bb_root_node->GetChild(2)->type() == BookmarkNode::SYNCED);
496 } else {
497 DCHECK(root_node->child_count() == 2);
498 DCHECK(bb_root_node->GetChild(0)->type() == BookmarkNode::BOOKMARK_BAR);
499 DCHECK(bb_root_node->GetChild(1)->type() == BookmarkNode::OTHER_NODE);
500 }
491 return root_node; 501 return root_node;
492 } 502 }
493 503
494 void BookmarkEditorView::CreateNodes(const BookmarkNode* bb_node, 504 void BookmarkEditorView::CreateNodes(const BookmarkNode* bb_node,
495 BookmarkEditorView::EditorNode* b_node) { 505 BookmarkEditorView::EditorNode* b_node) {
496 for (int i = 0; i < bb_node->child_count(); ++i) { 506 for (int i = 0; i < bb_node->child_count(); ++i) {
497 const BookmarkNode* child_bb_node = bb_node->GetChild(i); 507 const BookmarkNode* child_bb_node = bb_node->GetChild(i);
498 if (child_bb_node->is_folder()) { 508 if (child_bb_node->is_folder()) {
499 EditorNode* new_b_node = 509 EditorNode* new_b_node =
500 new EditorNode(WideToUTF16(child_bb_node->GetTitle()), 510 new EditorNode(WideToUTF16(child_bb_node->GetTitle()),
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 break; 590 break;
581 } 591 }
582 } 592 }
583 DCHECK(child_bb_node); 593 DCHECK(child_bb_node);
584 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle()); 594 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle());
585 } 595 }
586 ApplyNameChangesAndCreateNewFolders(child_bb_node, child_b_node, 596 ApplyNameChangesAndCreateNewFolders(child_bb_node, child_b_node,
587 parent_b_node, parent_bb_node); 597 parent_b_node, parent_bb_node);
588 } 598 }
589 } 599 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698