| 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 | 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 "base/task/cancelable_task_tracker.h" | 20 #include "base/task/cancelable_task_tracker.h" |
| 21 #include "chrome/browser/bookmarks/bookmark_service.h" | 21 #include "chrome/browser/bookmarks/bookmark_service.h" |
| 22 #include "components/bookmarks/core/browser/bookmark_client.h" |
| 22 #include "components/bookmarks/core/browser/bookmark_node.h" | 23 #include "components/bookmarks/core/browser/bookmark_node.h" |
| 23 #include "components/favicon_base/favicon_types.h" | |
| 24 #include "components/keyed_service/core/keyed_service.h" | 24 #include "components/keyed_service/core/keyed_service.h" |
| 25 #include "content/public/browser/notification_observer.h" | 25 #include "content/public/browser/notification_observer.h" |
| 26 #include "content/public/browser/notification_registrar.h" | 26 #include "content/public/browser/notification_registrar.h" |
| 27 #include "ui/gfx/image/image.h" | 27 #include "ui/gfx/image/image.h" |
| 28 #include "url/gurl.h" | 28 #include "url/gurl.h" |
| 29 | 29 |
| 30 class BookmarkExpandedStateTracker; | 30 class BookmarkExpandedStateTracker; |
| 31 class BookmarkIndex; | 31 class BookmarkIndex; |
| 32 class BookmarkLoadDetails; | 32 class BookmarkLoadDetails; |
| 33 class BookmarkModelObserver; | 33 class BookmarkModelObserver; |
| 34 class BookmarkStorage; | 34 class BookmarkStorage; |
| 35 struct BookmarkTitleMatch; | 35 struct BookmarkTitleMatch; |
| 36 class Profile; | 36 class Profile; |
| 37 class ScopedGroupBookmarkActions; | 37 class ScopedGroupBookmarkActions; |
| 38 | 38 |
| 39 namespace base { | 39 namespace base { |
| 40 class SequencedTaskRunner; | 40 class SequencedTaskRunner; |
| 41 } | 41 } |
| 42 | 42 |
| 43 namespace chrome { | |
| 44 struct FaviconImageResult; | |
| 45 } | |
| 46 | |
| 47 // BookmarkModel -------------------------------------------------------------- | 43 // BookmarkModel -------------------------------------------------------------- |
| 48 | 44 |
| 49 // BookmarkModel provides a directed acyclic graph of URLs and folders. | 45 // BookmarkModel provides a directed acyclic graph of URLs and folders. |
| 50 // Three graphs are provided for the three entry points: those on the 'bookmarks | 46 // Three graphs are provided for the three entry points: those on the 'bookmarks |
| 51 // bar', those in the 'other bookmarks' folder and those in the 'mobile' folder. | 47 // bar', those in the 'other bookmarks' folder and those in the 'mobile' folder. |
| 52 // | 48 // |
| 53 // An observer may be attached to observe relevant events. | 49 // An observer may be attached to observe relevant events. |
| 54 // | 50 // |
| 55 // You should NOT directly create a BookmarkModel, instead go through the | 51 // You should NOT directly create a BookmarkModel, instead go through the |
| 56 // BookmarkModelFactory. | 52 // BookmarkModelFactory. |
| 57 class BookmarkModel : public content::NotificationObserver, | 53 class BookmarkModel : public content::NotificationObserver, |
| 54 public BookmarkClient, |
| 58 public BookmarkService, | 55 public BookmarkService, |
| 59 public KeyedService { | 56 public KeyedService { |
| 60 public: | 57 public: |
| 61 explicit BookmarkModel(Profile* profile); | 58 explicit BookmarkModel(Profile* profile); |
| 62 virtual ~BookmarkModel(); | 59 virtual ~BookmarkModel(); |
| 63 | 60 |
| 61 virtual base::CancelableTaskTracker::TaskId GetFaviconImageForURL( |
| 62 const GURL& page_url, |
| 63 int icon_types, |
| 64 int desired_size_in_dip, |
| 65 const FaviconImageCallback& callback, |
| 66 base::CancelableTaskTracker* tracker) OVERRIDE; |
| 67 |
| 68 virtual void ExtractBookmarkNodePairs( |
| 69 const NodeSet& nodes, |
| 70 NodeTypedCountPairs* node_typed_count_pairs) OVERRIDE; |
| 71 |
| 72 virtual void RecordAction(const base::UserMetricsAction& action) OVERRIDE; |
| 73 |
| 74 virtual bool PostTask(const tracked_objects::Location& from_here, |
| 75 const base::Closure& task) OVERRIDE; |
| 76 |
| 64 // Invoked prior to destruction to release any necessary resources. | 77 // Invoked prior to destruction to release any necessary resources. |
| 65 virtual void Shutdown() OVERRIDE; | 78 virtual void Shutdown() OVERRIDE; |
| 66 | 79 |
| 67 // Loads the bookmarks. This is called upon creation of the | 80 // Loads the bookmarks. This is called upon creation of the |
| 68 // BookmarkModel. You need not invoke this directly. | 81 // BookmarkModel. You need not invoke this directly. |
| 69 // All load operations will be executed on |task_runner|. | 82 // All load operations will be executed on |task_runner|. |
| 70 void Load(const scoped_refptr<base::SequencedTaskRunner>& task_runner); | 83 void Load(const scoped_refptr<base::SequencedTaskRunner>& task_runner); |
| 71 | 84 |
| 72 // Returns true if the model finished loading. | 85 // Returns true if the model finished loading. |
| 73 bool loaded() const { return loaded_; } | 86 bool loaded() const { return loaded_; } |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 | 408 |
| 396 // See description of IsDoingExtensiveChanges above. | 409 // See description of IsDoingExtensiveChanges above. |
| 397 int extensive_changes_; | 410 int extensive_changes_; |
| 398 | 411 |
| 399 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; | 412 scoped_ptr<BookmarkExpandedStateTracker> expanded_state_tracker_; |
| 400 | 413 |
| 401 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); | 414 DISALLOW_COPY_AND_ASSIGN(BookmarkModel); |
| 402 }; | 415 }; |
| 403 | 416 |
| 404 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ | 417 #endif // CHROME_BROWSER_BOOKMARKS_BOOKMARK_MODEL_H_ |
| OLD | NEW |