| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ | 5 #ifndef COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ |
| 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ | 6 #define COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 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/strings/string16.h" | 17 #include "base/strings/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 "components/bookmarks/browser/bookmark_client.h" | 20 #include "components/bookmarks/browser/bookmark_client.h" |
| 21 #include "components/bookmarks/browser/bookmark_node.h" | 21 #include "components/bookmarks/browser/bookmark_node.h" |
| 22 #include "components/keyed_service/core/keyed_service.h" |
| 22 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
| 23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
| 24 | 25 |
| 25 class BookmarkModelObserver; | 26 class BookmarkModelObserver; |
| 26 class PrefService; | 27 class PrefService; |
| 27 | 28 |
| 28 namespace base { | 29 namespace base { |
| 29 class FilePath; | 30 class FilePath; |
| 30 class SequencedTaskRunner; | 31 class SequencedTaskRunner; |
| 31 } | 32 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 50 // BookmarkModel -------------------------------------------------------------- | 51 // BookmarkModel -------------------------------------------------------------- |
| 51 | 52 |
| 52 // BookmarkModel provides a directed acyclic graph of URLs and folders. | 53 // BookmarkModel provides a directed acyclic graph of URLs and folders. |
| 53 // Three graphs are provided for the three entry points: those on the 'bookmarks | 54 // Three graphs are provided for the three entry points: those on the 'bookmarks |
| 54 // bar', those in the 'other bookmarks' folder and those in the 'mobile' folder. | 55 // bar', those in the 'other bookmarks' folder and those in the 'mobile' folder. |
| 55 // | 56 // |
| 56 // An observer may be attached to observe relevant events. | 57 // An observer may be attached to observe relevant events. |
| 57 // | 58 // |
| 58 // You should NOT directly create a BookmarkModel, instead go through the | 59 // You should NOT directly create a BookmarkModel, instead go through the |
| 59 // BookmarkModelFactory. | 60 // BookmarkModelFactory. |
| 60 class BookmarkModel { | 61 class BookmarkModel : public KeyedService { |
| 61 public: | 62 public: |
| 62 struct URLAndTitle { | 63 struct URLAndTitle { |
| 63 GURL url; | 64 GURL url; |
| 64 base::string16 title; | 65 base::string16 title; |
| 65 }; | 66 }; |
| 66 | 67 |
| 67 // |index_urls| says whether URLs should be stored in the BookmarkIndex | 68 // |index_urls| says whether URLs should be stored in the BookmarkIndex |
| 68 // in addition to bookmark titles. | 69 // in addition to bookmark titles. |
| 69 BookmarkModel(BookmarkClient* client, bool index_urls); | 70 BookmarkModel(BookmarkClient* client, bool index_urls); |
| 70 ~BookmarkModel(); | 71 virtual ~BookmarkModel(); |
| 71 | 72 |
| 72 // Invoked prior to destruction to release any necessary resources. | 73 // KeyedService: |
| 73 void Shutdown(); | 74 virtual void Shutdown() OVERRIDE; |
| 74 | 75 |
| 75 // Loads the bookmarks. This is called upon creation of the | 76 // Loads the bookmarks. This is called upon creation of the |
| 76 // BookmarkModel. You need not invoke this directly. | 77 // BookmarkModel. You need not invoke this directly. |
| 77 // All load operations will be executed on |io_task_runner| and the completion | 78 // All load operations will be executed on |io_task_runner| and the completion |
| 78 // callback will be called from |ui_task_runner|. | 79 // callback will be called from |ui_task_runner|. |
| 79 void Load(PrefService* pref_service, | 80 void Load(PrefService* pref_service, |
| 80 const std::string& accept_languages, | 81 const std::string& accept_languages, |
| 81 const base::FilePath& profile_path, | 82 const base::FilePath& profile_path, |
| 82 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, | 83 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, |
| 83 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner); | 84 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner); |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 | 427 |
| 427 // See description of IsDoingExtensiveChanges above. | 428 // See description of IsDoingExtensiveChanges above. |
| 428 int extensive_changes_; | 429 int extensive_changes_; |
| 429 | 430 |
| 430 scoped_ptr<bookmarks::BookmarkExpandedStateTracker> expanded_state_tracker_; | 431 scoped_ptr<bookmarks::BookmarkExpandedStateTracker> expanded_state_tracker_; |
| 431 | 432 |
| 432 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); | 433 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); |
| 433 }; | 434 }; |
| 434 | 435 |
| 435 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ | 436 #endif // COMPONENTS_BOOKMARKS_BROWSER_BOOKMARK_MODEL_H_ |
| OLD | NEW |