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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H_
8 #include "chrome/browser/extensions/chrome_extension_function.h"
9 #include "chrome/common/extensions/api/feedback_private.h"
10 #include "extensions/browser/browser_context_keyed_api_factory.h"
11 #include "ui/gfx/geometry/rect.h"
13 namespace extensions
{
15 extern char kFeedbackExtensionId
[];
17 class FeedbackService
;
19 using extensions::api::feedback_private::SystemInformation
;
21 class FeedbackPrivateAPI
: public BrowserContextKeyedAPI
{
23 explicit FeedbackPrivateAPI(content::BrowserContext
* context
);
24 ~FeedbackPrivateAPI() override
;
26 FeedbackService
* GetService() const;
27 void RequestFeedback(const std::string
& description_template
,
28 const std::string
& category_tag
,
29 const GURL
& page_url
);
31 // BrowserContextKeyedAPI implementation.
32 static BrowserContextKeyedAPIFactory
<FeedbackPrivateAPI
>*
36 friend class BrowserContextKeyedAPIFactory
<FeedbackPrivateAPI
>;
38 // BrowserContextKeyedAPI implementation.
39 static const char* service_name() {
40 return "FeedbackPrivateAPI";
43 static const bool kServiceHasOwnInstanceInIncognito
= true;
45 content::BrowserContext
* const browser_context_
;
46 FeedbackService
* service_
;
50 class FeedbackPrivateGetStringsFunction
: public ChromeSyncExtensionFunction
{
52 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getStrings",
53 FEEDBACKPRIVATE_GETSTRINGS
)
55 // Invoke this callback when this function is called - used for testing.
56 static void set_test_callback(base::Closure
* const callback
) {
57 test_callback_
= callback
;
61 ~FeedbackPrivateGetStringsFunction() override
{}
63 // SyncExtensionFunction overrides.
64 bool RunSync() override
;
67 static base::Closure
* test_callback_
;
70 class FeedbackPrivateGetUserEmailFunction
: public ChromeSyncExtensionFunction
{
72 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getUserEmail",
73 FEEDBACKPRIVATE_GETUSEREMAIL
);
76 ~FeedbackPrivateGetUserEmailFunction() override
{}
77 bool RunSync() override
;
80 class FeedbackPrivateGetSystemInformationFunction
81 : public ChromeAsyncExtensionFunction
{
83 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getSystemInformation",
84 FEEDBACKPRIVATE_GETSYSTEMINFORMATION
);
87 ~FeedbackPrivateGetSystemInformationFunction() override
{}
88 bool RunAsync() override
;
92 const std::vector
<linked_ptr
<SystemInformation
> >& sys_info
);
95 class FeedbackPrivateSendFeedbackFunction
96 : public ChromeAsyncExtensionFunction
{
98 DECLARE_EXTENSION_FUNCTION("feedbackPrivate.sendFeedback",
99 FEEDBACKPRIVATE_SENDFEEDBACK
);
102 ~FeedbackPrivateSendFeedbackFunction() override
{}
103 bool RunAsync() override
;
106 void OnCompleted(bool success
);
109 } // namespace extensions
111 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H_