| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 SuggestionsSource::RequestContext::~RequestContext() {} | 110 SuggestionsSource::RequestContext::~RequestContext() {} |
| 111 | 111 |
| 112 std::string SuggestionsSource::GetSource() const { | 112 std::string SuggestionsSource::GetSource() const { |
| 113 return chrome::kChromeUISuggestionsHost; | 113 return chrome::kChromeUISuggestionsHost; |
| 114 } | 114 } |
| 115 | 115 |
| 116 void SuggestionsSource::StartDataRequest( | 116 void SuggestionsSource::StartDataRequest( |
| 117 const std::string& path, int render_process_id, int render_frame_id, | 117 const std::string& path, int render_process_id, int render_frame_id, |
| 118 const content::URLDataSource::GotDataCallback& callback) { | 118 const content::URLDataSource::GotDataCallback& callback) { |
| 119 SuggestionsServiceFactory* suggestions_service_factory = | |
| 120 SuggestionsServiceFactory::GetInstance(); | |
| 121 | |
| 122 SuggestionsService* suggestions_service( | 119 SuggestionsService* suggestions_service( |
| 123 suggestions_service_factory->GetForProfile(profile_)); | 120 SuggestionsServiceFactory::GetInstance()->GetForProfile(profile_)); |
| 124 | 121 |
| 125 if (!suggestions_service) { | 122 if (!suggestions_service) { |
| 126 callback.Run(NULL); | 123 callback.Run(NULL); |
| 127 return; | 124 return; |
| 128 } | 125 } |
| 129 | 126 |
| 130 // Since it's a debugging page, it's fine to specify that sync state is | 127 // Since it's a debugging page, it's fine to specify that sync state is |
| 131 // initialized. | 128 // initialized. |
| 132 suggestions_service->FetchSuggestionsData( | 129 suggestions_service->FetchSuggestionsData( |
| 133 INITIALIZED_ENABLED_HISTORY, | 130 INITIALIZED_ENABLED_HISTORY, |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 std::string encoded_output; | 190 std::string encoded_output; |
| 194 base::Base64Encode(std::string(output.begin(), output.end()), | 191 base::Base64Encode(std::string(output.begin(), output.end()), |
| 195 &encoded_output); | 192 &encoded_output); |
| 196 context->base64_encoded_pngs[url] = "data:image/png;base64,"; | 193 context->base64_encoded_pngs[url] = "data:image/png;base64,"; |
| 197 context->base64_encoded_pngs[url] += encoded_output; | 194 context->base64_encoded_pngs[url] += encoded_output; |
| 198 } | 195 } |
| 199 barrier.Run(); | 196 barrier.Run(); |
| 200 } | 197 } |
| 201 | 198 |
| 202 } // namespace suggestions | 199 } // namespace suggestions |
| OLD | NEW |