OLD | NEW |
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 #include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h" | 5 #include "chrome/browser/extensions/api/feedback_private/feedback_private_api.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 | 62 |
63 FeedbackService* FeedbackPrivateAPI::GetService() const { | 63 FeedbackService* FeedbackPrivateAPI::GetService() const { |
64 return service_; | 64 return service_; |
65 } | 65 } |
66 | 66 |
67 void FeedbackPrivateAPI::RequestFeedback( | 67 void FeedbackPrivateAPI::RequestFeedback( |
68 const std::string& description_template, | 68 const std::string& description_template, |
69 const std::string& category_tag, | 69 const std::string& category_tag, |
70 const GURL& page_url) { | 70 const GURL& page_url) { |
71 // TODO(rkc): Remove logging once crbug.com/284662 is closed. | |
72 LOG(WARNING) << "FEEDBACK_DEBUG: Feedback requested."; | |
73 if (browser_context_ && EventRouter::Get(browser_context_)) { | 71 if (browser_context_ && EventRouter::Get(browser_context_)) { |
74 FeedbackInfo info; | 72 FeedbackInfo info; |
75 info.description = description_template; | 73 info.description = description_template; |
76 info.category_tag = make_scoped_ptr(new std::string(category_tag)); | 74 info.category_tag = make_scoped_ptr(new std::string(category_tag)); |
77 info.page_url = make_scoped_ptr(new std::string(page_url.spec())); | 75 info.page_url = make_scoped_ptr(new std::string(page_url.spec())); |
78 info.system_information.reset(new SystemInformationList); | 76 info.system_information.reset(new SystemInformationList); |
79 // The manager is only available if tracing is enabled. | 77 // The manager is only available if tracing is enabled. |
80 if (TracingManager* manager = TracingManager::Get()) { | 78 if (TracingManager* manager = TracingManager::Get()) { |
81 info.trace_id.reset(new int(manager->RequestTrace())); | 79 info.trace_id.reset(new int(manager->RequestTrace())); |
82 } | 80 } |
83 | 81 |
84 scoped_ptr<base::ListValue> args(new base::ListValue()); | 82 scoped_ptr<base::ListValue> args(new base::ListValue()); |
85 args->Append(info.ToValue().release()); | 83 args->Append(info.ToValue().release()); |
86 | 84 |
87 scoped_ptr<Event> event(new Event( | 85 scoped_ptr<Event> event(new Event( |
88 feedback_private::OnFeedbackRequested::kEventName, args.Pass())); | 86 feedback_private::OnFeedbackRequested::kEventName, args.Pass())); |
89 event->restrict_to_browser_context = browser_context_; | 87 event->restrict_to_browser_context = browser_context_; |
90 | 88 |
91 // TODO(rkc): Remove logging once crbug.com/284662 is closed. | |
92 LOG(WARNING) << "FEEDBACK_DEBUG: Dispatching onFeedbackRequested event."; | |
93 EventRouter::Get(browser_context_) | 89 EventRouter::Get(browser_context_) |
94 ->DispatchEventToExtension(kFeedbackExtensionId, event.Pass()); | 90 ->DispatchEventToExtension(kFeedbackExtensionId, event.Pass()); |
95 } | 91 } |
96 } | 92 } |
97 | 93 |
98 // static | 94 // static |
99 base::Closure* FeedbackPrivateGetStringsFunction::test_callback_ = NULL; | 95 base::Closure* FeedbackPrivateGetStringsFunction::test_callback_ = NULL; |
100 | 96 |
101 bool FeedbackPrivateGetStringsFunction::RunSync() { | 97 bool FeedbackPrivateGetStringsFunction::RunSync() { |
102 base::DictionaryValue* dict = new base::DictionaryValue(); | 98 base::DictionaryValue* dict = new base::DictionaryValue(); |
(...skipping 25 matching lines...) Expand all Loading... |
128 | 124 |
129 webui::SetFontAndTextDirection(dict); | 125 webui::SetFontAndTextDirection(dict); |
130 | 126 |
131 if (test_callback_ && !test_callback_->is_null()) | 127 if (test_callback_ && !test_callback_->is_null()) |
132 test_callback_->Run(); | 128 test_callback_->Run(); |
133 | 129 |
134 return true; | 130 return true; |
135 } | 131 } |
136 | 132 |
137 bool FeedbackPrivateGetUserEmailFunction::RunSync() { | 133 bool FeedbackPrivateGetUserEmailFunction::RunSync() { |
138 // TODO(rkc): Remove logging once crbug.com/284662 is closed. | |
139 LOG(WARNING) << "FEEDBACK_DEBUG: User e-mail requested."; | |
140 FeedbackService* service = | 134 FeedbackService* service = |
141 FeedbackPrivateAPI::GetFactoryInstance()->Get(GetProfile())->GetService(); | 135 FeedbackPrivateAPI::GetFactoryInstance()->Get(GetProfile())->GetService(); |
142 DCHECK(service); | 136 DCHECK(service); |
143 SetResult(new base::StringValue(service->GetUserEmail())); | 137 SetResult(new base::StringValue(service->GetUserEmail())); |
144 return true; | 138 return true; |
145 } | 139 } |
146 | 140 |
147 bool FeedbackPrivateGetSystemInformationFunction::RunAsync() { | 141 bool FeedbackPrivateGetSystemInformationFunction::RunAsync() { |
148 // TODO(rkc): Remove logging once crbug.com/284662 is closed. | |
149 LOG(WARNING) << "FEEDBACK_DEBUG: System information requested."; | |
150 FeedbackService* service = | 142 FeedbackService* service = |
151 FeedbackPrivateAPI::GetFactoryInstance()->Get(GetProfile())->GetService(); | 143 FeedbackPrivateAPI::GetFactoryInstance()->Get(GetProfile())->GetService(); |
152 DCHECK(service); | 144 DCHECK(service); |
153 service->GetSystemInformation( | 145 service->GetSystemInformation( |
154 base::Bind( | 146 base::Bind( |
155 &FeedbackPrivateGetSystemInformationFunction::OnCompleted, this)); | 147 &FeedbackPrivateGetSystemInformationFunction::OnCompleted, this)); |
156 return true; | 148 return true; |
157 } | 149 } |
158 | 150 |
159 void FeedbackPrivateGetSystemInformationFunction::OnCompleted( | 151 void FeedbackPrivateGetSystemInformationFunction::OnCompleted( |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 228 |
237 void FeedbackPrivateSendFeedbackFunction::OnCompleted( | 229 void FeedbackPrivateSendFeedbackFunction::OnCompleted( |
238 bool success) { | 230 bool success) { |
239 results_ = feedback_private::SendFeedback::Results::Create( | 231 results_ = feedback_private::SendFeedback::Results::Create( |
240 success ? feedback_private::STATUS_SUCCESS : | 232 success ? feedback_private::STATUS_SUCCESS : |
241 feedback_private::STATUS_DELAYED); | 233 feedback_private::STATUS_DELAYED); |
242 SendResponse(true); | 234 SendResponse(true); |
243 } | 235 } |
244 | 236 |
245 } // namespace extensions | 237 } // namespace extensions |
OLD | NEW |