| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT_IS
_BOOKMARKED_CONDITION_TRACKER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT_IS
_BOOKMARKED_CONDITION_TRACKER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT_IS
_BOOKMARKED_CONDITION_TRACKER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT_IS
_BOOKMARKED_CONDITION_TRACKER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
| 9 | 10 |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/scoped_observer.h" | 15 #include "base/scoped_observer.h" |
| 16 #include "chrome/browser/extensions/api/declarative_content/content_predicate_ev
aluator.h" | 16 #include "chrome/browser/extensions/api/declarative_content/content_predicate_ev
aluator.h" |
| 17 #include "components/bookmarks/browser/base_bookmark_model_observer.h" | 17 #include "components/bookmarks/browser/base_bookmark_model_observer.h" |
| 18 #include "content/public/browser/web_contents_observer.h" | 18 #include "content/public/browser/web_contents_observer.h" |
| 19 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
| 20 | 20 |
| 21 namespace base { | 21 namespace base { |
| 22 class Value; | 22 class Value; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 class BrowserContext; | 26 class BrowserContext; |
| 27 struct FrameNavigateParams; | 27 struct FrameNavigateParams; |
| 28 struct LoadCommittedDetails; | 28 struct LoadCommittedDetails; |
| 29 class WebContents; | 29 class WebContents; |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace extensions { | 32 namespace extensions { |
| 33 | 33 |
| 34 // Tests the bookmarked state of the page. | 34 // Tests the bookmarked state of the page. |
| 35 class DeclarativeContentIsBookmarkedPredicate : public ContentPredicate { | 35 class DeclarativeContentIsBookmarkedPredicate : public ContentPredicate { |
| 36 public: | 36 public: |
| 37 ~DeclarativeContentIsBookmarkedPredicate() override; | 37 ~DeclarativeContentIsBookmarkedPredicate() override; |
| 38 | 38 |
| 39 bool IsIgnored() const override; | 39 bool IsIgnored() const override; |
| 40 | 40 |
| 41 bool is_bookmarked() const { return is_bookmarked_; } | 41 bool is_bookmarked() const { return is_bookmarked_; } |
| 42 | 42 |
| 43 static scoped_ptr<DeclarativeContentIsBookmarkedPredicate> Create( | 43 static std::unique_ptr<DeclarativeContentIsBookmarkedPredicate> Create( |
| 44 ContentPredicateEvaluator* evaluator, | 44 ContentPredicateEvaluator* evaluator, |
| 45 const Extension* extension, | 45 const Extension* extension, |
| 46 const base::Value& value, | 46 const base::Value& value, |
| 47 std::string* error); | 47 std::string* error); |
| 48 | 48 |
| 49 // ContentPredicate: | 49 // ContentPredicate: |
| 50 ContentPredicateEvaluator* GetEvaluator() const override; | 50 ContentPredicateEvaluator* GetEvaluator() const override; |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 DeclarativeContentIsBookmarkedPredicate( | 53 DeclarativeContentIsBookmarkedPredicate( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 70 : public ContentPredicateEvaluator, | 70 : public ContentPredicateEvaluator, |
| 71 public bookmarks::BaseBookmarkModelObserver { | 71 public bookmarks::BaseBookmarkModelObserver { |
| 72 public: | 72 public: |
| 73 DeclarativeContentIsBookmarkedConditionTracker( | 73 DeclarativeContentIsBookmarkedConditionTracker( |
| 74 content::BrowserContext* context, | 74 content::BrowserContext* context, |
| 75 Delegate* delegate); | 75 Delegate* delegate); |
| 76 ~DeclarativeContentIsBookmarkedConditionTracker() override; | 76 ~DeclarativeContentIsBookmarkedConditionTracker() override; |
| 77 | 77 |
| 78 // ContentPredicateEvaluator: | 78 // ContentPredicateEvaluator: |
| 79 std::string GetPredicateApiAttributeName() const override; | 79 std::string GetPredicateApiAttributeName() const override; |
| 80 scoped_ptr<const ContentPredicate> CreatePredicate( | 80 std::unique_ptr<const ContentPredicate> CreatePredicate( |
| 81 const Extension* extension, | 81 const Extension* extension, |
| 82 const base::Value& value, | 82 const base::Value& value, |
| 83 std::string* error) override; | 83 std::string* error) override; |
| 84 void TrackPredicates( | 84 void TrackPredicates( |
| 85 const std::map<const void*, std::vector<const ContentPredicate*>>& | 85 const std::map<const void*, std::vector<const ContentPredicate*>>& |
| 86 predicates) override; | 86 predicates) override; |
| 87 void StopTrackingPredicates( | 87 void StopTrackingPredicates( |
| 88 const std::vector<const void*>& predicate_groups) override; | 88 const std::vector<const void*>& predicate_groups) override; |
| 89 void TrackForWebContents(content::WebContents* contents) override; | 89 void TrackForWebContents(content::WebContents* contents) override; |
| 90 void OnWebContentsNavigation( | 90 void OnWebContentsNavigation( |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 | 168 |
| 169 ScopedObserver<bookmarks::BookmarkModel, bookmarks::BookmarkModelObserver> | 169 ScopedObserver<bookmarks::BookmarkModel, bookmarks::BookmarkModelObserver> |
| 170 scoped_bookmarks_observer_; | 170 scoped_bookmarks_observer_; |
| 171 | 171 |
| 172 DISALLOW_COPY_AND_ASSIGN(DeclarativeContentIsBookmarkedConditionTracker); | 172 DISALLOW_COPY_AND_ASSIGN(DeclarativeContentIsBookmarkedConditionTracker); |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 } // namespace extensions | 175 } // namespace extensions |
| 176 | 176 |
| 177 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT
_IS_BOOKMARKED_CONDITION_TRACKER_H_ | 177 #endif // CHROME_BROWSER_EXTENSIONS_API_DECLARATIVE_CONTENT_DECLARATIVE_CONTENT
_IS_BOOKMARKED_CONDITION_TRACKER_H_ |
| OLD | NEW |