OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/drive/search_metadata.h" | 5 #include "chrome/browser/chromeos/drive/search_metadata.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <queue> | 8 #include <queue> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/i18n/string_search.h" | 11 #include "base/i18n/string_search.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "chrome/browser/chromeos/drive/file_system_util.h" | 15 #include "chrome/browser/chromeos/drive/file_system_util.h" |
16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "google_apis/drive/gdata_wapi_parser.h" |
17 #include "net/base/escape.h" | 18 #include "net/base/escape.h" |
18 | 19 |
19 using content::BrowserThread; | 20 using content::BrowserThread; |
20 | 21 |
21 namespace drive { | 22 namespace drive { |
22 namespace internal { | 23 namespace internal { |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 struct ResultCandidate { | 27 struct ResultCandidate { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 return false; | 155 return false; |
155 | 156 |
156 if ((options & SEARCH_METADATA_EXCLUDE_DIRECTORIES) && | 157 if ((options & SEARCH_METADATA_EXCLUDE_DIRECTORIES) && |
157 entry.file_info().is_directory()) | 158 entry.file_info().is_directory()) |
158 return false; | 159 return false; |
159 | 160 |
160 if (options & SEARCH_METADATA_SHARED_WITH_ME) | 161 if (options & SEARCH_METADATA_SHARED_WITH_ME) |
161 return entry.shared_with_me(); | 162 return entry.shared_with_me(); |
162 | 163 |
163 if (options & SEARCH_METADATA_OFFLINE) { | 164 if (options & SEARCH_METADATA_OFFLINE) { |
164 if (entry.file_specific_info().is_hosted_document()) | 165 if (entry.file_specific_info().is_hosted_document()) { |
165 return true; | 166 // Not all hosted documents are cached by Drive offline app. |
166 FileCacheEntry cache_entry; | 167 // http://support.google.com/drive/bin/answer.py?hl=en&answer=1628467 |
167 it->GetCacheEntry(&cache_entry); | 168 switch (google_apis::ResourceEntry::GetEntryKindFromExtension( |
168 return cache_entry.is_present(); | 169 entry.file_specific_info().document_extension())) { |
| 170 case google_apis::ENTRY_KIND_DOCUMENT: |
| 171 case google_apis::ENTRY_KIND_SPREADSHEET: |
| 172 case google_apis::ENTRY_KIND_PRESENTATION: |
| 173 case google_apis::ENTRY_KIND_DRAWING: |
| 174 return true; |
| 175 default: |
| 176 return false; |
| 177 } |
| 178 } else { |
| 179 FileCacheEntry cache_entry; |
| 180 it->GetCacheEntry(&cache_entry); |
| 181 return cache_entry.is_present(); |
| 182 } |
169 } | 183 } |
170 | 184 |
171 // Exclude "drive", "drive/root", and "drive/other". | 185 // Exclude "drive", "drive/root", and "drive/other". |
172 if (it->GetID() == util::kDriveGrandRootLocalId || | 186 if (it->GetID() == util::kDriveGrandRootLocalId || |
173 entry.parent_local_id() == util::kDriveGrandRootLocalId) { | 187 entry.parent_local_id() == util::kDriveGrandRootLocalId) { |
174 return false; | 188 return false; |
175 } | 189 } |
176 | 190 |
177 return true; | 191 return true; |
178 } | 192 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(pre))); | 348 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(pre))); |
335 highlighted_text->append("<b>"); | 349 highlighted_text->append("<b>"); |
336 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(match))); | 350 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(match))); |
337 highlighted_text->append("</b>"); | 351 highlighted_text->append("</b>"); |
338 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(post))); | 352 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(post))); |
339 return true; | 353 return true; |
340 } | 354 } |
341 | 355 |
342 } // namespace internal | 356 } // namespace internal |
343 } // namespace drive | 357 } // namespace drive |
OLD | NEW |