OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/ntp/suggestions_source_discovery.h" | 5 #include "chrome/browser/ui/webui/ntp/suggestions_source_discovery.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 net::LOAD_DO_NOT_SAVE_COOKIES); | 75 net::LOAD_DO_NOT_SAVE_COOKIES); |
76 recommended_fetcher_->Start(); | 76 recommended_fetcher_->Start(); |
77 } | 77 } |
78 | 78 |
79 void SuggestionsSourceDiscovery::SetCombiner(SuggestionsCombiner* combiner) { | 79 void SuggestionsSourceDiscovery::SetCombiner(SuggestionsCombiner* combiner) { |
80 DCHECK(!combiner_); | 80 DCHECK(!combiner_); |
81 combiner_ = combiner; | 81 combiner_ = combiner; |
82 } | 82 } |
83 | 83 |
84 void SuggestionsSourceDiscovery::OnURLFetchComplete( | 84 void SuggestionsSourceDiscovery::OnURLFetchComplete( |
85 const content::URLFetcher* source) { | 85 const net::URLFetcher* source) { |
86 DCHECK(combiner_); | 86 DCHECK(combiner_); |
87 STLDeleteElements(&items_); | 87 STLDeleteElements(&items_); |
88 if (source->GetStatus().status() == net::URLRequestStatus::SUCCESS && | 88 if (source->GetStatus().status() == net::URLRequestStatus::SUCCESS && |
89 source->GetResponseCode() == net::HTTP_OK) { | 89 source->GetResponseCode() == net::HTTP_OK) { |
90 std::string data; | 90 std::string data; |
91 source->GetResponseAsString(&data); | 91 source->GetResponseAsString(&data); |
92 scoped_ptr<Value> message_value(base::JSONReader::Read(data, false)); | 92 scoped_ptr<Value> message_value(base::JSONReader::Read(data, false)); |
93 | 93 |
94 DictionaryValue* response_dict; | 94 DictionaryValue* response_dict; |
95 DictionaryValue* response_data; | 95 DictionaryValue* response_data; |
(...skipping 16 matching lines...) Expand all Loading... |
112 unescaped_url, | 112 unescaped_url, |
113 GURL(unescaped_url)); | 113 GURL(unescaped_url)); |
114 items_.push_back(page_value); | 114 items_.push_back(page_value); |
115 } | 115 } |
116 } | 116 } |
117 } | 117 } |
118 | 118 |
119 recommended_fetcher_.reset(); | 119 recommended_fetcher_.reset(); |
120 combiner_->OnItemsReady(); | 120 combiner_->OnItemsReady(); |
121 } | 121 } |
OLD | NEW |