OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chromeos/extensions/launcher_search_provider.h" | 5 #include "chrome/browser/chromeos/extensions/launcher_search_provider.h" |
6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "chrome/browser/chromeos/launcher_search_provider/error_reporter.h" |
7 #include "chrome/browser/chromeos/launcher_search_provider/service.h" | 9 #include "chrome/browser/chromeos/launcher_search_provider/service.h" |
8 #include "chrome/common/extensions/api/launcher_search_provider.h" | 10 #include "chrome/common/extensions/api/launcher_search_provider.h" |
| 11 #include "content/public/browser/render_frame_host.h" |
| 12 #include "content/public/browser/render_view_host.h" |
9 | 13 |
10 namespace extensions { | 14 namespace extensions { |
11 | 15 |
12 LauncherSearchProviderSetSearchResultsFunction:: | 16 LauncherSearchProviderSetSearchResultsFunction:: |
13 ~LauncherSearchProviderSetSearchResultsFunction() { | 17 ~LauncherSearchProviderSetSearchResultsFunction() { |
14 } | 18 } |
15 | 19 |
16 bool LauncherSearchProviderSetSearchResultsFunction::RunSync() { | 20 bool LauncherSearchProviderSetSearchResultsFunction::RunSync() { |
| 21 using chromeos::launcher_search_provider::ErrorReporter; |
17 using chromeos::launcher_search_provider::Service; | 22 using chromeos::launcher_search_provider::Service; |
18 using extensions::api::launcher_search_provider::SetSearchResults::Params; | 23 using extensions::api::launcher_search_provider::SetSearchResults::Params; |
19 const scoped_ptr<Params> params(Params::Create(*args_)); | 24 const scoped_ptr<Params> params(Params::Create(*args_)); |
20 EXTENSION_FUNCTION_VALIDATE(params); | 25 EXTENSION_FUNCTION_VALIDATE(params); |
21 | 26 |
| 27 // Either render_view_host or render_frame_host will be set. See |
| 28 // crbug.com/304341. |
| 29 IPC::Sender* sender = nullptr; |
| 30 int routing_id = 0; |
| 31 if (render_view_host()) { |
| 32 sender = render_view_host(); |
| 33 routing_id = render_view_host()->GetRoutingID(); |
| 34 } else { |
| 35 sender = render_frame_host(); |
| 36 routing_id = render_frame_host()->GetRoutingID(); |
| 37 } |
| 38 DCHECK(sender); |
| 39 |
| 40 scoped_ptr<ErrorReporter> error_reporter( |
| 41 new ErrorReporter(sender, routing_id)); |
22 Service* const service = Service::Get(GetProfile()); | 42 Service* const service = Service::Get(GetProfile()); |
23 service->SetSearchResults(extension(), params->query_id, params->results); | 43 service->SetSearchResults(extension(), error_reporter.Pass(), |
| 44 params->query_id, params->results); |
24 | 45 |
25 return true; | 46 return true; |
26 } | 47 } |
27 | 48 |
28 } // namespace extensions | 49 } // namespace extensions |
OLD | NEW |