Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/extensions/api/feedback_private/feedback_private_api.h

Issue 2840103002: Add new API function: feedbackPrivate.readLogSource (Closed)
Patch Set: Add comments to SingleLogSourceFactory; Add new histogram enum Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "chrome/browser/extensions/chrome_extension_function.h" 8 #include "chrome/browser/extensions/chrome_extension_function.h"
9 #include "chrome/browser/feedback/system_logs/system_logs_fetcher_base.h" 9 #include "chrome/browser/feedback/system_logs/system_logs_fetcher_base.h"
10 #include "chrome/common/extensions/api/feedback_private.h" 10 #include "chrome/common/extensions/api/feedback_private.h"
11 #include "extensions/browser/browser_context_keyed_api_factory.h" 11 #include "extensions/browser/browser_context_keyed_api_factory.h"
12 #include "extensions/browser/extension_function.h" 12 #include "extensions/browser/extension_function.h"
13 #include "ui/gfx/geometry/rect.h" 13 #include "ui/gfx/geometry/rect.h"
14 14
15 #if defined(OS_CHROMEOS)
16 #include "base/time/time.h"
17 #include "chrome/browser/extensions/api/feedback_private/log_source_access_manag er.h"
18 #endif // defined(OS_CHROMEOS)
19
15 namespace extensions { 20 namespace extensions {
16 21
17 class FeedbackService; 22 class FeedbackService;
18 23
19 class FeedbackPrivateAPI : public BrowserContextKeyedAPI { 24 class FeedbackPrivateAPI : public BrowserContextKeyedAPI {
20 public: 25 public:
21 explicit FeedbackPrivateAPI(content::BrowserContext* context); 26 explicit FeedbackPrivateAPI(content::BrowserContext* context);
22 ~FeedbackPrivateAPI() override; 27 ~FeedbackPrivateAPI() override;
23 28
24 FeedbackService* GetService() const; 29 FeedbackService* GetService() const;
25 30
31 #if defined(OS_CHROMEOS)
32 LogSourceAccessManager* GetLogSourceAccessManager() { return &manager_; }
33 #endif // defined(OS_CHROMEOS)
34
26 void RequestFeedback(const std::string& description_template, 35 void RequestFeedback(const std::string& description_template,
27 const std::string& category_tag, 36 const std::string& category_tag,
28 const GURL& page_url); 37 const GURL& page_url);
29 38
30 void RequestFeedbackForFlow(const std::string& description_template, 39 void RequestFeedbackForFlow(const std::string& description_template,
31 const std::string& category_tag, 40 const std::string& category_tag,
32 const GURL& page_url, 41 const GURL& page_url,
33 api::feedback_private::FeedbackFlow flow); 42 api::feedback_private::FeedbackFlow flow);
34 43
35 // BrowserContextKeyedAPI implementation. 44 // BrowserContextKeyedAPI implementation.
36 static BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>* 45 static BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>*
37 GetFactoryInstance(); 46 GetFactoryInstance();
38 47
39 private: 48 private:
40 friend class BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>; 49 friend class BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>;
41 50
42 // BrowserContextKeyedAPI implementation. 51 // BrowserContextKeyedAPI implementation.
43 static const char* service_name() { 52 static const char* service_name() {
44 return "FeedbackPrivateAPI"; 53 return "FeedbackPrivateAPI";
45 } 54 }
46 55
47 static const bool kServiceHasOwnInstanceInIncognito = true; 56 static const bool kServiceHasOwnInstanceInIncognito = true;
48 57
49 content::BrowserContext* const browser_context_; 58 content::BrowserContext* const browser_context_;
50 FeedbackService* service_; 59 FeedbackService* service_;
60 #if defined(OS_CHROMEOS)
61 LogSourceAccessManager manager_;
62 #endif // defined(OS_CHROMEOS)
51 }; 63 };
52 64
53 // Feedback strings. 65 // Feedback strings.
54 class FeedbackPrivateGetStringsFunction : public UIThreadExtensionFunction { 66 class FeedbackPrivateGetStringsFunction : public UIThreadExtensionFunction {
55 public: 67 public:
56 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getStrings", 68 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getStrings",
57 FEEDBACKPRIVATE_GETSTRINGS) 69 FEEDBACKPRIVATE_GETSTRINGS)
58 70
59 // Invoke this callback when this function is called - used for testing. 71 // Invoke this callback when this function is called - used for testing.
60 static void set_test_callback(base::Closure* const callback) { 72 static void set_test_callback(base::Closure* const callback) {
(...skipping 27 matching lines...) Expand all
88 FEEDBACKPRIVATE_GETSYSTEMINFORMATION); 100 FEEDBACKPRIVATE_GETSYSTEMINFORMATION);
89 101
90 protected: 102 protected:
91 ~FeedbackPrivateGetSystemInformationFunction() override {} 103 ~FeedbackPrivateGetSystemInformationFunction() override {}
92 ResponseAction Run() override; 104 ResponseAction Run() override;
93 105
94 private: 106 private:
95 void OnCompleted(std::unique_ptr<system_logs::SystemLogsResponse> sys_info); 107 void OnCompleted(std::unique_ptr<system_logs::SystemLogsResponse> sys_info);
96 }; 108 };
97 109
110 // This function only reads from actual log sources on Chrome OS. On other
111 // platforms, it just returns EmptyResponse().
112 class FeedbackPrivateReadLogSourceFunction : public UIThreadExtensionFunction {
113 public:
114 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.readLogSource",
115 FEEDBACKPRIVATE_READLOGSOURCE);
116
117 #if defined(OS_CHROMEOS)
118 // To override the default rate-limiting mechanism of this function, pass in
119 // a TimeDelta representing the desired minimum time between consecutive reads
120 // of a source from an extension. Does not take ownership of |timeout|. When
121 // done testing, call this function again with |timeout|=nullptr to reset to
122 // the default behavior.
123 static void SetRateLimitingTimeoutForTesting(const base::TimeDelta* timeout);
124 #endif // defined(OS_CHROMEOS)
125
126 protected:
127 ~FeedbackPrivateReadLogSourceFunction() override {}
128 ResponseAction Run() override;
129
130 private:
131 // Returns a default response to the API that contains no data. Return this
132 // from Run() when it hits an error case and needs to return early, or on
133 // platforms where the ReadLogSource capability is not supported.
134 ResponseAction EmptyResponse();
135
136 #if defined(OS_CHROMEOS)
137 void OnCompleted(api::feedback_private::LogSource source,
138 int readerId,
139 bool incremental,
140 system_logs::SystemLogsResponse* response);
141 #endif // defined(OS_CHROMEOS)
142 };
143
98 class FeedbackPrivateSendFeedbackFunction 144 class FeedbackPrivateSendFeedbackFunction
99 : public ChromeAsyncExtensionFunction { 145 : public ChromeAsyncExtensionFunction {
100 public: 146 public:
101 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.sendFeedback", 147 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.sendFeedback",
102 FEEDBACKPRIVATE_SENDFEEDBACK); 148 FEEDBACKPRIVATE_SENDFEEDBACK);
103 149
104 protected: 150 protected:
105 ~FeedbackPrivateSendFeedbackFunction() override {} 151 ~FeedbackPrivateSendFeedbackFunction() override {}
106 bool RunAsync() override; 152 bool RunAsync() override;
107 153
108 private: 154 private:
109 void OnCompleted(bool success); 155 void OnCompleted(bool success);
110 }; 156 };
111 157
112 class FeedbackPrivateLogSrtPromptResultFunction 158 class FeedbackPrivateLogSrtPromptResultFunction
113 : public UIThreadExtensionFunction { 159 : public UIThreadExtensionFunction {
114 public: 160 public:
115 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.logSrtPromptResult", 161 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.logSrtPromptResult",
116 FEEDBACKPRIVATE_LOGSRTPROMPTRESULT); 162 FEEDBACKPRIVATE_LOGSRTPROMPTRESULT);
117 163
118 protected: 164 protected:
119 ~FeedbackPrivateLogSrtPromptResultFunction() override {} 165 ~FeedbackPrivateLogSrtPromptResultFunction() override {}
120 AsyncExtensionFunction::ResponseAction Run() override; 166 AsyncExtensionFunction::ResponseAction Run() override;
121 }; 167 };
122 168
123 } // namespace extensions 169 } // namespace extensions
124 170
125 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H _ 171 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698