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_SERVICE_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_
9 #include "base/basictypes.h"
10 #include "base/callback.h"
11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/extensions/api/feedback_private/blob_reader.h"
14 #include "chrome/browser/feedback/feedback_data.h"
15 #include "chrome/common/extensions/api/feedback_private.h"
19 using extensions::api::feedback_private::SystemInformation;
21 namespace extensions {
23 typedef std::vector<linked_ptr<SystemInformation> > SystemInformationList;
25 class FeedbackService {
27 typedef base::Callback<void(bool)> SendFeedbackCallback;
28 typedef base::Callback<void(const SystemInformationList& sys_info)>
29 GetSystemInformationCallback;
31 // Creates a platform-specific FeedbackService instance.
32 static FeedbackService* CreateInstance();
33 // Convenience method for populating a SystemInformationList structure
34 // with a key/value pair.
35 static void PopulateSystemInfo(SystemInformationList* sys_info_list,
36 const std::string& key,
37 const std::string& value);
39 virtual ~FeedbackService();
41 // Sends a feedback report.
42 virtual void SendFeedback(Profile* profile,
43 scoped_refptr<FeedbackData> feedback_data,
44 const SendFeedbackCallback& callback);
46 // Platform specific methods:
47 // Get's the email address of the logged in user.
48 virtual std::string GetUserEmail() = 0;
50 // Start to gather system information.
51 // The |callback| will be invoked once the query is completed.
52 virtual void GetSystemInformation(
53 const GetSystemInformationCallback& callback) = 0;
58 // Used to get a weak ptr for a derived class instance.
59 virtual base::WeakPtr<FeedbackService> GetWeakPtr() = 0;
61 // Callbacks to receive blob data.
62 void AttachedFileCallback(scoped_ptr<std::string> data);
63 void ScreenshotCallback(scoped_ptr<std::string> data);
65 // Checks if we have read all the blobs we need to; signals the feedback
66 // data object once all the requisite data has been populated.
67 void CompleteSendFeedback();
69 GetSystemInformationCallback system_information_callback_;
70 SendFeedbackCallback send_feedback_callback_;
72 scoped_refptr<FeedbackData> feedback_data_;
74 DISALLOW_COPY_AND_ASSIGN(FeedbackService);
77 } // namespace extensions
79 #endif // CHROME_BROWSER_EXTENSIONS_API_FEEDBACK_PRIVATE_FEEDBACK_SERVICE_H_