Chromium Code Reviews| 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); | |
| 104 // Fetches snippets from the server for specified hosts (overriding | 107 // Fetches snippets from the server for specified hosts (overriding |
|
Bernhard Bauer
2016/07/22 13:59:14
Nit: can you add an empty line before this comment
jkrcal
2016/07/25 10:05:38
Done.
| |
| 105 // suggestions from the suggestion service) and adds them to the current ones. | 108 // suggestions from the suggestion service) and adds them to the current ones. |
| 106 // Only called from chrome://snippets-internals, DO NOT USE otherwise! | 109 // Only called from chrome://snippets-internals, DO NOT USE otherwise! |
| 107 // Ignored while |loaded()| is false. | 110 // Ignored while |loaded()| is false. |
| 108 void FetchSnippetsFromHosts(const std::set<std::string>& hosts); | 111 void FetchSnippetsFromHosts(const std::set<std::string>& hosts, |
| 112 bool force_request); | |
| 109 | 113 |
| 110 // Available snippets. | 114 // Available snippets. |
| 111 const NTPSnippet::PtrVector& snippets() const { return snippets_; } | 115 const NTPSnippet::PtrVector& snippets() const { return snippets_; } |
| 112 | 116 |
| 113 // Returns the list of snippets previously discarded by the user (that are | 117 // Returns the list of snippets previously discarded by the user (that are |
| 114 // not expired yet). | 118 // not expired yet). |
| 115 const NTPSnippet::PtrVector& discarded_snippets() const { | 119 const NTPSnippet::PtrVector& discarded_snippets() const { |
| 116 return discarded_snippets_; | 120 return discarded_snippets_; |
| 117 } | 121 } |
| 118 | 122 |
| (...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. | 338 // If the service might be enabled, DisabledReason::NONE will be provided. |
| 335 virtual void NTPSnippetsServiceDisabledReasonChanged(DisabledReason) = 0; | 339 virtual void NTPSnippetsServiceDisabledReasonChanged(DisabledReason) = 0; |
| 336 | 340 |
| 337 protected: | 341 protected: |
| 338 virtual ~NTPSnippetsServiceObserver() {} | 342 virtual ~NTPSnippetsServiceObserver() {} |
| 339 }; | 343 }; |
| 340 | 344 |
| 341 } // namespace ntp_snippets | 345 } // namespace ntp_snippets |
| 342 | 346 |
| 343 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ | 347 #endif // COMPONENTS_NTP_SNIPPETS_NTP_SNIPPETS_SERVICE_H_ |
| OLD | NEW |