Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H_ |
| 7 | 7 |
| 8 #include <memory> | |
| 9 | |
| 8 #include "chrome/browser/extensions/chrome_extension_function.h" | 10 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 9 #include "chrome/browser/feedback/system_logs/system_logs_fetcher_base.h" | 11 #include "chrome/browser/feedback/system_logs/system_logs_fetcher_base.h" |
| 10 #include "chrome/common/extensions/api/feedback_private.h" | 12 #include "chrome/common/extensions/api/feedback_private.h" |
| 11 #include "extensions/browser/browser_context_keyed_api_factory.h" | 13 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 12 #include "extensions/browser/extension_function.h" | 14 #include "extensions/browser/extension_function.h" |
| 13 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
| 14 | 16 |
| 17 #if defined(OS_CHROMEOS) | |
| 18 #include "base/time/time.h" | |
|
tbarzic
2017/06/06 20:27:25
nit: can you clean these up.
Simon Que
2017/06/06 22:29:14
Done.
| |
| 19 #include "chrome/browser/chromeos/system_logs/single_log_source.h" | |
| 20 #include "chrome/browser/extensions/api/feedback_private/log_source_access_manag er.h" | |
|
tbarzic
2017/06/06 20:27:25
nit: you can forward declare this one
Simon Que
2017/06/06 22:29:14
Done.
| |
| 21 #endif // defined(OS_CHROMEOS) | |
| 22 | |
| 15 namespace extensions { | 23 namespace extensions { |
| 16 | 24 |
| 17 class FeedbackService; | 25 class FeedbackService; |
| 18 | 26 |
| 19 class FeedbackPrivateAPI : public BrowserContextKeyedAPI { | 27 class FeedbackPrivateAPI : public BrowserContextKeyedAPI { |
| 20 public: | 28 public: |
| 21 explicit FeedbackPrivateAPI(content::BrowserContext* context); | 29 explicit FeedbackPrivateAPI(content::BrowserContext* context); |
| 22 ~FeedbackPrivateAPI() override; | 30 ~FeedbackPrivateAPI() override; |
| 23 | 31 |
| 24 FeedbackService* GetService() const; | 32 FeedbackService* GetService() const; |
| 25 | 33 |
| 34 #if defined(OS_CHROMEOS) | |
| 35 LogSourceAccessManager* log_source_access_manager() const { | |
| 36 return log_source_access_manager_.get(); | |
|
tbarzic
2017/06/06 20:27:25
nit: can rename this to GetLockSourceAcceeManager
Simon Que
2017/06/06 22:29:14
Done.
| |
| 37 } | |
| 38 #endif // defined(OS_CHROMEOS) | |
| 39 | |
| 26 void RequestFeedback(const std::string& description_template, | 40 void RequestFeedback(const std::string& description_template, |
| 27 const std::string& category_tag, | 41 const std::string& category_tag, |
| 28 const GURL& page_url); | 42 const GURL& page_url); |
| 29 | 43 |
| 30 void RequestFeedbackForFlow(const std::string& description_template, | 44 void RequestFeedbackForFlow(const std::string& description_template, |
| 31 const std::string& category_tag, | 45 const std::string& category_tag, |
| 32 const GURL& page_url, | 46 const GURL& page_url, |
| 33 api::feedback_private::FeedbackFlow flow); | 47 api::feedback_private::FeedbackFlow flow); |
| 34 | 48 |
| 35 // BrowserContextKeyedAPI implementation. | 49 // BrowserContextKeyedAPI implementation. |
| 36 static BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>* | 50 static BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>* |
| 37 GetFactoryInstance(); | 51 GetFactoryInstance(); |
| 38 | 52 |
| 39 private: | 53 private: |
| 40 friend class BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>; | 54 friend class BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>; |
| 41 | 55 |
| 42 // BrowserContextKeyedAPI implementation. | 56 // BrowserContextKeyedAPI implementation. |
| 43 static const char* service_name() { | 57 static const char* service_name() { |
| 44 return "FeedbackPrivateAPI"; | 58 return "FeedbackPrivateAPI"; |
| 45 } | 59 } |
| 46 | 60 |
| 47 static const bool kServiceHasOwnInstanceInIncognito = true; | 61 static const bool kServiceHasOwnInstanceInIncognito = true; |
| 48 | 62 |
| 49 content::BrowserContext* const browser_context_; | 63 content::BrowserContext* const browser_context_; |
| 50 FeedbackService* service_; | 64 std::unique_ptr<FeedbackService> service_; |
| 65 | |
| 66 #if defined(OS_CHROMEOS) | |
| 67 std::unique_ptr<LogSourceAccessManager> log_source_access_manager_; | |
| 68 #endif // defined(OS_CHROMEOS) | |
| 51 }; | 69 }; |
| 52 | 70 |
| 53 // Feedback strings. | 71 // Feedback strings. |
| 54 class FeedbackPrivateGetStringsFunction : public UIThreadExtensionFunction { | 72 class FeedbackPrivateGetStringsFunction : public UIThreadExtensionFunction { |
| 55 public: | 73 public: |
| 56 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getStrings", | 74 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getStrings", |
| 57 FEEDBACKPRIVATE_GETSTRINGS) | 75 FEEDBACKPRIVATE_GETSTRINGS) |
| 58 | 76 |
| 59 // Invoke this callback when this function is called - used for testing. | 77 // Invoke this callback when this function is called - used for testing. |
| 60 static void set_test_callback(base::Closure* const callback) { | 78 static void set_test_callback(base::Closure* const callback) { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 88 FEEDBACKPRIVATE_GETSYSTEMINFORMATION); | 106 FEEDBACKPRIVATE_GETSYSTEMINFORMATION); |
| 89 | 107 |
| 90 protected: | 108 protected: |
| 91 ~FeedbackPrivateGetSystemInformationFunction() override {} | 109 ~FeedbackPrivateGetSystemInformationFunction() override {} |
| 92 ResponseAction Run() override; | 110 ResponseAction Run() override; |
| 93 | 111 |
| 94 private: | 112 private: |
| 95 void OnCompleted(std::unique_ptr<system_logs::SystemLogsResponse> sys_info); | 113 void OnCompleted(std::unique_ptr<system_logs::SystemLogsResponse> sys_info); |
| 96 }; | 114 }; |
| 97 | 115 |
| 116 // This function only reads from actual log sources on Chrome OS. On other | |
| 117 // platforms, it just returns EmptyResponse(). | |
| 118 class FeedbackPrivateReadLogSourceFunction : public UIThreadExtensionFunction { | |
| 119 public: | |
| 120 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.readLogSource", | |
| 121 FEEDBACKPRIVATE_READLOGSOURCE); | |
| 122 | |
| 123 protected: | |
| 124 ~FeedbackPrivateReadLogSourceFunction() override {} | |
| 125 ResponseAction Run() override; | |
| 126 | |
| 127 #if defined(OS_CHROMEOS) | |
| 128 private: | |
| 129 void OnCompleted(api::feedback_private::ReadLogSourceResult& result); | |
| 130 #endif // defined(OS_CHROMEOS) | |
| 131 }; | |
| 132 | |
| 98 class FeedbackPrivateSendFeedbackFunction | 133 class FeedbackPrivateSendFeedbackFunction |
| 99 : public ChromeAsyncExtensionFunction { | 134 : public ChromeAsyncExtensionFunction { |
| 100 public: | 135 public: |
| 101 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.sendFeedback", | 136 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.sendFeedback", |
| 102 FEEDBACKPRIVATE_SENDFEEDBACK); | 137 FEEDBACKPRIVATE_SENDFEEDBACK); |
| 103 | 138 |
| 104 protected: | 139 protected: |
| 105 ~FeedbackPrivateSendFeedbackFunction() override {} | 140 ~FeedbackPrivateSendFeedbackFunction() override {} |
| 106 bool RunAsync() override; | 141 bool RunAsync() override; |
| 107 | 142 |
| 108 private: | 143 private: |
| 109 void OnCompleted(bool success); | 144 void OnCompleted(bool success); |
| 110 }; | 145 }; |
| 111 | 146 |
| 112 class FeedbackPrivateLogSrtPromptResultFunction | 147 class FeedbackPrivateLogSrtPromptResultFunction |
| 113 : public UIThreadExtensionFunction { | 148 : public UIThreadExtensionFunction { |
| 114 public: | 149 public: |
| 115 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.logSrtPromptResult", | 150 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.logSrtPromptResult", |
| 116 FEEDBACKPRIVATE_LOGSRTPROMPTRESULT); | 151 FEEDBACKPRIVATE_LOGSRTPROMPTRESULT); |
| 117 | 152 |
| 118 protected: | 153 protected: |
| 119 ~FeedbackPrivateLogSrtPromptResultFunction() override {} | 154 ~FeedbackPrivateLogSrtPromptResultFunction() override {} |
| 120 AsyncExtensionFunction::ResponseAction Run() override; | 155 AsyncExtensionFunction::ResponseAction Run() override; |
| 121 }; | 156 }; |
| 122 | 157 |
| 123 } // namespace extensions | 158 } // namespace extensions |
| 124 | 159 |
| 125 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H _ | 160 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H _ |
| OLD | NEW |