Chromium Code Reviews| 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 "components/enhanced_bookmarks/bookmark_server_search_service.h" | 5 #include "components/enhanced_bookmarks/bookmark_server_search_service.h" |
| 6 | 6 |
| 7 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h" | |
| 7 #include "components/enhanced_bookmarks/enhanced_bookmark_utils.h" | 8 #include "components/enhanced_bookmarks/enhanced_bookmark_utils.h" |
| 8 #include "components/enhanced_bookmarks/proto/search.pb.h" | 9 #include "components/enhanced_bookmarks/proto/search.pb.h" |
| 9 #include "net/base/url_util.h" | 10 #include "net/base/url_util.h" |
| 10 #include "net/url_request/url_fetcher.h" | 11 #include "net/url_request/url_fetcher.h" |
| 11 | 12 |
| 12 namespace { | 13 namespace { |
| 13 const std::string kSearchUrl( | 14 const char kSearchUrl[] = |
|
sdefresne
2014/10/08 09:08:20
nit: this fits on one line
| |
| 14 "https://www.google.com/stars/search"); | 15 "https://www.google.com/stars/search"; |
| 15 } // namespace | 16 } // namespace |
| 16 | 17 |
| 17 namespace enhanced_bookmarks { | 18 namespace enhanced_bookmarks { |
| 18 | 19 |
| 19 BookmarkServerSearchService::BookmarkServerSearchService( | 20 BookmarkServerSearchService::BookmarkServerSearchService( |
| 20 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | 21 scoped_refptr<net::URLRequestContextGetter> request_context_getter, |
| 21 ProfileOAuth2TokenService* token_service, | 22 ProfileOAuth2TokenService* token_service, |
| 22 SigninManagerBase* signin_manager, | 23 SigninManagerBase* signin_manager, |
| 23 EnhancedBookmarkModel* enhanced_bookmark_model) | 24 EnhancedBookmarkModel* enhanced_bookmark_model) |
| 24 : BookmarkServerService(request_context_getter, | 25 : BookmarkServerService(request_context_getter, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 49 for (std::vector<std::string>::iterator clip_it = it->second.begin(); | 50 for (std::vector<std::string>::iterator clip_it = it->second.begin(); |
| 50 clip_it != it->second.end(); | 51 clip_it != it->second.end(); |
| 51 ++clip_it) { | 52 ++clip_it) { |
| 52 const BookmarkNode* node = BookmarkForRemoteId(*clip_it); | 53 const BookmarkNode* node = BookmarkForRemoteId(*clip_it); |
| 53 if (node) | 54 if (node) |
| 54 result.push_back(node); | 55 result.push_back(node); |
| 55 } | 56 } |
| 56 return result; | 57 return result; |
| 57 } | 58 } |
| 58 | 59 |
| 59 net::URLFetcher* BookmarkServerSearchService::CreateFetcher() { | 60 scoped_ptr<net::URLFetcher> BookmarkServerSearchService::CreateFetcher() { |
| 60 // Add the necessary arguments to the URI. | 61 // Add the necessary arguments to the URI. |
| 61 GURL url(kSearchUrl); | 62 GURL url(kSearchUrl); |
| 62 url = net::AppendQueryParameter(url, "output", "proto"); | 63 url = net::AppendQueryParameter(url, "output", "proto"); |
| 63 url = net::AppendQueryParameter(url, "q", current_query_); | 64 url = net::AppendQueryParameter(url, "q", current_query_); |
| 65 url = net::AppendQueryParameter(url, "v", model_->GetVersionString()); | |
| 64 | 66 |
| 65 // Build the URLFetcher to perform the request. | 67 // Build the URLFetcher to perform the request. |
| 66 net::URLFetcher* url_fetcher = | 68 scoped_ptr<net::URLFetcher> url_fetcher( |
| 67 net::URLFetcher::Create(url, net::URLFetcher::GET, this); | 69 net::URLFetcher::Create(url, net::URLFetcher::GET, this)); |
| 68 | 70 |
| 69 return url_fetcher; | 71 return url_fetcher; |
| 70 } | 72 } |
| 71 | 73 |
| 72 bool BookmarkServerSearchService::ProcessResponse(const std::string& response, | 74 bool BookmarkServerSearchService::ProcessResponse(const std::string& response, |
| 73 bool* should_notify) { | 75 bool* should_notify) { |
| 74 DCHECK(*should_notify); | 76 DCHECK(*should_notify); |
| 75 DCHECK(current_query_.length()); | 77 DCHECK(current_query_.length()); |
| 76 image::collections::CorpusSearchResult response_proto; | 78 image::collections::CorpusSearchResult response_proto; |
| 77 bool result = response_proto.ParseFromString(response); | 79 bool result = response_proto.ParseFromString(response); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 107 searches_.clear(); | 109 searches_.clear(); |
| 108 } | 110 } |
| 109 | 111 |
| 110 void BookmarkServerSearchService::EnhancedBookmarkRemoteIdChanged( | 112 void BookmarkServerSearchService::EnhancedBookmarkRemoteIdChanged( |
| 111 const BookmarkNode* node, | 113 const BookmarkNode* node, |
| 112 const std::string& old_remote_id, | 114 const std::string& old_remote_id, |
| 113 const std::string& remote_id) { | 115 const std::string& remote_id) { |
| 114 searches_.clear(); | 116 searches_.clear(); |
| 115 } | 117 } |
| 116 } // namespace enhanced_bookmarks | 118 } // namespace enhanced_bookmarks |
| OLD | NEW |