| 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/extensions/api/web_request/web_request_api.h" | 5 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2142 // We only check whether tokens are left here. Deducting a token happens in | 2142 // We only check whether tokens are left here. Deducting a token happens in |
| 2143 // OnPageLoad(). | 2143 // OnPageLoad(). |
| 2144 return bucket->has_tokens(); | 2144 return bucket->has_tokens(); |
| 2145 } | 2145 } |
| 2146 | 2146 |
| 2147 void ClearCacheQuotaHeuristic::OnPageLoad(Bucket* bucket) { | 2147 void ClearCacheQuotaHeuristic::OnPageLoad(Bucket* bucket) { |
| 2148 callback_registered_ = false; | 2148 callback_registered_ = false; |
| 2149 bucket->DeductToken(); | 2149 bucket->DeductToken(); |
| 2150 } | 2150 } |
| 2151 | 2151 |
| 2152 bool WebRequestAddEventListener::RunImpl() { | 2152 bool WebRequestInternalAddEventListenerFunction::RunImpl() { |
| 2153 // Argument 0 is the callback, which we don't use here. | 2153 // Argument 0 is the callback, which we don't use here. |
| 2154 ExtensionWebRequestEventRouter::RequestFilter filter; | 2154 ExtensionWebRequestEventRouter::RequestFilter filter; |
| 2155 base::DictionaryValue* value = NULL; | 2155 base::DictionaryValue* value = NULL; |
| 2156 error_.clear(); | 2156 error_.clear(); |
| 2157 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &value)); | 2157 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &value)); |
| 2158 // Failure + an empty error string means a fatal error. | 2158 // Failure + an empty error string means a fatal error. |
| 2159 EXTENSION_FUNCTION_VALIDATE(filter.InitFromValue(*value, &error_) || | 2159 EXTENSION_FUNCTION_VALIDATE(filter.InitFromValue(*value, &error_) || |
| 2160 !error_.empty()); | 2160 !error_.empty()); |
| 2161 if (!error_.empty()) | 2161 if (!error_.empty()) |
| 2162 return false; | 2162 return false; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2222 | 2222 |
| 2223 helpers::ClearCacheOnNavigation(); | 2223 helpers::ClearCacheOnNavigation(); |
| 2224 | 2224 |
| 2225 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 2225 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
| 2226 &helpers::NotifyWebRequestAPIUsed, | 2226 &helpers::NotifyWebRequestAPIUsed, |
| 2227 profile_id(), make_scoped_refptr(GetExtension()))); | 2227 profile_id(), make_scoped_refptr(GetExtension()))); |
| 2228 | 2228 |
| 2229 return true; | 2229 return true; |
| 2230 } | 2230 } |
| 2231 | 2231 |
| 2232 void WebRequestEventHandled::RespondWithError( | 2232 void WebRequestInternalEventHandledFunction::RespondWithError( |
| 2233 const std::string& event_name, | 2233 const std::string& event_name, |
| 2234 const std::string& sub_event_name, | 2234 const std::string& sub_event_name, |
| 2235 uint64 request_id, | 2235 uint64 request_id, |
| 2236 scoped_ptr<ExtensionWebRequestEventRouter::EventResponse> response, | 2236 scoped_ptr<ExtensionWebRequestEventRouter::EventResponse> response, |
| 2237 const std::string& error) { | 2237 const std::string& error) { |
| 2238 error_ = error; | 2238 error_ = error; |
| 2239 ExtensionWebRequestEventRouter::GetInstance()->OnEventHandled( | 2239 ExtensionWebRequestEventRouter::GetInstance()->OnEventHandled( |
| 2240 profile_id(), | 2240 profile_id(), |
| 2241 extension_id(), | 2241 extension_id(), |
| 2242 event_name, | 2242 event_name, |
| 2243 sub_event_name, | 2243 sub_event_name, |
| 2244 request_id, | 2244 request_id, |
| 2245 response.release()); | 2245 response.release()); |
| 2246 } | 2246 } |
| 2247 | 2247 |
| 2248 bool WebRequestEventHandled::RunImpl() { | 2248 bool WebRequestInternalEventHandledFunction::RunImpl() { |
| 2249 std::string event_name; | 2249 std::string event_name; |
| 2250 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name)); | 2250 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name)); |
| 2251 | 2251 |
| 2252 std::string sub_event_name; | 2252 std::string sub_event_name; |
| 2253 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &sub_event_name)); | 2253 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &sub_event_name)); |
| 2254 | 2254 |
| 2255 std::string request_id_str; | 2255 std::string request_id_str; |
| 2256 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &request_id_str)); | 2256 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &request_id_str)); |
| 2257 uint64 request_id; | 2257 uint64 request_id; |
| 2258 EXTENSION_FUNCTION_VALIDATE(base::StringToUint64(request_id_str, | 2258 EXTENSION_FUNCTION_VALIDATE(base::StringToUint64(request_id_str, |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2450 } else if ((*it)->name().find("AdBlock") != std::string::npos) { | 2450 } else if ((*it)->name().find("AdBlock") != std::string::npos) { |
| 2451 adblock = true; | 2451 adblock = true; |
| 2452 } else { | 2452 } else { |
| 2453 other = true; | 2453 other = true; |
| 2454 } | 2454 } |
| 2455 } | 2455 } |
| 2456 } | 2456 } |
| 2457 | 2457 |
| 2458 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); | 2458 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); |
| 2459 } | 2459 } |
| OLD | NEW |