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

Side by Side Diff: chrome/browser/autocomplete/search_provider.cc

Issue 7714004: base: Add AsList() function to Value API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos Created 9 years, 4 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
« no previous file with comments | « base/values_unittest.cc ('k') | chrome/browser/chromeos/cros/native_network_parser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/autocomplete/search_provider.h" 5 #include "chrome/browser/autocomplete/search_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 URLFetcher::GET, this); 445 URLFetcher::GET, this);
446 fetcher->set_request_context(profile_->GetRequestContext()); 446 fetcher->set_request_context(profile_->GetRequestContext());
447 fetcher->Start(); 447 fetcher->Start();
448 return fetcher; 448 return fetcher;
449 } 449 }
450 450
451 bool SearchProvider::ParseSuggestResults(Value* root_val, 451 bool SearchProvider::ParseSuggestResults(Value* root_val,
452 bool is_keyword, 452 bool is_keyword,
453 const string16& input_text, 453 const string16& input_text,
454 SuggestResults* suggest_results) { 454 SuggestResults* suggest_results) {
455 if (!root_val->IsType(Value::TYPE_LIST)) 455 ListValue* root_list = root_val->AsList();
456 if (!root_list)
456 return false; 457 return false;
457 ListValue* root_list = static_cast<ListValue*>(root_val);
458 458
459 Value* query_val; 459 Value* query_val;
460 string16 query_str; 460 string16 query_str;
461 Value* result_val; 461 Value* result_val;
462 if ((root_list->GetSize() < 2) || !root_list->Get(0, &query_val) || 462 if ((root_list->GetSize() < 2) || !root_list->Get(0, &query_val) ||
463 !query_val->GetAsString(&query_str) || 463 !query_val->GetAsString(&query_str) ||
464 (query_str != input_text) || 464 (query_str != input_text) ||
465 !root_list->Get(1, &result_val) || !result_val->IsType(Value::TYPE_LIST)) 465 !root_list->Get(1, &result_val) || !result_val->AsList())
466 return false; 466 return false;
467 467
468 ListValue* description_list = NULL; 468 ListValue* description_list = NULL;
469 if (root_list->GetSize() > 2) { 469 if (root_list->GetSize() > 2) {
470 // 3rd element: Description list. 470 // 3rd element: Description list.
471 Value* description_val; 471 Value* description_val;
472 if (root_list->Get(2, &description_val) && 472 if (root_list->Get(2, &description_val))
473 description_val->IsType(Value::TYPE_LIST)) 473 description_list = description_val->AsList();
474 description_list = static_cast<ListValue*>(description_val);
475 } 474 }
476 475
477 // We don't care about the query URL list (the fourth element in the 476 // We don't care about the query URL list (the fourth element in the
478 // response) for now. 477 // response) for now.
479 478
480 // Parse optional data in the results from the Suggest server if any. 479 // Parse optional data in the results from the Suggest server if any.
481 ListValue* type_list = NULL; 480 ListValue* type_list = NULL;
482 // 5th argument: Optional key-value pairs. 481 // 5th argument: Optional key-value pairs.
483 // TODO: We may iterate the 5th+ arguments of the root_list if any other 482 // TODO: We may iterate the 5th+ arguments of the root_list if any other
484 // optional data are defined. 483 // optional data are defined.
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 943
945 return match; 944 return match;
946 } 945 }
947 946
948 void SearchProvider::UpdateDone() { 947 void SearchProvider::UpdateDone() {
949 // We're done when there are no more suggest queries pending (this is set to 1 948 // We're done when there are no more suggest queries pending (this is set to 1
950 // when the timer is started) and we're not waiting on instant. 949 // when the timer is started) and we're not waiting on instant.
951 done_ = ((suggest_results_pending_ == 0) && 950 done_ = ((suggest_results_pending_ == 0) &&
952 (instant_finalized_ || !InstantController::IsEnabled(profile_))); 951 (instant_finalized_ || !InstantController::IsEnabled(profile_)));
953 } 952 }
OLDNEW
« no previous file with comments | « base/values_unittest.cc ('k') | chrome/browser/chromeos/cros/native_network_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698