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

Side by Side Diff: app/tree_node_model.h

Issue 3140022: Remove wstrings from bookmarks, part 7. (Closed)
Patch Set: it was the worst of times Created 10 years, 4 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
« no previous file with comments | « no previous file | app/tree_node_model_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 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 #ifndef APP_TREE_NODE_MODEL_H_ 5 #ifndef APP_TREE_NODE_MODEL_H_
6 #define APP_TREE_NODE_MODEL_H_ 6 #define APP_TREE_NODE_MODEL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 int IndexOfChild(const NodeType* node) const { 150 int IndexOfChild(const NodeType* node) const {
151 DCHECK(node); 151 DCHECK(node);
152 typename std::vector<NodeType*>::const_iterator i = 152 typename std::vector<NodeType*>::const_iterator i =
153 std::find(children_->begin(), children_->end(), node); 153 std::find(children_->begin(), children_->end(), node);
154 if (i != children_->end()) 154 if (i != children_->end())
155 return static_cast<int>(i - children_->begin()); 155 return static_cast<int>(i - children_->begin());
156 return -1; 156 return -1;
157 } 157 }
158 158
159 // Sets the title of the node. 159 // Sets the title of the node.
160 // TODO(munjal): Remove wstring overload once all code is moved to string16.
161 #if !defined(WCHAR_T_IS_UTF16)
162 void SetTitle(const std::wstring& string) {
163 title_ = WideToUTF16(string);
164 }
165 #endif
166 void SetTitle(const string16& string) { 160 void SetTitle(const string16& string) {
167 title_ = string; 161 title_ = string;
168 } 162 }
169 163
170 // TODO(munjal): Remove wstring version and rename GetTitleAsString16 to 164 // TODO(munjal): Remove wstring version and rename GetTitleAsString16 to
171 // GetTitle once all code is moved to string16. 165 // GetTitle once all code is moved to string16.
172 // Returns the title of the node. 166 // Returns the title of the node.
173 virtual std::wstring GetTitle() const { 167 virtual std::wstring GetTitle() const {
174 return UTF16ToWide(title_); 168 return UTF16ToWide(title_);
175 } 169 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 268 }
275 269
276 NodeType* AsNode(TreeModelNode* model_node) { 270 NodeType* AsNode(TreeModelNode* model_node) {
277 return static_cast<NodeType*>(model_node); 271 return static_cast<NodeType*>(model_node);
278 } 272 }
279 273
280 // Sets the title of the specified node. 274 // Sets the title of the specified node.
281 virtual void SetTitle(TreeModelNode* node, 275 virtual void SetTitle(TreeModelNode* node,
282 const std::wstring& title) { 276 const std::wstring& title) {
283 DCHECK(node); 277 DCHECK(node);
284 AsNode(node)->SetTitle(title); 278 AsNode(node)->SetTitle(WideToUTF16Hack(title));
285 NotifyObserverTreeNodeChanged(node); 279 NotifyObserverTreeNodeChanged(node);
286 } 280 }
287 281
288 void Add(NodeType* parent, int index, NodeType* child) { 282 void Add(NodeType* parent, int index, NodeType* child) {
289 DCHECK(parent && child); 283 DCHECK(parent && child);
290 parent->Add(index, child); 284 parent->Add(index, child);
291 NotifyObserverTreeNodesAdded(parent, index, 1); 285 NotifyObserverTreeNodesAdded(parent, index, 1);
292 } 286 }
293 287
294 NodeType* Remove(NodeType* parent, int index) { 288 NodeType* Remove(NodeType* parent, int index) {
(...skipping 27 matching lines...) Expand all
322 private: 316 private:
323 // The observers. 317 // The observers.
324 ObserverList<TreeModelObserver> observer_list_; 318 ObserverList<TreeModelObserver> observer_list_;
325 // The root. 319 // The root.
326 scoped_ptr<NodeType> root_; 320 scoped_ptr<NodeType> root_;
327 321
328 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel); 322 DISALLOW_COPY_AND_ASSIGN(TreeNodeModel);
329 }; 323 };
330 324
331 #endif // APP_TREE_NODE_MODEL_H_ 325 #endif // APP_TREE_NODE_MODEL_H_
OLDNEW
« no previous file with comments | « no previous file | app/tree_node_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698