| 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 COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // Returns whether the service is ready. While this is false, the list of | 93 // Returns whether the service is ready. While this is false, the list of |
| 94 // snippets will be empty, and all modifications to it (fetch, discard, etc) | 94 // snippets will be empty, and all modifications to it (fetch, discard, etc) |
| 95 // will be ignored. | 95 // will be ignored. |
| 96 bool ready() const { return state_ == State::READY; } | 96 bool ready() const { return state_ == State::READY; } |
| 97 | 97 |
| 98 // Returns whether the service is initialized. While this is false, some | 98 // Returns whether the service is initialized. While this is false, some |
| 99 // calls may trigger DCHECKs. | 99 // calls may trigger DCHECKs. |
| 100 bool initialized() const { return ready() || state_ == State::DISABLED; } | 100 bool initialized() const { return ready() || state_ == State::DISABLED; } |
| 101 | 101 |
| 102 // Fetches snippets from the server and adds them to the current ones. | 102 // Fetches snippets from the server and adds them to the current ones. |
| 103 void FetchSnippets(); | 103 // Requests can be marked more important by setting |force_request| to true |
| 104 // (such request might circumvent the daily quota for requests, etc.) Useful |
| 105 // for requests triggered by the user. |
| 106 void FetchSnippets(bool force_request); |
| 107 |
| 104 // Fetches snippets from the server for specified hosts (overriding | 108 // Fetches snippets from the server for specified hosts (overriding |
| 105 // suggestions from the suggestion service) and adds them to the current ones. | 109 // suggestions from the suggestion service) and adds them to the current ones. |
| 106 // Only called from chrome://snippets-internals, DO NOT USE otherwise! | 110 // Only called from chrome://snippets-internals, DO NOT USE otherwise! |
| 107 // Ignored while |loaded()| is false. | 111 // Ignored while |loaded()| is false. |
| 108 void FetchSnippetsFromHosts(const std::set<std::string>& hosts); | 112 void FetchSnippetsFromHosts(const std::set<std::string>& hosts, |
| 113 bool force_request); |
| 109 | 114 |
| 110 // Available snippets. | 115 // Available snippets. |
| 111 const NTPSnippet::PtrVector& snippets() const { return snippets_; } | 116 const NTPSnippet::PtrVector& snippets() const { return snippets_; } |
| 112 | 117 |
| 113 // Returns the list of snippets previously discarded by the user (that are | 118 // Returns the list of snippets previously discarded by the user (that are |
| 114 // not expired yet). | 119 // not expired yet). |
| 115 const NTPSnippet::PtrVector& discarded_snippets() const { | 120 const NTPSnippet::PtrVector& discarded_snippets() const { |
| 116 return discarded_snippets_; | 121 return discarded_snippets_; |
| 117 } | 122 } |
| 118 | 123 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 // If the service might be enabled, DisabledReason::NONE will be provided. | 339 // If the service might be enabled, DisabledReason::NONE will be provided. |
| 335 virtual void NTPSnippetsServiceDisabledReasonChanged(DisabledReason) = 0; | 340 virtual void NTPSnippetsServiceDisabledReasonChanged(DisabledReason) = 0; |
| 336 | 341 |
| 337 protected: | 342 protected: |
| 338 virtual ~NTPSnippetsServiceObserver() {} | 343 virtual ~NTPSnippetsServiceObserver() {} |
| 339 }; | 344 }; |
| 340 | 345 |
| 341 } // namespace ntp_snippets | 346 } // namespace ntp_snippets |
| 342 | 347 |
| 343 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ | 348 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ |
| OLD | NEW |