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

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 proper ifdefs for non-CrOS platforms 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.h" 11 #include "chrome/browser/feedback/system_logs/system_logs_fetcher.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 #if defined(OS_CHROMEOS)
21 class LogSourceAccessManager;
22 #endif // defined(OS_CHROMEOS)
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() const;
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)
64
65 DISALLOW_COPY_AND_ASSIGN(FeedbackPrivateAPI);
51 }; 66 };
52 67
53 // Feedback strings. 68 // Feedback strings.
54 class FeedbackPrivateGetStringsFunction : public UIThreadExtensionFunction { 69 class FeedbackPrivateGetStringsFunction : public UIThreadExtensionFunction {
55 public: 70 public:
56 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getStrings", 71 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getStrings",
57 FEEDBACKPRIVATE_GETSTRINGS) 72 FEEDBACKPRIVATE_GETSTRINGS)
58 73
59 // Invoke this callback when this function is called - used for testing. 74 // Invoke this callback when this function is called - used for testing.
60 static void set_test_callback(base::Closure* const callback) { 75 static void set_test_callback(base::Closure* const callback) {
(...skipping 27 matching lines...) Expand all
88 FEEDBACKPRIVATE_GETSYSTEMINFORMATION); 103 FEEDBACKPRIVATE_GETSYSTEMINFORMATION);
89 104
90 protected: 105 protected:
91 ~FeedbackPrivateGetSystemInformationFunction() override {} 106 ~FeedbackPrivateGetSystemInformationFunction() override {}
92 ResponseAction Run() override; 107 ResponseAction Run() override;
93 108
94 private: 109 private:
95 void OnCompleted(std::unique_ptr<system_logs::SystemLogsResponse> sys_info); 110 void OnCompleted(std::unique_ptr<system_logs::SystemLogsResponse> sys_info);
96 }; 111 };
97 112
113 // This function only reads from actual log sources on Chrome OS. On other
114 // platforms, it just returns EmptyResponse().
115 class FeedbackPrivateReadLogSourceFunction : public UIThreadExtensionFunction {
116 public:
117 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.readLogSource",
118 FEEDBACKPRIVATE_READLOGSOURCE);
119
120 protected:
121 ~FeedbackPrivateReadLogSourceFunction() override {}
122 ResponseAction Run() override;
123
124 #if defined(OS_CHROMEOS)
125 private:
126 void OnCompleted(const api::feedback_private::ReadLogSourceResult& result);
127 #endif // defined(OS_CHROMEOS)
128 };
129
98 class FeedbackPrivateSendFeedbackFunction 130 class FeedbackPrivateSendFeedbackFunction
99 : public ChromeAsyncExtensionFunction { 131 : public ChromeAsyncExtensionFunction {
100 public: 132 public:
101 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.sendFeedback", 133 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.sendFeedback",
102 FEEDBACKPRIVATE_SENDFEEDBACK); 134 FEEDBACKPRIVATE_SENDFEEDBACK);
103 135
104 protected: 136 protected:
105 ~FeedbackPrivateSendFeedbackFunction() override {} 137 ~FeedbackPrivateSendFeedbackFunction() override {}
106 bool RunAsync() override; 138 bool RunAsync() override;
107 139
108 private: 140 private:
109 void OnCompleted(bool success); 141 void OnCompleted(bool success);
110 }; 142 };
111 143
112 class FeedbackPrivateLogSrtPromptResultFunction 144 class FeedbackPrivateLogSrtPromptResultFunction
113 : public UIThreadExtensionFunction { 145 : public UIThreadExtensionFunction {
114 public: 146 public:
115 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.logSrtPromptResult", 147 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.logSrtPromptResult",
116 FEEDBACKPRIVATE_LOGSRTPROMPTRESULT); 148 FEEDBACKPRIVATE_LOGSRTPROMPTRESULT);
117 149
118 protected: 150 protected:
119 ~FeedbackPrivateLogSrtPromptResultFunction() override {} 151 ~FeedbackPrivateLogSrtPromptResultFunction() override {}
120 AsyncExtensionFunction::ResponseAction Run() override; 152 AsyncExtensionFunction::ResponseAction Run() override;
121 }; 153 };
122 154
123 } // namespace extensions 155 } // namespace extensions
124 156
125 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H _ 157 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H _
OLDNEW
« no previous file with comments | « chrome/browser/extensions/BUILD.gn ('k') | chrome/browser/extensions/api/feedback_private/feedback_private_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698