Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: chrome/browser/extensions/extension_webrequest_api.cc

Issue 8772058: Clear in-memory cache after adding or deleting an event handler to ensure it is effective (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_webrequest_api.h" 5 #include "chrome/browser/extensions/extension_webrequest_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 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 CHECK_EQ(listeners_[profile][event_name].count(listener), 1u) << 1032 CHECK_EQ(listeners_[profile][event_name].count(listener), 1u) <<
1033 "extension=" << extension_id << " event=" << event_name; 1033 "extension=" << extension_id << " event=" << event_name;
1034 1034
1035 // Unblock any request that this event listener may have been blocking. 1035 // Unblock any request that this event listener may have been blocking.
1036 for (std::set<uint64>::iterator it = found->blocked_requests.begin(); 1036 for (std::set<uint64>::iterator it = found->blocked_requests.begin();
1037 it != found->blocked_requests.end(); ++it) { 1037 it != found->blocked_requests.end(); ++it) {
1038 DecrementBlockCount(profile, extension_id, event_name, *it, NULL); 1038 DecrementBlockCount(profile, extension_id, event_name, *it, NULL);
1039 } 1039 }
1040 1040
1041 listeners_[profile][event_name].erase(listener); 1041 listeners_[profile][event_name].erase(listener);
1042
1043 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
1044 base::Bind(&ClearCacheOnNavigationOnUI));
1042 } 1045 }
1043 1046
1044 void ExtensionWebRequestEventRouter::OnOTRProfileCreated( 1047 void ExtensionWebRequestEventRouter::OnOTRProfileCreated(
1045 void* original_profile, void* otr_profile) { 1048 void* original_profile, void* otr_profile) {
1046 cross_profile_map_[original_profile] = otr_profile; 1049 cross_profile_map_[original_profile] = otr_profile;
1047 cross_profile_map_[otr_profile] = original_profile; 1050 cross_profile_map_[otr_profile] = original_profile;
1048 } 1051 }
1049 1052
1050 void ExtensionWebRequestEventRouter::OnOTRProfileDestroyed( 1053 void ExtensionWebRequestEventRouter::OnOTRProfileDestroyed(
1051 void* original_profile, void* otr_profile) { 1054 void* original_profile, void* otr_profile) {
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1487 ExtensionAPIPermission::kWebRequestBlocking)) { 1490 ExtensionAPIPermission::kWebRequestBlocking)) {
1488 error_ = keys::kBlockingPermissionRequired; 1491 error_ = keys::kBlockingPermissionRequired;
1489 return false; 1492 return false;
1490 } 1493 }
1491 1494
1492 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener( 1495 ExtensionWebRequestEventRouter::GetInstance()->AddEventListener(
1493 profile_id(), extension_id(), extension_name, 1496 profile_id(), extension_id(), extension_name,
1494 event_name, sub_event_name, filter, 1497 event_name, sub_event_name, filter,
1495 extra_info_spec, ipc_sender_weak()); 1498 extra_info_spec, ipc_sender_weak());
1496 1499
1500 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
1501 base::Bind(&ClearCacheOnNavigationOnUI));
1502
1497 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( 1503 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind(
1498 &NotifyWebRequestAPIUsed, 1504 &NotifyWebRequestAPIUsed,
1499 profile_id(), make_scoped_refptr(GetExtension()))); 1505 profile_id(), make_scoped_refptr(GetExtension())));
1500 1506
1501 return true; 1507 return true;
1502 } 1508 }
1503 1509
1504 bool WebRequestEventHandled::RunImpl() { 1510 bool WebRequestEventHandled::RunImpl() {
1505 std::string event_name; 1511 std::string event_name;
1506 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name)); 1512 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &event_name));
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 } else if ((*it)->name().find("AdBlock") != std::string::npos) { 1668 } else if ((*it)->name().find("AdBlock") != std::string::npos) {
1663 adblock = true; 1669 adblock = true;
1664 } else { 1670 } else {
1665 other = true; 1671 other = true;
1666 } 1672 }
1667 } 1673 }
1668 } 1674 }
1669 1675
1670 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other)); 1676 host->Send(new ExtensionMsg_UsingWebRequestAPI(adblock, adblock_plus, other));
1671 } 1677 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698