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/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 266 |
267 // Represents a single unique listener to an event, along with whatever filter | 267 // Represents a single unique listener to an event, along with whatever filter |
268 // parameters and extra_info_spec were specified at the time the listener was | 268 // parameters and extra_info_spec were specified at the time the listener was |
269 // added. | 269 // added. |
270 struct ExtensionWebRequestEventRouter::EventListener { | 270 struct ExtensionWebRequestEventRouter::EventListener { |
271 std::string extension_id; | 271 std::string extension_id; |
272 std::string extension_name; | 272 std::string extension_name; |
273 std::string sub_event_name; | 273 std::string sub_event_name; |
274 RequestFilter filter; | 274 RequestFilter filter; |
275 int extra_info_spec; | 275 int extra_info_spec; |
276 base::WeakPtr<IPC::Message::Sender> ipc_sender; | 276 base::WeakPtr<IPC::Sender> ipc_sender; |
277 mutable std::set<uint64> blocked_requests; | 277 mutable std::set<uint64> blocked_requests; |
278 | 278 |
279 // Comparator to work with std::set. | 279 // Comparator to work with std::set. |
280 bool operator<(const EventListener& that) const { | 280 bool operator<(const EventListener& that) const { |
281 if (extension_id < that.extension_id) | 281 if (extension_id < that.extension_id) |
282 return true; | 282 return true; |
283 if (extension_id == that.extension_id && | 283 if (extension_id == that.extension_id && |
284 sub_event_name < that.sub_event_name) | 284 sub_event_name < that.sub_event_name) |
285 return true; | 285 return true; |
286 return false; | 286 return false; |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 } | 984 } |
985 | 985 |
986 bool ExtensionWebRequestEventRouter::AddEventListener( | 986 bool ExtensionWebRequestEventRouter::AddEventListener( |
987 void* profile, | 987 void* profile, |
988 const std::string& extension_id, | 988 const std::string& extension_id, |
989 const std::string& extension_name, | 989 const std::string& extension_name, |
990 const std::string& event_name, | 990 const std::string& event_name, |
991 const std::string& sub_event_name, | 991 const std::string& sub_event_name, |
992 const RequestFilter& filter, | 992 const RequestFilter& filter, |
993 int extra_info_spec, | 993 int extra_info_spec, |
994 base::WeakPtr<IPC::Message::Sender> ipc_sender) { | 994 base::WeakPtr<IPC::Sender> ipc_sender) { |
995 if (!IsWebRequestEvent(event_name)) | 995 if (!IsWebRequestEvent(event_name)) |
996 return false; | 996 return false; |
997 | 997 |
998 EventListener listener; | 998 EventListener listener; |
999 listener.extension_id = extension_id; | 999 listener.extension_id = extension_id; |
1000 listener.extension_name = extension_name; | 1000 listener.extension_name = extension_name; |
1001 listener.sub_event_name = sub_event_name; | 1001 listener.sub_event_name = sub_event_name; |
1002 listener.filter = filter; | 1002 listener.filter = filter; |
1003 listener.extra_info_spec = extra_info_spec; | 1003 listener.extra_info_spec = extra_info_spec; |
1004 listener.ipc_sender = ipc_sender; | 1004 listener.ipc_sender = ipc_sender; |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 } else if ((*it)->name().find("AdBlock") != std::string::npos) { | 1751 } else if ((*it)->name().find("AdBlock") != std::string::npos) { |
1752 adblock = true; | 1752 adblock = true; |
1753 } else { | 1753 } else { |
1754 other = true; | 1754 other = true; |
1755 } | 1755 } |
1756 } | 1756 } |
1757 } | 1757 } |
1758 | 1758 |
1759 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); | 1759 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); |
1760 } | 1760 } |
OLD | NEW |