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

Side by Side Diff: chrome/browser/spellchecker/spelling_service_client.cc

Issue 1864583006: Simplify BrowserContext by removing redundant methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/spellchecker/spelling_service_client.h" 5 #include "chrome/browser/spellchecker/spelling_service_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/json/string_escape.h" 12 #include "base/json/string_escape.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/values.h" 18 #include "base/values.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chrome/common/spellcheck_common.h" 20 #include "chrome/common/spellcheck_common.h"
21 #include "chrome/common/spellcheck_result.h" 21 #include "chrome/common/spellcheck_result.h"
22 #include "components/data_use_measurement/core/data_use_user_data.h" 22 #include "components/data_use_measurement/core/data_use_user_data.h"
23 #include "components/prefs/pref_service.h" 23 #include "components/prefs/pref_service.h"
24 #include "components/user_prefs/user_prefs.h" 24 #include "components/user_prefs/user_prefs.h"
25 #include "content/public/browser/browser_context.h" 25 #include "content/public/browser/browser_context.h"
26 #include "content/public/browser/storage_partition.h"
26 #include "google_apis/google_api_keys.h" 27 #include "google_apis/google_api_keys.h"
27 #include "net/base/load_flags.h" 28 #include "net/base/load_flags.h"
28 #include "net/url_request/url_fetcher.h" 29 #include "net/url_request/url_fetcher.h"
29 #include "url/gurl.h" 30 #include "url/gurl.h"
30 31
31 namespace { 32 namespace {
32 33
33 // The URL for requesting spell checking and sending user feedback. 34 // The URL for requesting spell checking and sending user feedback.
34 const char kSpellingServiceURL[] = "https://www.googleapis.com/rpc"; 35 const char kSpellingServiceURL[] = "https://www.googleapis.com/rpc";
35 36
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 type, 104 type,
104 encoded_text.c_str(), 105 encoded_text.c_str(),
105 language_code.c_str(), 106 language_code.c_str(),
106 country_code.c_str(), 107 country_code.c_str(),
107 api_key.c_str()); 108 api_key.c_str());
108 109
109 GURL url = GURL(kSpellingServiceURL); 110 GURL url = GURL(kSpellingServiceURL);
110 net::URLFetcher* fetcher = CreateURLFetcher(url).release(); 111 net::URLFetcher* fetcher = CreateURLFetcher(url).release();
111 data_use_measurement::DataUseUserData::AttachToFetcher( 112 data_use_measurement::DataUseUserData::AttachToFetcher(
112 fetcher, data_use_measurement::DataUseUserData::SPELL_CHECKER); 113 fetcher, data_use_measurement::DataUseUserData::SPELL_CHECKER);
113 fetcher->SetRequestContext(context->GetRequestContext()); 114 fetcher->SetRequestContext(
115 content::BrowserContext::GetDefaultStoragePartition(context)->
116 GetURLRequestContext());
114 fetcher->SetUploadData("application/json", request); 117 fetcher->SetUploadData("application/json", request);
115 fetcher->SetLoadFlags( 118 fetcher->SetLoadFlags(
116 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES); 119 net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SAVE_COOKIES);
117 spellcheck_fetchers_[fetcher] = new TextCheckCallbackData(callback, text); 120 spellcheck_fetchers_[fetcher] = new TextCheckCallbackData(callback, text);
118 fetcher->Start(); 121 fetcher->Start();
119 return true; 122 return true;
120 } 123 }
121 124
122 bool SpellingServiceClient::IsAvailable( 125 bool SpellingServiceClient::IsAvailable(
123 content::BrowserContext* context, 126 content::BrowserContext* context,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 272
270 // The callback may release the last (transitive) dependency on |this|. It 273 // The callback may release the last (transitive) dependency on |this|. It
271 // MUST be the last function called. 274 // MUST be the last function called.
272 callback_data->callback.Run(success, callback_data->text, results); 275 callback_data->callback.Run(success, callback_data->text, results);
273 } 276 }
274 277
275 scoped_ptr<net::URLFetcher> SpellingServiceClient::CreateURLFetcher( 278 scoped_ptr<net::URLFetcher> SpellingServiceClient::CreateURLFetcher(
276 const GURL& url) { 279 const GURL& url) {
277 return net::URLFetcher::Create(url, net::URLFetcher::POST, this); 280 return net::URLFetcher::Create(url, net::URLFetcher::POST, this);
278 } 281 }
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_service.cc ('k') | chrome/browser/sync_file_system/drive_backend/sync_engine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698