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