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" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" | 21 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" |
22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
23 #include "components/suggestions/suggestions_service.h" | 23 #include "components/suggestions/suggestions_service.h" |
| 24 #include "components/suggestions/suggestions_utils.h" |
24 #include "net/base/escape.h" | 25 #include "net/base/escape.h" |
25 #include "ui/base/l10n/time_format.h" | 26 #include "ui/base/l10n/time_format.h" |
26 #include "ui/gfx/codec/png_codec.h" | 27 #include "ui/gfx/codec/png_codec.h" |
27 #include "ui/gfx/image/image_skia.h" | 28 #include "ui/gfx/image/image_skia.h" |
28 #include "url/gurl.h" | 29 #include "url/gurl.h" |
29 | 30 |
30 namespace suggestions { | 31 namespace suggestions { |
31 | 32 |
32 namespace { | 33 namespace { |
33 | 34 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 SuggestionsServiceFactory::GetInstance(); | 120 SuggestionsServiceFactory::GetInstance(); |
120 | 121 |
121 SuggestionsService* suggestions_service( | 122 SuggestionsService* suggestions_service( |
122 suggestions_service_factory->GetForProfile(profile_)); | 123 suggestions_service_factory->GetForProfile(profile_)); |
123 | 124 |
124 if (!suggestions_service) { | 125 if (!suggestions_service) { |
125 callback.Run(NULL); | 126 callback.Run(NULL); |
126 return; | 127 return; |
127 } | 128 } |
128 | 129 |
| 130 // Since it's a debugging page, it's fine to specify that sync state is |
| 131 // initialized. |
129 suggestions_service->FetchSuggestionsData( | 132 suggestions_service->FetchSuggestionsData( |
| 133 INITIALIZED_ENABLED_HISTORY, |
130 base::Bind(&SuggestionsSource::OnSuggestionsAvailable, | 134 base::Bind(&SuggestionsSource::OnSuggestionsAvailable, |
131 weak_ptr_factory_.GetWeakPtr(), callback)); | 135 weak_ptr_factory_.GetWeakPtr(), callback)); |
132 } | 136 } |
133 | 137 |
134 std::string SuggestionsSource::GetMimeType(const std::string& path) const { | 138 std::string SuggestionsSource::GetMimeType(const std::string& path) const { |
135 return "text/html"; | 139 return "text/html"; |
136 } | 140 } |
137 | 141 |
138 base::MessageLoop* SuggestionsSource::MessageLoopForRequestPath( | 142 base::MessageLoop* SuggestionsSource::MessageLoopForRequestPath( |
139 const std::string& path) const { | 143 const std::string& path) const { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 std::string encoded_output; | 193 std::string encoded_output; |
190 base::Base64Encode(std::string(output.begin(), output.end()), | 194 base::Base64Encode(std::string(output.begin(), output.end()), |
191 &encoded_output); | 195 &encoded_output); |
192 context->base64_encoded_pngs[url] = "data:image/png;base64,"; | 196 context->base64_encoded_pngs[url] = "data:image/png;base64,"; |
193 context->base64_encoded_pngs[url] += encoded_output; | 197 context->base64_encoded_pngs[url] += encoded_output; |
194 } | 198 } |
195 barrier.Run(); | 199 barrier.Run(); |
196 } | 200 } |
197 | 201 |
198 } // namespace suggestions | 202 } // namespace suggestions |
OLD | NEW |