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

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: Responded to comments from Patch Set 14 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 <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
15 namespace extensions { 17 namespace extensions {
16 18
17 class FeedbackService; 19 class FeedbackService;
20 class LogSourceAccessManager;
18 21
19 class FeedbackPrivateAPI : public BrowserContextKeyedAPI { 22 class FeedbackPrivateAPI : public BrowserContextKeyedAPI {
20 public: 23 public:
21 explicit FeedbackPrivateAPI(content::BrowserContext* context); 24 explicit FeedbackPrivateAPI(content::BrowserContext* context);
22 ~FeedbackPrivateAPI() override; 25 ~FeedbackPrivateAPI() override;
23 26
24 FeedbackService* GetService() const; 27 FeedbackService* GetService() const;
25 28
29 #if defined(OS_CHROMEOS)
30 LogSourceAccessManager* GetLogSourceAccessManager() const {
31 return log_source_access_manager_.get();
tbarzic 2017/06/07 17:58:38 nit: this should now go to .cc
Simon Que 2017/06/07 18:25:58 Done.
32 }
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 std::unique_ptr<FeedbackService> service_;
60
61 #if defined(OS_CHROMEOS)
62 std::unique_ptr<LogSourceAccessManager> log_source_access_manager_;
63 #endif // defined(OS_CHROMEOS)
tbarzic 2017/06/07 17:58:38 nit: add DISALLOW_COPY_AND_ASSIGN(FeedbackPrivateA
Simon Que 2017/06/07 18:25:58 Done.
51 }; 64 };
52 65
53 // Feedback strings. 66 // Feedback strings.
54 class FeedbackPrivateGetStringsFunction : public UIThreadExtensionFunction { 67 class FeedbackPrivateGetStringsFunction : public UIThreadExtensionFunction {
55 public: 68 public:
56 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getStrings", 69 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getStrings",
57 FEEDBACKPRIVATE_GETSTRINGS) 70 FEEDBACKPRIVATE_GETSTRINGS)
58 71
59 // Invoke this callback when this function is called - used for testing. 72 // Invoke this callback when this function is called - used for testing.
60 static void set_test_callback(base::Closure* const callback) { 73 static void set_test_callback(base::Closure* const callback) {
(...skipping 27 matching lines...) Expand all
88 FEEDBACKPRIVATE_GETSYSTEMINFORMATION); 101 FEEDBACKPRIVATE_GETSYSTEMINFORMATION);
89 102
90 protected: 103 protected:
91 ~FeedbackPrivateGetSystemInformationFunction() override {} 104 ~FeedbackPrivateGetSystemInformationFunction() override {}
92 ResponseAction Run() override; 105 ResponseAction Run() override;
93 106
94 private: 107 private:
95 void OnCompleted(std::unique_ptr<system_logs::SystemLogsResponse> sys_info); 108 void OnCompleted(std::unique_ptr<system_logs::SystemLogsResponse> sys_info);
96 }; 109 };
97 110
111 // This function only reads from actual log sources on Chrome OS. On other
112 // platforms, it just returns EmptyResponse().
113 class FeedbackPrivateReadLogSourceFunction : public UIThreadExtensionFunction {
114 public:
115 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.readLogSource",
116 FEEDBACKPRIVATE_READLOGSOURCE);
117
118 protected:
119 ~FeedbackPrivateReadLogSourceFunction() override {}
120 ResponseAction Run() override;
121
122 #if defined(OS_CHROMEOS)
123 private:
124 void OnCompleted(api::feedback_private::ReadLogSourceResult& result);
125 #endif // defined(OS_CHROMEOS)
126 };
127
98 class FeedbackPrivateSendFeedbackFunction 128 class FeedbackPrivateSendFeedbackFunction
99 : public ChromeAsyncExtensionFunction { 129 : public ChromeAsyncExtensionFunction {
100 public: 130 public:
101 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.sendFeedback", 131 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.sendFeedback",
102 FEEDBACKPRIVATE_SENDFEEDBACK); 132 FEEDBACKPRIVATE_SENDFEEDBACK);
103 133
104 protected: 134 protected:
105 ~FeedbackPrivateSendFeedbackFunction() override {} 135 ~FeedbackPrivateSendFeedbackFunction() override {}
106 bool RunAsync() override; 136 bool RunAsync() override;
107 137
108 private: 138 private:
109 void OnCompleted(bool success); 139 void OnCompleted(bool success);
110 }; 140 };
111 141
112 class FeedbackPrivateLogSrtPromptResultFunction 142 class FeedbackPrivateLogSrtPromptResultFunction
113 : public UIThreadExtensionFunction { 143 : public UIThreadExtensionFunction {
114 public: 144 public:
115 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.logSrtPromptResult", 145 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.logSrtPromptResult",
116 FEEDBACKPRIVATE_LOGSRTPROMPTRESULT); 146 FEEDBACKPRIVATE_LOGSRTPROMPTRESULT);
117 147
118 protected: 148 protected:
119 ~FeedbackPrivateLogSrtPromptResultFunction() override {} 149 ~FeedbackPrivateLogSrtPromptResultFunction() override {}
120 AsyncExtensionFunction::ResponseAction Run() override; 150 AsyncExtensionFunction::ResponseAction Run() override;
121 }; 151 };
122 152
123 } // namespace extensions 153 } // namespace extensions
124 154
125 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H _ 155 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698