| 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 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ | 5 #ifndef CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ |
| 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ | 6 #define CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "base/string16.h" | 17 #include "base/string16.h" |
| 18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
| 19 #include "base/synchronization/waitable_event.h" | 19 #include "base/synchronization/waitable_event.h" |
| 20 #include "chrome/browser/bookmarks/bookmark_service.h" | 20 #include "chrome/browser/bookmarks/bookmark_service.h" |
| 21 #include "chrome/browser/cancelable_request.h" | 21 #include "chrome/browser/cancelable_request.h" |
| 22 #include "chrome/browser/favicon/favicon_service.h" | 22 #include "chrome/browser/favicon/favicon_service.h" |
| 23 #include "chrome/browser/history/history.h" | 23 #include "chrome/browser/history/history.h" |
| 24 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 24 #include "content/public/browser/notification_registrar.h" | 25 #include "content/public/browser/notification_registrar.h" |
| 25 #include "googleurl/src/gurl.h" | 26 #include "googleurl/src/gurl.h" |
| 26 #include "third_party/skia/include/core/SkBitmap.h" | 27 #include "third_party/skia/include/core/SkBitmap.h" |
| 27 #include "ui/base/models/tree_node_model.h" | 28 #include "ui/base/models/tree_node_model.h" |
| 28 | 29 |
| 29 class BookmarkExpandedStateTracker; | 30 class BookmarkExpandedStateTracker; |
| 30 class BookmarkIndex; | 31 class BookmarkIndex; |
| 31 class BookmarkLoadDetails; | 32 class BookmarkLoadDetails; |
| 32 class BookmarkModel; | 33 class BookmarkModel; |
| 33 class BookmarkModelObserver; | 34 class BookmarkModelObserver; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 186 |
| 186 // BookmarkModel -------------------------------------------------------------- | 187 // BookmarkModel -------------------------------------------------------------- |
| 187 | 188 |
| 188 // BookmarkModel provides a directed acyclic graph of URLs and folders. | 189 // BookmarkModel provides a directed acyclic graph of URLs and folders. |
| 189 // Three graphs are provided for the three entry points: those on the 'bookmarks | 190 // Three graphs are provided for the three entry points: those on the 'bookmarks |
| 190 // bar', those in the 'other bookmarks' folder and those in the 'mobile' folder. | 191 // bar', those in the 'other bookmarks' folder and those in the 'mobile' folder. |
| 191 // | 192 // |
| 192 // An observer may be attached to observe relevant events. | 193 // An observer may be attached to observe relevant events. |
| 193 // | 194 // |
| 194 // You should NOT directly create a BookmarkModel, instead go through the | 195 // You should NOT directly create a BookmarkModel, instead go through the |
| 195 // Profile. | 196 // BookmarkModelFactory. |
| 196 class BookmarkModel : public content::NotificationObserver, | 197 class BookmarkModel : public content::NotificationObserver, |
| 197 public BookmarkService { | 198 public BookmarkService, |
| 199 public ProfileKeyedService { |
| 198 public: | 200 public: |
| 199 explicit BookmarkModel(Profile* profile); | 201 explicit BookmarkModel(Profile* profile); |
| 200 virtual ~BookmarkModel(); | 202 virtual ~BookmarkModel(); |
| 201 | 203 |
| 202 static void RegisterUserPrefs(PrefService* prefs); | 204 // Invoked prior to destruction to release any necessary resources. |
| 205 void Shutdown() OVERRIDE; |
| 203 | 206 |
| 204 // Invoked prior to destruction to release any necessary resources. | 207 // Loads the bookmarks. This is called upon creation of the |
| 205 void Cleanup(); | |
| 206 | |
| 207 // Loads the bookmarks. This is called by Profile upon creation of the | |
| 208 // BookmarkModel. You need not invoke this directly. | 208 // BookmarkModel. You need not invoke this directly. |
| 209 void Load(); | 209 void Load(); |
| 210 | 210 |
| 211 // Returns true if the model finished loading. | 211 // Returns true if the model finished loading. |
| 212 // This is virtual so it can be mocked. | 212 // This is virtual so it can be mocked. |
| 213 virtual bool IsLoaded() const; | 213 virtual bool IsLoaded() const; |
| 214 | 214 |
| 215 // Returns the root node. The 'bookmark bar' node and 'other' node are | 215 // Returns the root node. The 'bookmark bar' node and 'other' node are |
| 216 // children of the root node. | 216 // children of the root node. |
| 217 const BookmarkNode* root_node() { return &root_; } | 217 const BookmarkNode* root_node() { return &root_; } |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 | 495 |
| 496 // See description of IsDoingExtensiveChanges above. | 496 // See description of IsDoingExtensiveChanges above. |
| 497 int extensive_changes_; | 497 int extensive_changes_; |
| 498 | 498 |
| 499 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; | 499 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; |
| 500 | 500 |
| 501 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); | 501 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); |
| 502 }; | 502 }; |
| 503 | 503 |
| 504 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ | 504 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ |
| OLD | NEW |