Chromium Code Reviews| Index: chrome/browser/extensions/api/feedback_private/feedback_private_api.h |
| diff --git a/chrome/browser/extensions/api/feedback_private/feedback_private_api.h b/chrome/browser/extensions/api/feedback_private/feedback_private_api.h |
| index 3ff94b9c3f70f5f313d42f5b347febf6d19bc50d..2fbc6a0d4838171f0265caa7e7bb62572c053cb7 100644 |
| --- a/chrome/browser/extensions/api/feedback_private/feedback_private_api.h |
| +++ b/chrome/browser/extensions/api/feedback_private/feedback_private_api.h |
| @@ -12,6 +12,12 @@ |
| #include "extensions/browser/extension_function.h" |
| #include "ui/gfx/geometry/rect.h" |
| +#if defined(OS_CHROMEOS) |
| +#include "base/time/time.h" |
| +#include "chrome/browser/chromeos/system_logs/single_log_source.h" |
| +#include "chrome/browser/extensions/api/feedback_private/log_source_access_manager.h" |
| +#endif // defined(OS_CHROMEOS) |
| + |
| namespace extensions { |
| class FeedbackService; |
| @@ -23,6 +29,12 @@ class FeedbackPrivateAPI : public BrowserContextKeyedAPI { |
| FeedbackService* GetService() const; |
| +#if defined(OS_CHROMEOS) |
| + LogSourceAccessManager* log_source_access_manager() { |
| + return log_source_access_manager_; |
| + } |
| +#endif // defined(OS_CHROMEOS) |
| + |
| void RequestFeedback(const std::string& description_template, |
| const std::string& category_tag, |
| const GURL& page_url); |
| @@ -48,6 +60,10 @@ class FeedbackPrivateAPI : public BrowserContextKeyedAPI { |
| content::BrowserContext* const browser_context_; |
| FeedbackService* service_; |
| + |
| +#if defined(OS_CHROMEOS) |
| + LogSourceAccessManager* log_source_access_manager_; |
|
tbarzic
2017/06/01 19:23:46
Does this have to be a pointer, the object lifetim
Simon Que
2017/06/01 21:49:09
Done.
|
| +#endif // defined(OS_CHROMEOS) |
| }; |
| // Feedback strings. |
| @@ -95,6 +111,46 @@ class FeedbackPrivateGetSystemInformationFunction |
| void OnCompleted(std::unique_ptr<system_logs::SystemLogsResponse> sys_info); |
| }; |
| +// This function only reads from actual log sources on Chrome OS. On other |
| +// platforms, it just returns EmptyResponse(). |
| +class FeedbackPrivateReadLogSourceFunction : public UIThreadExtensionFunction { |
| + public: |
| + DECLARE_EXTENSION_FUNCTION("feedbackPrivate.readLogSource", |
| + FEEDBACKPRIVATE_READLOGSOURCE); |
| + |
| + protected: |
| + ~FeedbackPrivateReadLogSourceFunction() override {} |
| + ResponseAction Run() override; |
| + |
| +#if defined(OS_CHROMEOS) |
| + private: |
| + // Looks for an existing LogSourceResource in the API Resource Manager with |
| + // id=|*reader_id|. |
| + // - If the resource exists and was created by the same extension, returns the |
| + // corresponding resource's SingleLogSource. |
| + // - If the resource exists and was created by a different extension, returns |
| + // nullptr. |
| + // - If the resource does not exist and there is no existing resource with |
| + // source=|source| for the current extension, creates one, stores it in the |
| + // API Resource Manager, and returns the new resource's SingleLogSource. |
| + // - If the resource does not exist and there is already an existing resource |
| + // source=|source| for the current extension, returns nullptr. |
| + // |
| + // |*reader_id|=0 means the resource does not exist. In that case, the created |
| + // resource will have a new ID that is returned in |*reader_id|. |
| + // |
| + // All returned pointers are owned by the API Resource Manager. |
| + system_logs::SingleLogSource* GetOrCreateSingleLogSource( |
| + int* reader_id, |
| + api::feedback_private::LogSource source); |
| + |
| + void OnCompleted(api::feedback_private::LogSource source, |
| + int readerId, |
| + bool incremental, |
| + system_logs::SystemLogsResponse* response); |
| +#endif // defined(OS_CHROMEOS) |
| +}; |
| + |
| class FeedbackPrivateSendFeedbackFunction |
| : public ChromeAsyncExtensionFunction { |
| public: |