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 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1595 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 1595 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
1596 BrowserThread::PostTask(BrowserThread::UI, | 1596 BrowserThread::PostTask(BrowserThread::UI, |
1597 FROM_HERE, | 1597 FROM_HERE, |
1598 base::Bind(&LogExtensionActivity, | 1598 base::Bind(&LogExtensionActivity, |
1599 profile, | 1599 profile, |
1600 extension_id, | 1600 extension_id, |
1601 url, | 1601 url, |
1602 api_call, | 1602 api_call, |
1603 details.release())); | 1603 details.release())); |
1604 } else { | 1604 } else { |
1605 extensions::ActivityLog::GetInstance(profile)->LogWebRequestAction( | 1605 // An ExtensionService might not be running during unit tests, or an |
1606 extension_id, | 1606 // extension might have been unloadd by the time we get to logging it. In |
1607 url, | 1607 // those cases log a warning. |
1608 api_call, | 1608 ExtensionService* extension_service = |
1609 details.Pass(), | 1609 extensions::ExtensionSystem::Get(profile)->extension_service(); |
1610 ""); | 1610 if (!extension_service) { |
| 1611 LOG(WARNING) << "ExtensionService does not seem to be available " |
| 1612 << "(this may be normal for unit tests)"; |
| 1613 } else { |
| 1614 const Extension* extension = |
| 1615 extension_service->extensions()->GetByID(extension_id); |
| 1616 if (!extension) { |
| 1617 LOG(WARNING) << "Extension " << extension_id << " not found!"; |
| 1618 } else { |
| 1619 extensions::ActivityLog::GetInstance(profile)->LogWebRequestAction( |
| 1620 extension, |
| 1621 url, |
| 1622 api_call, |
| 1623 details.Pass(), |
| 1624 ""); |
| 1625 } |
| 1626 } |
1611 } | 1627 } |
1612 } | 1628 } |
1613 | 1629 |
1614 } // namespace | 1630 } // namespace |
1615 | 1631 |
1616 void ExtensionWebRequestEventRouter::DecrementBlockCount( | 1632 void ExtensionWebRequestEventRouter::DecrementBlockCount( |
1617 void* profile, | 1633 void* profile, |
1618 const std::string& extension_id, | 1634 const std::string& extension_id, |
1619 const std::string& event_name, | 1635 const std::string& event_name, |
1620 uint64 request_id, | 1636 uint64 request_id, |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2251 } else if ((*it)->name().find("AdBlock") != std::string::npos) { | 2267 } else if ((*it)->name().find("AdBlock") != std::string::npos) { |
2252 adblock = true; | 2268 adblock = true; |
2253 } else { | 2269 } else { |
2254 other = true; | 2270 other = true; |
2255 } | 2271 } |
2256 } | 2272 } |
2257 } | 2273 } |
2258 | 2274 |
2259 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); | 2275 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); |
2260 } | 2276 } |
OLD | NEW |