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

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: Rebased; updated histogram enum Created 3 years, 6 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/chromeos/system_logs/single_log_source.h"
18 #include "chrome/browser/extensions/api/feedback_private/log_source_access_manag er.h"
19 #endif // defined(OS_CHROMEOS)
20
15 namespace extensions { 21 namespace extensions {
16 22
17 class FeedbackService; 23 class FeedbackService;
18 24
19 class FeedbackPrivateAPI : public BrowserContextKeyedAPI { 25 class FeedbackPrivateAPI : public BrowserContextKeyedAPI {
20 public: 26 public:
21 explicit FeedbackPrivateAPI(content::BrowserContext* context); 27 explicit FeedbackPrivateAPI(content::BrowserContext* context);
22 ~FeedbackPrivateAPI() override; 28 ~FeedbackPrivateAPI() override;
23 29
24 FeedbackService* GetService() const; 30 FeedbackService* GetService() const;
25 31
32 #if defined(OS_CHROMEOS)
33 LogSourceAccessManager* log_source_access_manager() {
34 return log_source_access_manager_;
35 }
36 #endif // defined(OS_CHROMEOS)
37
26 void RequestFeedback(const std::string& description_template, 38 void RequestFeedback(const std::string& description_template,
27 const std::string& category_tag, 39 const std::string& category_tag,
28 const GURL& page_url); 40 const GURL& page_url);
29 41
30 void RequestFeedbackForFlow(const std::string& description_template, 42 void RequestFeedbackForFlow(const std::string& description_template,
31 const std::string& category_tag, 43 const std::string& category_tag,
32 const GURL& page_url, 44 const GURL& page_url,
33 api::feedback_private::FeedbackFlow flow); 45 api::feedback_private::FeedbackFlow flow);
34 46
35 // BrowserContextKeyedAPI implementation. 47 // BrowserContextKeyedAPI implementation.
36 static BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>* 48 static BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>*
37 GetFactoryInstance(); 49 GetFactoryInstance();
38 50
39 private: 51 private:
40 friend class BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>; 52 friend class BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>;
41 53
42 // BrowserContextKeyedAPI implementation. 54 // BrowserContextKeyedAPI implementation.
43 static const char* service_name() { 55 static const char* service_name() {
44 return "FeedbackPrivateAPI"; 56 return "FeedbackPrivateAPI";
45 } 57 }
46 58
47 static const bool kServiceHasOwnInstanceInIncognito = true; 59 static const bool kServiceHasOwnInstanceInIncognito = true;
48 60
49 content::BrowserContext* const browser_context_; 61 content::BrowserContext* const browser_context_;
50 FeedbackService* service_; 62 FeedbackService* service_;
63
64 #if defined(OS_CHROMEOS)
65 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.
66 #endif // defined(OS_CHROMEOS)
51 }; 67 };
52 68
53 // Feedback strings. 69 // Feedback strings.
54 class FeedbackPrivateGetStringsFunction : public UIThreadExtensionFunction { 70 class FeedbackPrivateGetStringsFunction : public UIThreadExtensionFunction {
55 public: 71 public:
56 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getStrings", 72 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getStrings",
57 FEEDBACKPRIVATE_GETSTRINGS) 73 FEEDBACKPRIVATE_GETSTRINGS)
58 74
59 // Invoke this callback when this function is called - used for testing. 75 // Invoke this callback when this function is called - used for testing.
60 static void set_test_callback(base::Closure* const callback) { 76 static void set_test_callback(base::Closure* const callback) {
(...skipping 27 matching lines...) Expand all
88 FEEDBACKPRIVATE_GETSYSTEMINFORMATION); 104 FEEDBACKPRIVATE_GETSYSTEMINFORMATION);
89 105
90 protected: 106 protected:
91 ~FeedbackPrivateGetSystemInformationFunction() override {} 107 ~FeedbackPrivateGetSystemInformationFunction() override {}
92 ResponseAction Run() override; 108 ResponseAction Run() override;
93 109
94 private: 110 private:
95 void OnCompleted(std::unique_ptr<system_logs::SystemLogsResponse> sys_info); 111 void OnCompleted(std::unique_ptr<system_logs::SystemLogsResponse> sys_info);
96 }; 112 };
97 113
114 // This function only reads from actual log sources on Chrome OS. On other
115 // platforms, it just returns EmptyResponse().
116 class FeedbackPrivateReadLogSourceFunction : public UIThreadExtensionFunction {
117 public:
118 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.readLogSource",
119 FEEDBACKPRIVATE_READLOGSOURCE);
120
121 protected:
122 ~FeedbackPrivateReadLogSourceFunction() override {}
123 ResponseAction Run() override;
124
125 #if defined(OS_CHROMEOS)
126 private:
127 // Looks for an existing LogSourceResource in the API Resource Manager with
128 // id=|*reader_id|.
129 // - If the resource exists and was created by the same extension, returns the
130 // corresponding resource's SingleLogSource.
131 // - If the resource exists and was created by a different extension, returns
132 // nullptr.
133 // - If the resource does not exist and there is no existing resource with
134 // source=|source| for the current extension, creates one, stores it in the
135 // API Resource Manager, and returns the new resource's SingleLogSource.
136 // - If the resource does not exist and there is already an existing resource
137 // source=|source| for the current extension, returns nullptr.
138 //
139 // |*reader_id|=0 means the resource does not exist. In that case, the created
140 // resource will have a new ID that is returned in |*reader_id|.
141 //
142 // All returned pointers are owned by the API Resource Manager.
143 system_logs::SingleLogSource* GetOrCreateSingleLogSource(
144 int* reader_id,
145 api::feedback_private::LogSource source);
146
147 void OnCompleted(api::feedback_private::LogSource source,
148 int readerId,
149 bool incremental,
150 system_logs::SystemLogsResponse* response);
151 #endif // defined(OS_CHROMEOS)
152 };
153
98 class FeedbackPrivateSendFeedbackFunction 154 class FeedbackPrivateSendFeedbackFunction
99 : public ChromeAsyncExtensionFunction { 155 : public ChromeAsyncExtensionFunction {
100 public: 156 public:
101 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.sendFeedback", 157 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.sendFeedback",
102 FEEDBACKPRIVATE_SENDFEEDBACK); 158 FEEDBACKPRIVATE_SENDFEEDBACK);
103 159
104 protected: 160 protected:
105 ~FeedbackPrivateSendFeedbackFunction() override {} 161 ~FeedbackPrivateSendFeedbackFunction() override {}
106 bool RunAsync() override; 162 bool RunAsync() override;
107 163
108 private: 164 private:
109 void OnCompleted(bool success); 165 void OnCompleted(bool success);
110 }; 166 };
111 167
112 class FeedbackPrivateLogSrtPromptResultFunction 168 class FeedbackPrivateLogSrtPromptResultFunction
113 : public UIThreadExtensionFunction { 169 : public UIThreadExtensionFunction {
114 public: 170 public:
115 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.logSrtPromptResult", 171 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.logSrtPromptResult",
116 FEEDBACKPRIVATE_LOGSRTPROMPTRESULT); 172 FEEDBACKPRIVATE_LOGSRTPROMPTRESULT);
117 173
118 protected: 174 protected:
119 ~FeedbackPrivateLogSrtPromptResultFunction() override {} 175 ~FeedbackPrivateLogSrtPromptResultFunction() override {}
120 AsyncExtensionFunction::ResponseAction Run() override; 176 AsyncExtensionFunction::ResponseAction Run() override;
121 }; 177 };
122 178
123 } // namespace extensions 179 } // namespace extensions
124 180
125 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H _ 181 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698