OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 #ifndef COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_SERVER_SEARCH_SERVICE_H_ | |
5 #define COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_SERVER_SEARCH_SERVICE_H_ | |
6 | |
7 #include <string> | |
8 #include <vector> | |
9 | |
10 #include "components/enhanced_bookmarks/bookmark_server_service.h" | |
11 #include "net/url_request/url_fetcher.h" | |
12 | |
13 class BookmarkModel; | |
14 | |
15 namespace enhanced_bookmarks { | |
16 | |
17 // Sends requests to the bookmark server to search for bookmarks relevant to a | |
18 // given query. Will handle one outgoing request at a time. | |
19 class BookmarkServerSearchService : public BookmarkServerService { | |
20 public: | |
21 BookmarkServerSearchService( | |
22 scoped_refptr<net::URLRequestContextGetter> request_context_getter, | |
23 ProfileOAuth2TokenService* token_service, | |
24 SigninManagerBase* signin_manager, | |
25 BookmarkModel* bookmark_model); | |
26 virtual ~BookmarkServerSearchService(); | |
27 | |
28 // Triggers a search. The query must not be empty. A call to this method | |
29 // cancels any previous searches. OnChange() is garanteed to be called once | |
30 // per query. | |
31 void Search(const std::string& query); | |
32 | |
33 // Returns the search results. The results are only available after the | |
34 // OnChange() observer methods has been sent. This method will return an empty | |
35 // result otherwise. query should be a string passed to Search() previously. | |
36 std::vector<const BookmarkNode*> ResultForQuery(const std::string& query); | |
37 | |
38 protected: | |
39 | |
40 virtual net::URLFetcher* CreateFetcherWithToken( | |
41 const std::string& access_token) OVERRIDE; | |
42 | |
43 virtual bool ProcessResponse(const std::string& response, | |
44 bool* should_notify) OVERRIDE; | |
45 | |
46 virtual void CleanAfterFailure() OVERRIDE; | |
47 | |
48 // BookmarkModelObserver methods. | |
49 virtual void BookmarkNodeAdded(BookmarkModel* model, | |
50 const BookmarkNode* parent, | |
51 int index) OVERRIDE; | |
52 virtual void BookmarkMetaInfoChanged(BookmarkModel* model, | |
53 const BookmarkNode* node) OVERRIDE; | |
54 | |
55 private: | |
56 // The search data, a map from query to a vector of starsid. | |
Yaron
2014/09/05 04:37:52
stars.id
noyau (Ping after 24h)
2014/09/08 09:46:48
Done.
| |
57 std::map<std::string, std::vector<std::string> > searches_; | |
58 std::string current_query_; | |
59 DISALLOW_COPY_AND_ASSIGN(BookmarkServerSearchService); | |
60 }; | |
61 } // namespace enhanced_bookmarks | |
62 | |
63 #endif // COMPONENTS_ENHANCED_BOOKMARKS_BOOKMARK_SERVER_SEARCH_SERVICE_H_ | |
OLD | NEW |