Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: chrome/browser/chromeos/drive/search_metadata.cc

Issue 384543004: Get rid of DriveEntryKind. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed some temporary variables and IsHostedDocumentByFileExtension(). Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/drive/drive_api_util.h"
16 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
17 #include "google_apis/drive/gdata_wapi_parser.h"
18 #include "net/base/escape.h" 18 #include "net/base/escape.h"
19 19
20 using content::BrowserThread; 20 using content::BrowserThread;
21 21
22 namespace drive { 22 namespace drive {
23 namespace internal { 23 namespace internal {
24 24
25 namespace { 25 namespace {
26 26
27 struct ResultCandidate { 27 struct ResultCandidate {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 entry.file_info().is_directory()) 159 entry.file_info().is_directory())
160 return false; 160 return false;
161 161
162 if (options & SEARCH_METADATA_SHARED_WITH_ME) 162 if (options & SEARCH_METADATA_SHARED_WITH_ME)
163 return entry.shared_with_me(); 163 return entry.shared_with_me();
164 164
165 if (options & SEARCH_METADATA_OFFLINE) { 165 if (options & SEARCH_METADATA_OFFLINE) {
166 if (entry.file_specific_info().is_hosted_document()) { 166 if (entry.file_specific_info().is_hosted_document()) {
167 // Not all hosted documents are cached by Drive offline app. 167 // Not all hosted documents are cached by Drive offline app.
168 // http://support.google.com/drive/bin/answer.py?hl=en&answer=1628467 168 // http://support.google.com/drive/bin/answer.py?hl=en&answer=1628467
169 switch (google_apis::ResourceEntry::GetEntryKindFromExtension( 169 std::string mime_type = drive::util::GetHostedDocumentMimeType(
170 entry.file_specific_info().document_extension())) { 170 entry.file_specific_info().document_extension());
171 case google_apis::ENTRY_KIND_DOCUMENT: 171 return mime_type == drive::util::kGoogleDocumentMimeType ||
172 case google_apis::ENTRY_KIND_SPREADSHEET: 172 mime_type == drive::util::kGoogleSpreadsheetMimeType ||
173 case google_apis::ENTRY_KIND_PRESENTATION: 173 mime_type == drive::util::kGooglePresentationMimeType ||
174 case google_apis::ENTRY_KIND_DRAWING: 174 mime_type == drive::util::kGoogleDrawingMimeType;
175 return true;
176 default:
177 return false;
178 }
179 } else { 175 } else {
180 return entry.file_specific_info().cache_state().is_present(); 176 return entry.file_specific_info().cache_state().is_present();
181 } 177 }
182 } 178 }
183 179
184 return true; 180 return true;
185 } 181 }
186 182
187 // Used to implement SearchMetadata. 183 // Used to implement SearchMetadata.
188 // Adds entry to the result when appropriate. 184 // Adds entry to the result when appropriate.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(pre))); 347 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(pre)));
352 highlighted_text->append("<b>"); 348 highlighted_text->append("<b>");
353 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(match))); 349 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(match)));
354 highlighted_text->append("</b>"); 350 highlighted_text->append("</b>");
355 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(post))); 351 highlighted_text->append(net::EscapeForHTML(base::UTF16ToUTF8(post)));
356 return true; 352 return true;
357 } 353 }
358 354
359 } // namespace internal 355 } // namespace internal
360 } // namespace drive 356 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698