Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/bookmarks/bookmark_expanded_state_tracker.h" | 5 #include "chrome/browser/bookmarks/bookmark_expanded_state_tracker.h" |
| 6 | 6 |
| 7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_model.h" | 9 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 | 12 |
| 13 BookmarkExpandedStateTracker::BookmarkExpandedStateTracker(Profile* profile, | 13 BookmarkExpandedStateTracker::BookmarkExpandedStateTracker( |
| 14 const char* path) | 14 Profile* profile, |
| 15 const char* path, | |
| 16 BookmarkModel* bookmark_model) | |
|
rpetterson
2012/05/18 22:32:44
We need to pass this in because this is initialize
| |
| 15 : profile_(profile), | 17 : profile_(profile), |
| 16 pref_path_(path) { | 18 pref_path_(path) { |
| 17 profile_->GetBookmarkModel()->AddObserver(this); | 19 bookmark_model->AddObserver(this); |
| 18 } | 20 } |
| 19 | 21 |
| 20 BookmarkExpandedStateTracker::~BookmarkExpandedStateTracker() { | 22 BookmarkExpandedStateTracker::~BookmarkExpandedStateTracker() { |
| 23 } | |
| 24 | |
| 25 void BookmarkExpandedStateTracker::Cleanup() { | |
|
sky
2012/05/21 14:23:06
Move this to BookmarkModelBeingDeleted
rpetterson
2012/05/21 18:01:49
Done.
| |
| 21 profile_->GetBookmarkModel()->RemoveObserver(this); | 26 profile_->GetBookmarkModel()->RemoveObserver(this); |
| 22 } | 27 } |
| 23 | 28 |
| 24 void BookmarkExpandedStateTracker::SetExpandedNodes(const Nodes& nodes) { | 29 void BookmarkExpandedStateTracker::SetExpandedNodes(const Nodes& nodes) { |
| 25 UpdatePrefs(nodes); | 30 UpdatePrefs(nodes); |
| 26 } | 31 } |
| 27 | 32 |
| 28 BookmarkExpandedStateTracker::Nodes | 33 BookmarkExpandedStateTracker::Nodes |
| 29 BookmarkExpandedStateTracker::GetExpandedNodes() { | 34 BookmarkExpandedStateTracker::GetExpandedNodes() { |
| 30 Nodes nodes; | 35 Nodes nodes; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 if (!profile_->GetPrefs()) | 94 if (!profile_->GetPrefs()) |
| 90 return; | 95 return; |
| 91 | 96 |
| 92 ListValue values; | 97 ListValue values; |
| 93 for (Nodes::const_iterator i = nodes.begin(); i != nodes.end(); ++i) { | 98 for (Nodes::const_iterator i = nodes.begin(); i != nodes.end(); ++i) { |
| 94 values.Set(values.GetSize(), | 99 values.Set(values.GetSize(), |
| 95 new StringValue(base::Int64ToString((*i)->id()))); | 100 new StringValue(base::Int64ToString((*i)->id()))); |
| 96 } | 101 } |
| 97 profile_->GetPrefs()->Set(pref_path_, values); | 102 profile_->GetPrefs()->Set(pref_path_, values); |
| 98 } | 103 } |
| OLD | NEW |