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/bookmarks/bookmark_utils.h" | 5 #include "chrome/browser/bookmarks/bookmark_utils.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 node->url(), languages, net::kFormatUrlOmitNothing, | 78 node->url(), languages, net::kFormatUrlOmitNothing, |
79 net::UnescapeRule::NORMAL, NULL, NULL, NULL), words); | 79 net::UnescapeRule::NORMAL, NULL, NULL, NULL), words); |
80 } | 80 } |
81 | 81 |
82 const BookmarkNode* CreateNewNode(BookmarkModel* model, | 82 const BookmarkNode* CreateNewNode(BookmarkModel* model, |
83 const BookmarkNode* parent, | 83 const BookmarkNode* parent, |
84 const BookmarkEditor::EditDetails& details, | 84 const BookmarkEditor::EditDetails& details, |
85 const string16& new_title, | 85 const string16& new_title, |
86 const GURL& new_url) { | 86 const GURL& new_url) { |
87 const BookmarkNode* node; | 87 const BookmarkNode* node; |
| 88 // When create the new one to right-clicked folder, add it to the next to the |
| 89 // folder's position. |
| 90 int insert_index = |
| 91 parent == details.parent_node ? details.index : parent->child_count(); |
88 if (details.type == BookmarkEditor::EditDetails::NEW_URL) { | 92 if (details.type == BookmarkEditor::EditDetails::NEW_URL) { |
89 node = model->AddURL(parent, parent->child_count(), new_title, new_url); | 93 node = model->AddURL(parent, insert_index, new_title, new_url); |
90 } else if (details.type == BookmarkEditor::EditDetails::NEW_FOLDER) { | 94 } else if (details.type == BookmarkEditor::EditDetails::NEW_FOLDER) { |
91 node = model->AddFolder(parent, parent->child_count(), new_title); | 95 node = model->AddFolder(parent, insert_index, new_title); |
92 for (size_t i = 0; i < details.urls.size(); ++i) { | 96 for (size_t i = 0; i < details.urls.size(); ++i) { |
93 model->AddURL(node, node->child_count(), details.urls[i].second, | 97 model->AddURL(node, node->child_count(), details.urls[i].second, |
94 details.urls[i].first); | 98 details.urls[i].first); |
95 } | 99 } |
96 model->SetDateFolderModified(parent, Time::Now()); | 100 model->SetDateFolderModified(parent, Time::Now()); |
97 } else { | 101 } else { |
98 NOTREACHED(); | 102 NOTREACHED(); |
99 return NULL; | 103 return NULL; |
100 } | 104 } |
101 | 105 |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 void DisableBookmarkBarViewAnimationsForTesting(bool disabled) { | 526 void DisableBookmarkBarViewAnimationsForTesting(bool disabled) { |
523 g_bookmark_bar_view_animations_disabled = disabled; | 527 g_bookmark_bar_view_animations_disabled = disabled; |
524 } | 528 } |
525 | 529 |
526 bool IsBookmarkBarViewAnimationsDisabled() { | 530 bool IsBookmarkBarViewAnimationsDisabled() { |
527 return g_bookmark_bar_view_animations_disabled; | 531 return g_bookmark_bar_view_animations_disabled; |
528 } | 532 } |
529 #endif | 533 #endif |
530 | 534 |
531 } // namespace bookmark_utils | 535 } // namespace bookmark_utils |
OLD | NEW |