| 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_service.h" | 5 #include "components/enhanced_bookmarks/bookmark_server_service.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h" | 8 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h" |
| 9 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 9 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 10 #include "components/signin/core/browser/signin_manager_base.h" | 10 #include "components/signin/core/browser/signin_manager_base.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 observers_.AddObserver(observer); | 41 observers_.AddObserver(observer); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void BookmarkServerService::RemoveObserver( | 44 void BookmarkServerService::RemoveObserver( |
| 45 BookmarkServerServiceObserver* observer) { | 45 BookmarkServerServiceObserver* observer) { |
| 46 observers_.RemoveObserver(observer); | 46 observers_.RemoveObserver(observer); |
| 47 } | 47 } |
| 48 | 48 |
| 49 const BookmarkNode* BookmarkServerService::BookmarkForRemoteId( | 49 const BookmarkNode* BookmarkServerService::BookmarkForRemoteId( |
| 50 const std::string& remote_id) const { | 50 const std::string& remote_id) const { |
| 51 return model_->BookmarkForRemoteId(remote_id); | 51 std::map<std::string, const BookmarkNode*>::const_iterator it = |
| 52 starsid_to_bookmark_.find(remote_id); |
| 53 if (it == starsid_to_bookmark_.end()) |
| 54 return NULL; |
| 55 return it->second; |
| 52 } | 56 } |
| 53 | 57 |
| 54 const std::string BookmarkServerService::RemoteIDForBookmark( | 58 const std::string BookmarkServerService::RemoteIDForBookmark( |
| 55 const BookmarkNode* bookmark) const { | 59 const BookmarkNode* bookmark) const { |
| 56 return model_->GetRemoteId(bookmark); | 60 return model_->GetRemoteId(bookmark); |
| 57 } | 61 } |
| 58 | 62 |
| 59 void BookmarkServerService::Notify() { | 63 void BookmarkServerService::Notify() { |
| 60 FOR_EACH_OBSERVER(BookmarkServerServiceObserver, observers_, OnChange(this)); | 64 FOR_EACH_OBSERVER(BookmarkServerServiceObserver, observers_, OnChange(this)); |
| 61 } | 65 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 80 token_request_ = token_service_->StartRequest(username, scopes, this); | 84 token_request_ = token_service_->StartRequest(username, scopes, this); |
| 81 } | 85 } |
| 82 | 86 |
| 83 // | 87 // |
| 84 // OAuth2AccessTokenConsumer methods. | 88 // OAuth2AccessTokenConsumer methods. |
| 85 // | 89 // |
| 86 void BookmarkServerService::OnGetTokenSuccess( | 90 void BookmarkServerService::OnGetTokenSuccess( |
| 87 const OAuth2TokenService::Request* request, | 91 const OAuth2TokenService::Request* request, |
| 88 const std::string& access_token, | 92 const std::string& access_token, |
| 89 const base::Time& expiration_time) { | 93 const base::Time& expiration_time) { |
| 90 url_fetcher_ = CreateFetcher(); | 94 url_fetcher_.reset(CreateFetcher()); |
| 91 | |
| 92 // Free the token request. | 95 // Free the token request. |
| 93 token_request_.reset(); | 96 token_request_.reset(); |
| 94 | 97 |
| 95 if (!url_fetcher_) { | 98 if (!url_fetcher_) { |
| 96 CleanAfterFailure(); | 99 CleanAfterFailure(); |
| 97 Notify(); | 100 Notify(); |
| 98 return; | 101 return; |
| 99 } | 102 } |
| 100 url_fetcher_->SetRequestContext(request_context_getter_.get()); | 103 url_fetcher_->SetRequestContext(request_context_getter_.get()); |
| 101 | 104 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 void BookmarkServerService::EnhancedBookmarkModelShuttingDown() { | 146 void BookmarkServerService::EnhancedBookmarkModelShuttingDown() { |
| 144 NOTREACHED(); | 147 NOTREACHED(); |
| 145 } | 148 } |
| 146 | 149 |
| 147 SigninManagerBase* BookmarkServerService::GetSigninManager() { | 150 SigninManagerBase* BookmarkServerService::GetSigninManager() { |
| 148 DCHECK(signin_manager_); | 151 DCHECK(signin_manager_); |
| 149 return signin_manager_; | 152 return signin_manager_; |
| 150 } | 153 } |
| 151 | 154 |
| 152 } // namespace enhanced_bookmarks | 155 } // namespace enhanced_bookmarks |
| OLD | NEW |