OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/search/suggestions/suggestions_source.h" | 5 #include "chrome/browser/search/suggestions/suggestions_source.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/barrier_closure.h" | 9 #include "base/barrier_closure.h" |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 SuggestionsServiceFactory::GetInstance(); | 119 SuggestionsServiceFactory::GetInstance(); |
120 | 120 |
121 SuggestionsService* suggestions_service( | 121 SuggestionsService* suggestions_service( |
122 suggestions_service_factory->GetForProfile(profile_)); | 122 suggestions_service_factory->GetForProfile(profile_)); |
123 | 123 |
124 if (!suggestions_service) { | 124 if (!suggestions_service) { |
125 callback.Run(NULL); | 125 callback.Run(NULL); |
126 return; | 126 return; |
127 } | 127 } |
128 | 128 |
| 129 // Since it's a debugging page, it's fine to specify that sync state is |
| 130 // initialized. |
129 suggestions_service->FetchSuggestionsData( | 131 suggestions_service->FetchSuggestionsData( |
130 base::Bind(&SuggestionsSource::OnSuggestionsAvailable, | 132 true, true, base::Bind(&SuggestionsSource::OnSuggestionsAvailable, |
131 weak_ptr_factory_.GetWeakPtr(), callback)); | 133 weak_ptr_factory_.GetWeakPtr(), callback)); |
132 } | 134 } |
133 | 135 |
134 std::string SuggestionsSource::GetMimeType(const std::string& path) const { | 136 std::string SuggestionsSource::GetMimeType(const std::string& path) const { |
135 return "text/html"; | 137 return "text/html"; |
136 } | 138 } |
137 | 139 |
138 base::MessageLoop* SuggestionsSource::MessageLoopForRequestPath( | 140 base::MessageLoop* SuggestionsSource::MessageLoopForRequestPath( |
139 const std::string& path) const { | 141 const std::string& path) const { |
140 // This can be accessed from the IO thread. | 142 // This can be accessed from the IO thread. |
141 return content::URLDataSource::MessageLoopForRequestPath(path); | 143 return content::URLDataSource::MessageLoopForRequestPath(path); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 std::string encoded_output; | 191 std::string encoded_output; |
190 base::Base64Encode(std::string(output.begin(), output.end()), | 192 base::Base64Encode(std::string(output.begin(), output.end()), |
191 &encoded_output); | 193 &encoded_output); |
192 context->base64_encoded_pngs[url] = "data:image/png;base64,"; | 194 context->base64_encoded_pngs[url] = "data:image/png;base64,"; |
193 context->base64_encoded_pngs[url] += encoded_output; | 195 context->base64_encoded_pngs[url] += encoded_output; |
194 } | 196 } |
195 barrier.Run(); | 197 barrier.Run(); |
196 } | 198 } |
197 | 199 |
198 } // namespace suggestions | 200 } // namespace suggestions |
OLD | NEW |