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 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2137 // We only check whether tokens are left here. Deducting a token happens in | 2137 // We only check whether tokens are left here. Deducting a token happens in |
2138 // OnPageLoad(). | 2138 // OnPageLoad(). |
2139 return bucket->has_tokens(); | 2139 return bucket->has_tokens(); |
2140 } | 2140 } |
2141 | 2141 |
2142 void ClearCacheQuotaHeuristic::OnPageLoad(Bucket* bucket) { | 2142 void ClearCacheQuotaHeuristic::OnPageLoad(Bucket* bucket) { |
2143 callback_registered_ = false; | 2143 callback_registered_ = false; |
2144 bucket->DeductToken(); | 2144 bucket->DeductToken(); |
2145 } | 2145 } |
2146 | 2146 |
2147 bool WebRequestInternalAddEventListenerFunction::RunImpl() { | 2147 bool WebRequestInternalAddEventListenerFunction::RunSync() { |
2148 // Argument 0 is the callback, which we don't use here. | 2148 // Argument 0 is the callback, which we don't use here. |
2149 ExtensionWebRequestEventRouter::RequestFilter filter; | 2149 ExtensionWebRequestEventRouter::RequestFilter filter; |
2150 base::DictionaryValue* value = NULL; | 2150 base::DictionaryValue* value = NULL; |
2151 error_.clear(); | 2151 error_.clear(); |
2152 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &value)); | 2152 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(1, &value)); |
2153 // Failure + an empty error string means a fatal error. | 2153 // Failure + an empty error string means a fatal error. |
2154 EXTENSION_FUNCTION_VALIDATE(filter.InitFromValue(*value, &error_) || | 2154 EXTENSION_FUNCTION_VALIDATE(filter.InitFromValue(*value, &error_) || |
2155 !error_.empty()); | 2155 !error_.empty()); |
2156 if (!error_.empty()) | 2156 if (!error_.empty()) |
2157 return false; | 2157 return false; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 error_ = error; | 2233 error_ = error; |
2234 ExtensionWebRequestEventRouter::GetInstance()->OnEventHandled( | 2234 ExtensionWebRequestEventRouter::GetInstance()->OnEventHandled( |
2235 profile_id(), | 2235 profile_id(), |
2236 extension_id(), | 2236 extension_id(), |
2237 event_name, | 2237 event_name, |
2238 sub_event_name, | 2238 sub_event_name, |
2239 request_id, | 2239 request_id, |
2240 response.release()); | 2240 response.release()); |
2241 } | 2241 } |
2242 | 2242 |
2243 bool WebRequestInternalEventHandledFunction::RunImpl() { | 2243 bool WebRequestInternalEventHandledFunction::RunSync() { |
2244 std::string event_name; | 2244 std::string event_name; |
2245 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name)); | 2245 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name)); |
2246 | 2246 |
2247 std::string sub_event_name; | 2247 std::string sub_event_name; |
2248 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &sub_event_name)); | 2248 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &sub_event_name)); |
2249 | 2249 |
2250 std::string request_id_str; | 2250 std::string request_id_str; |
2251 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &request_id_str)); | 2251 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &request_id_str)); |
2252 uint64 request_id; | 2252 uint64 request_id; |
2253 EXTENSION_FUNCTION_VALIDATE(base::StringToUint64(request_id_str, | 2253 EXTENSION_FUNCTION_VALIDATE(base::StringToUint64(request_id_str, |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2413 BrowserThread::PostTask( | 2413 BrowserThread::PostTask( |
2414 BrowserThread::UI, | 2414 BrowserThread::UI, |
2415 FROM_HERE, | 2415 FROM_HERE, |
2416 base::Bind(&ExtensionWarningService::NotifyWarningsOnUI, | 2416 base::Bind(&ExtensionWarningService::NotifyWarningsOnUI, |
2417 profile_id(), warnings)); | 2417 profile_id(), warnings)); |
2418 | 2418 |
2419 // Continue gracefully. | 2419 // Continue gracefully. |
2420 Run(); | 2420 Run(); |
2421 } | 2421 } |
2422 | 2422 |
2423 bool WebRequestHandlerBehaviorChangedFunction::RunImpl() { | 2423 bool WebRequestHandlerBehaviorChangedFunction::RunSync() { |
2424 helpers::ClearCacheOnNavigation(); | 2424 helpers::ClearCacheOnNavigation(); |
2425 return true; | 2425 return true; |
2426 } | 2426 } |
2427 | 2427 |
2428 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host) { | 2428 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host) { |
2429 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); | 2429 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); |
2430 if (!profile) | 2430 if (!profile) |
2431 return; | 2431 return; |
2432 | 2432 |
2433 bool adblock = false; | 2433 bool adblock = false; |
(...skipping 11 matching lines...) Expand all Loading... |
2445 } else if ((*it)->name().find("AdBlock") != std::string::npos) { | 2445 } else if ((*it)->name().find("AdBlock") != std::string::npos) { |
2446 adblock = true; | 2446 adblock = true; |
2447 } else { | 2447 } else { |
2448 other = true; | 2448 other = true; |
2449 } | 2449 } |
2450 } | 2450 } |
2451 } | 2451 } |
2452 | 2452 |
2453 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); | 2453 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); |
2454 } | 2454 } |
OLD | NEW |