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/launcher_search_provider/service.h" | 5 #include "chrome/browser/chromeos/launcher_search_provider/service.h" |
6 | 6 |
7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/chromeos/launcher_search_provider/service_factory.h" | 9 #include "chrome/browser/chromeos/launcher_search_provider/service_factory.h" |
10 #include "chrome/browser/ui/app_list/search/launcher_search/launcher_search_prov ider.h" | 10 #include "chrome/browser/ui/app_list/search/launcher_search/launcher_search_prov ider.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 extension_id, | 77 extension_id, |
78 make_scoped_ptr(new extensions::Event( | 78 make_scoped_ptr(new extensions::Event( |
79 api_launcher_search_provider::OnQueryEnded::kEventName, | 79 api_launcher_search_provider::OnQueryEnded::kEventName, |
80 api_launcher_search_provider::OnQueryEnded::Create( | 80 api_launcher_search_provider::OnQueryEnded::Create( |
81 std::to_string(query_id_))))); | 81 std::to_string(query_id_))))); |
82 } | 82 } |
83 | 83 |
84 is_query_running_ = false; | 84 is_query_running_ = false; |
85 } | 85 } |
86 | 86 |
87 void Service::OnOpenResult(const ExtensionId& extension_id, | |
88 const std::string& item_id) { | |
89 // If |extension| is not contained in listener extension, ignore it. | |
90 std::set<ExtensionId> extension_ids = GetListenerExtensionIds(); | |
91 if (!ContainsValue(extension_ids, extension_id)) | |
Matt Giuca
2015/04/20 02:44:52
Is there any reason to expect this to happen durin
yawano
2015/04/20 04:02:36
Yes, this could not happen since extension_id is s
Matt Giuca
2015/04/20 04:36:26
I think it should be a CHECK because it would be a
yawano
2015/04/20 04:46:22
Done.
| |
92 return; | |
93 | |
94 extensions::EventRouter* event_router = | |
95 extensions::EventRouter::Get(profile_); | |
96 event_router->DispatchEventToExtension( | |
97 extension_id, | |
98 make_scoped_ptr(new extensions::Event( | |
99 api_launcher_search_provider::OnOpenResult::kEventName, | |
100 api_launcher_search_provider::OnOpenResult::Create(item_id)))); | |
101 } | |
102 | |
87 void Service::SetSearchResults( | 103 void Service::SetSearchResults( |
88 const extensions::Extension* extension, | 104 const extensions::Extension* extension, |
89 const std::string& query_id, | 105 const std::string& query_id, |
90 const std::vector<linked_ptr< | 106 const std::vector<linked_ptr< |
91 extensions::api::launcher_search_provider::SearchResult>>& results) { | 107 extensions::api::launcher_search_provider::SearchResult>>& results) { |
92 // If query is not running or query_id is different from current query id, | 108 // If query is not running or query_id is different from current query id, |
93 // discard the results. | 109 // discard the results. |
94 if (!is_query_running_ || query_id != std::to_string(query_id_)) | 110 if (!is_query_running_ || query_id != std::to_string(query_id_)) |
95 return; | 111 return; |
96 | 112 |
(...skipping 30 matching lines...) Expand all Loading... | |
127 extensions::APIPermission::kLauncherSearchProvider); | 143 extensions::APIPermission::kLauncherSearchProvider); |
128 if (has_permission) | 144 if (has_permission) |
129 extension_ids.insert(extension->id()); | 145 extension_ids.insert(extension->id()); |
130 } | 146 } |
131 | 147 |
132 return extension_ids; | 148 return extension_ids; |
133 } | 149 } |
134 | 150 |
135 } // namespace launcher_search_provider | 151 } // namespace launcher_search_provider |
136 } // namespace chromeos | 152 } // namespace chromeos |
OLD | NEW |