| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "model_test_utils.h" | 5 #include "model_test_utils.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 9 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 if (tell == folder_tell) { | 49 if (tell == folder_tell) { |
| 50 node_name = node_name.substr(0, part_length - 2); | 50 node_name = node_name.substr(0, part_length - 2); |
| 51 const BookmarkNode* new_node = | 51 const BookmarkNode* new_node = |
| 52 model.AddGroup(node, index, WideToUTF16Hack(node_name)); | 52 model.AddGroup(node, index, WideToUTF16Hack(node_name)); |
| 53 end_pos = AddNodesFromString(model, new_node, model_string, | 53 end_pos = AddNodesFromString(model, new_node, model_string, |
| 54 end_pos + 1); | 54 end_pos + 1); |
| 55 } else { | 55 } else { |
| 56 std::string url_string("http://"); | 56 std::string url_string("http://"); |
| 57 url_string += std::string(node_name.begin(), node_name.end()); | 57 url_string += std::string(node_name.begin(), node_name.end()); |
| 58 url_string += ".com"; | 58 url_string += ".com"; |
| 59 model.AddURL(node, index, node_name, GURL(url_string)); | 59 model.AddURL(node, index, WideToUTF16Hack(node_name), GURL(url_string)); |
| 60 ++end_pos; | 60 ++end_pos; |
| 61 } | 61 } |
| 62 ++index; | 62 ++index; |
| 63 start_pos = end_pos; | 63 start_pos = end_pos; |
| 64 end_pos = model_string.find(' ', start_pos); | 64 end_pos = model_string.find(' ', start_pos); |
| 65 } else { | 65 } else { |
| 66 ++end_pos; | 66 ++end_pos; |
| 67 break; | 67 break; |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 return end_pos; | 70 return end_pos; |
| 71 } | 71 } |
| 72 | 72 |
| 73 void AddNodesFromModelString(BookmarkModel& model, | 73 void AddNodesFromModelString(BookmarkModel& model, |
| 74 const BookmarkNode* node, | 74 const BookmarkNode* node, |
| 75 const std::wstring& model_string) { | 75 const std::wstring& model_string) { |
| 76 DCHECK(node); | 76 DCHECK(node); |
| 77 const std::wstring folder_tell(L":["); | 77 const std::wstring folder_tell(L":["); |
| 78 std::wstring::size_type start_pos = 0; | 78 std::wstring::size_type start_pos = 0; |
| 79 std::wstring::size_type end_pos = | 79 std::wstring::size_type end_pos = |
| 80 AddNodesFromString(model, node, model_string, start_pos); | 80 AddNodesFromString(model, node, model_string, start_pos); |
| 81 DCHECK(end_pos == std::wstring::npos); | 81 DCHECK(end_pos == std::wstring::npos); |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace model_test_utils | 84 } // namespace model_test_utils |
| OLD | NEW |