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

Side by Side Diff: components/enhanced_bookmarks/bookmark_server_search_service.cc

Issue 539173004: Bring up of the enhanced bookmarks cluster service. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@intermediary2
Patch Set: micro-nit Created 6 years, 2 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
OLDNEW
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[] = "https://www.google.com/stars/search";
14 "https://www.google.com/stars/search");
15 } // namespace 15 } // namespace
16 16
17 namespace enhanced_bookmarks { 17 namespace enhanced_bookmarks {
18 18
19 BookmarkServerSearchService::BookmarkServerSearchService( 19 BookmarkServerSearchService::BookmarkServerSearchService(
20 scoped_refptr<net::URLRequestContextGetter> request_context_getter, 20 scoped_refptr<net::URLRequestContextGetter> request_context_getter,
21 ProfileOAuth2TokenService* token_service, 21 ProfileOAuth2TokenService* token_service,
22 SigninManagerBase* signin_manager, 22 SigninManagerBase* signin_manager,
23 EnhancedBookmarkModel* enhanced_bookmark_model) 23 EnhancedBookmarkModel* enhanced_bookmark_model)
24 : BookmarkServerService(request_context_getter, 24 : BookmarkServerService(request_context_getter,
(...skipping 24 matching lines...) Expand all
49 for (std::vector<std::string>::iterator clip_it = it->second.begin(); 49 for (std::vector<std::string>::iterator clip_it = it->second.begin();
50 clip_it != it->second.end(); 50 clip_it != it->second.end();
51 ++clip_it) { 51 ++clip_it) {
52 const BookmarkNode* node = BookmarkForRemoteId(*clip_it); 52 const BookmarkNode* node = BookmarkForRemoteId(*clip_it);
53 if (node) 53 if (node)
54 result.push_back(node); 54 result.push_back(node);
55 } 55 }
56 return result; 56 return result;
57 } 57 }
58 58
59 net::URLFetcher* BookmarkServerSearchService::CreateFetcher() { 59 scoped_ptr<net::URLFetcher> BookmarkServerSearchService::CreateFetcher() {
60 // Add the necessary arguments to the URI. 60 // Add the necessary arguments to the URI.
61 GURL url(kSearchUrl); 61 GURL url(kSearchUrl);
62 url = net::AppendQueryParameter(url, "output", "proto"); 62 url = net::AppendQueryParameter(url, "output", "proto");
63 url = net::AppendQueryParameter(url, "q", current_query_); 63 url = net::AppendQueryParameter(url, "q", current_query_);
64 url = net::AppendQueryParameter(url, "v", model_->GetVersionString());
64 65
65 // Build the URLFetcher to perform the request. 66 // Build the URLFetcher to perform the request.
66 net::URLFetcher* url_fetcher = 67 scoped_ptr<net::URLFetcher> url_fetcher(
67 net::URLFetcher::Create(url, net::URLFetcher::GET, this); 68 net::URLFetcher::Create(url, net::URLFetcher::GET, this));
68 69
69 return url_fetcher; 70 return url_fetcher;
70 } 71 }
71 72
72 bool BookmarkServerSearchService::ProcessResponse(const std::string& response, 73 bool BookmarkServerSearchService::ProcessResponse(const std::string& response,
73 bool* should_notify) { 74 bool* should_notify) {
74 DCHECK(*should_notify); 75 DCHECK(*should_notify);
75 DCHECK(current_query_.length()); 76 DCHECK(current_query_.length());
76 image::collections::CorpusSearchResult response_proto; 77 image::collections::CorpusSearchResult response_proto;
77 bool result = response_proto.ParseFromString(response); 78 bool result = response_proto.ParseFromString(response);
(...skipping 29 matching lines...) Expand all
107 searches_.clear(); 108 searches_.clear();
108 } 109 }
109 110
110 void BookmarkServerSearchService::EnhancedBookmarkRemoteIdChanged( 111 void BookmarkServerSearchService::EnhancedBookmarkRemoteIdChanged(
111 const BookmarkNode* node, 112 const BookmarkNode* node,
112 const std::string& old_remote_id, 113 const std::string& old_remote_id,
113 const std::string& remote_id) { 114 const std::string& remote_id) {
114 searches_.clear(); 115 searches_.clear();
115 } 116 }
116 } // namespace enhanced_bookmarks 117 } // namespace enhanced_bookmarks
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698