OLD | NEW |
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/web_resource/web_resource_service.h" | 5 #include "chrome/browser/web_resource/web_resource_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 base::DoubleToString(base::Time::Now().ToDoubleT())); | 112 base::DoubleToString(base::Time::Now().ToDoubleT())); |
113 | 113 |
114 // If we are still fetching data, exit. | 114 // If we are still fetching data, exit. |
115 if (in_fetch_) | 115 if (in_fetch_) |
116 return; | 116 return; |
117 in_fetch_ = true; | 117 in_fetch_ = true; |
118 | 118 |
119 // Balanced in OnURLFetchComplete. | 119 // Balanced in OnURLFetchComplete. |
120 AddRef(); | 120 AddRef(); |
121 | 121 |
122 GURL web_resource_server = apply_locale_to_url_ ? | 122 GURL web_resource_server = |
123 google_util::AppendGoogleLocaleParam(web_resource_server_) : | 123 apply_locale_to_url_ |
124 web_resource_server_; | 124 ? google_util::AppendGoogleLocaleParam( |
| 125 web_resource_server_, g_browser_process->GetApplicationLocale()) |
| 126 : web_resource_server_; |
125 | 127 |
126 DVLOG(1) << "WebResourceService StartFetch " << web_resource_server; | 128 DVLOG(1) << "WebResourceService StartFetch " << web_resource_server; |
127 url_fetcher_.reset(net::URLFetcher::Create( | 129 url_fetcher_.reset(net::URLFetcher::Create( |
128 web_resource_server, net::URLFetcher::GET, this)); | 130 web_resource_server, net::URLFetcher::GET, this)); |
129 // Do not let url fetcher affect existing state in system context | 131 // Do not let url fetcher affect existing state in system context |
130 // (by setting cookies, for example). | 132 // (by setting cookies, for example). |
131 url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE | | 133 url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE | |
132 net::LOAD_DO_NOT_SEND_COOKIES | | 134 net::LOAD_DO_NOT_SEND_COOKIES | |
133 net::LOAD_DO_NOT_SAVE_COOKIES); | 135 net::LOAD_DO_NOT_SAVE_COOKIES); |
134 net::URLRequestContextGetter* url_request_context_getter = | 136 net::URLRequestContextGetter* url_request_context_getter = |
(...skipping 15 matching lines...) Expand all Loading... |
150 json_unpacker_->Start(data); | 152 json_unpacker_->Start(data); |
151 } else { | 153 } else { |
152 // Don't parse data if attempt to download was unsuccessful. | 154 // Don't parse data if attempt to download was unsuccessful. |
153 // Stop loading new web resource data, and silently exit. | 155 // Stop loading new web resource data, and silently exit. |
154 // We do not call UnpackerClient, so we need to call EndFetch ourselves. | 156 // We do not call UnpackerClient, so we need to call EndFetch ourselves. |
155 EndFetch(); | 157 EndFetch(); |
156 } | 158 } |
157 | 159 |
158 Release(); | 160 Release(); |
159 } | 161 } |
OLD | NEW |