Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / api / feedback_private / feedback_private_api.h
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.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H_
7
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/rect.h"
12
13 namespace extensions {
14
15 extern char kFeedbackExtensionId[];
16
17 class FeedbackService;
18
19 using extensions::api::feedback_private::SystemInformation;
20
21 class FeedbackPrivateAPI : public BrowserContextKeyedAPI {
22  public:
23   explicit FeedbackPrivateAPI(content::BrowserContext* context);
24   ~FeedbackPrivateAPI() override;
25
26   FeedbackService* GetService() const;
27   void RequestFeedback(const std::string& description_template,
28                        const std::string& category_tag,
29                        const GURL& page_url);
30
31   // BrowserContextKeyedAPI implementation.
32   static BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>*
33       GetFactoryInstance();
34
35  private:
36   friend class BrowserContextKeyedAPIFactory<FeedbackPrivateAPI>;
37
38   // BrowserContextKeyedAPI implementation.
39   static const char* service_name() {
40     return "FeedbackPrivateAPI";
41   }
42
43   static const bool kServiceHasOwnInstanceInIncognito = true;
44
45   content::BrowserContext* const browser_context_;
46   FeedbackService* service_;
47 };
48
49 // Feedback strings.
50 class FeedbackPrivateGetStringsFunction : public ChromeSyncExtensionFunction {
51  public:
52   DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getStrings",
53                              FEEDBACKPRIVATE_GETSTRINGS)
54
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;
58   }
59
60  protected:
61   ~FeedbackPrivateGetStringsFunction() override {}
62
63   // SyncExtensionFunction overrides.
64   bool RunSync() override;
65
66  private:
67   static base::Closure* test_callback_;
68 };
69
70 class FeedbackPrivateGetUserEmailFunction : public ChromeSyncExtensionFunction {
71  public:
72   DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getUserEmail",
73                              FEEDBACKPRIVATE_GETUSEREMAIL);
74
75  protected:
76   ~FeedbackPrivateGetUserEmailFunction() override {}
77   bool RunSync() override;
78 };
79
80 class FeedbackPrivateGetSystemInformationFunction
81     : public ChromeAsyncExtensionFunction {
82  public:
83   DECLARE_EXTENSION_FUNCTION("feedbackPrivate.getSystemInformation",
84                              FEEDBACKPRIVATE_GETSYSTEMINFORMATION);
85
86  protected:
87   ~FeedbackPrivateGetSystemInformationFunction() override {}
88   bool RunAsync() override;
89
90  private:
91   void OnCompleted(
92       const std::vector<linked_ptr<SystemInformation> >& sys_info);
93 };
94
95 class FeedbackPrivateSendFeedbackFunction
96     : public ChromeAsyncExtensionFunction {
97  public:
98   DECLARE_EXTENSION_FUNCTION("feedbackPrivate.sendFeedback",
99                              FEEDBACKPRIVATE_SENDFEEDBACK);
100
101  protected:
102   ~FeedbackPrivateSendFeedbackFunction() override {}
103   bool RunAsync() override;
104
105  private:
106   void OnCompleted(bool success);
107 };
108
109 }  // namespace extensions
110
111 #endif  // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_PRIVATE_API_H_