Chromium Code Reviews| Index: chrome/browser/history/web_history_service.cc |
| diff --git a/chrome/browser/history/web_history_service.cc b/chrome/browser/history/web_history_service.cc |
| index e5a8014d1171e30504b67322a3d75749f3ac2041..55157881411cdff9eb891fc994c80be4369bb87a 100644 |
| --- a/chrome/browser/history/web_history_service.cc |
| +++ b/chrome/browser/history/web_history_service.cc |
| @@ -40,6 +40,12 @@ const char kHistoryQueryHistoryUrl[] = |
| const char kHistoryDeleteHistoryUrl[] = |
| "https://history.google.com/history/api/delete?client=chrome"; |
| +const char kHistoryAudioHistoryUrl[] = |
| + "https://history.google.com/history/api/lookup?client=audio"; |
| + |
| +const char kHistoryAudioHistoryChangeUrl[] = |
| + "https://history.google.com/history/api/change"; |
| + |
| const char kPostDataMimeType[] = "text/plain"; |
| // The maximum number of retries for the URLFetcher requests. |
| @@ -303,6 +309,7 @@ WebHistoryService::WebHistoryService(Profile* profile) |
| WebHistoryService::~WebHistoryService() { |
| STLDeleteElements(&pending_expire_requests_); |
| + STLDeleteElements(&pending_audio_history_requests_); |
| } |
| scoped_ptr<WebHistoryService::Request> WebHistoryService::QueryHistory( |
| @@ -382,6 +389,46 @@ void WebHistoryService::ExpireHistoryBetween( |
| ExpireHistory(expire_list, callback); |
| } |
| +void WebHistoryService::GetAudioHistoryEnabled( |
| + const AudioWebHistoryCallback& callback) { |
| + // Wrap the original callback into a generic completion callback. |
| + RequestImpl::CompletionCallback completion_callback = |
| + base::Bind(&WebHistoryService::AudioHistoryCompletionCallback, |
| + weak_ptr_factory_.GetWeakPtr(), |
| + callback); |
| + |
| + GURL url(kHistoryAudioHistoryUrl); |
| + scoped_ptr<RequestImpl> request( |
| + new RequestImpl(profile_, url, completion_callback)); |
| + request->Start(); |
| + pending_audio_history_requests_.insert(request.release()); |
| +} |
| + |
| +void WebHistoryService::SetAudioHistoryEnabled( |
| + bool new_enabled_value, |
| + const AudioWebHistoryCallback& callback) { |
| + // Wrap the original callback into a generic completion callback. |
| + RequestImpl::CompletionCallback completion_callback = |
| + base::Bind(&WebHistoryService::AudioHistoryCompletionCallback, |
| + weak_ptr_factory_.GetWeakPtr(), |
| + callback); |
| + |
| + GURL url(kHistoryAudioHistoryChangeUrl); |
| + scoped_ptr<RequestImpl> request( |
| + new RequestImpl(profile_, url, completion_callback)); |
| + |
| + base::DictionaryValue enable_audio_history; |
| + enable_audio_history.SetBoolean("enable_history_recording", |
| + new_enabled_value); |
| + enable_audio_history.SetString("client", "audio"); |
| + std::string post_data; |
| + base::JSONWriter::Write(&enable_audio_history, &post_data); |
| + request->set_post_data(post_data); |
| + |
| + request->Start(); |
| + pending_audio_history_requests_.insert(request.release()); |
| +} |
| + |
| // static |
| void WebHistoryService::QueryHistoryCompletionCallback( |
| const WebHistoryService::QueryWebHistoryCallback& callback, |
| @@ -409,4 +456,19 @@ void WebHistoryService::ExpireHistoryCompletionCallback( |
| delete request; |
| } |
| +void WebHistoryService::AudioHistoryCompletionCallback( |
| + const WebHistoryService::AudioWebHistoryCallback& callback, |
| + WebHistoryService::Request* request, |
| + bool success) { |
| + scoped_ptr<base::DictionaryValue> response_value; |
| + bool enabled_value = false; |
| + if (success) { |
| + response_value = ReadResponse(static_cast<RequestImpl*>(request)); |
| + if (response_value) |
| + response_value->GetBoolean("history_recording_enabled", &enabled_value); |
| + } |
| + callback.Run(success, enabled_value); |
| + pending_audio_history_requests_.erase(request); |
|
sky
2014/11/11 20:30:10
Does this leak request?
rpetterson
2014/11/11 22:29:16
No, it should not. We use the pending_audio_histor
sky
2014/11/12 00:46:32
Where is the delete? From what I see you erase the
rpetterson
2014/11/12 00:58:42
Whoops. It's back.
|
| +} |
| + |
| } // namespace history |