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

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

Issue 10824149: Fix memory leak in ActiveTabPermissionManager. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 months 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
« no previous file with comments | « no previous file | chrome/common/extensions/extension.h » ('j') | 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) 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/active_tab_permission_manager.h" 5 #include "chrome/browser/extensions/active_tab_permission_manager.h"
6 6
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/extension_system.h" 8 #include "chrome/browser/extensions/extension_system.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sessions/session_id.h" 10 #include "chrome/browser/sessions/session_id.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 if (pattern.Parse(web_contents()->GetURL().spec()) != 46 if (pattern.Parse(web_contents()->GetURL().spec()) !=
47 URLPattern::PARSE_SUCCESS) { 47 URLPattern::PARSE_SUCCESS) {
48 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://. 48 // Pattern parsing could fail if this is an unsupported URL e.g. chrome://.
49 return; 49 return;
50 } 50 }
51 51
52 APIPermissionSet new_apis; 52 APIPermissionSet new_apis;
53 new_apis.insert(APIPermission::kTab); 53 new_apis.insert(APIPermission::kTab);
54 URLPatternSet new_hosts; 54 URLPatternSet new_hosts;
55 new_hosts.AddPattern(pattern); 55 new_hosts.AddPattern(pattern);
56 scoped_refptr<const PermissionSet> new_permissions =
57 new PermissionSet(new_apis, new_hosts, URLPatternSet());
56 58
57 extension->UpdateTabSpecificPermissions( 59 extension->UpdateTabSpecificPermissions(tab_id_, new_permissions);
58 tab_id_, new PermissionSet(new_apis, new_hosts, URLPatternSet()));
59 granted_extensions_.Insert(extension); 60 granted_extensions_.Insert(extension);
60 Send(new ExtensionMsg_UpdateTabSpecificPermissions(GetPageID(), 61 Send(new ExtensionMsg_UpdateTabSpecificPermissions(GetPageID(),
61 tab_id_, 62 tab_id_,
62 extension->id(), 63 extension->id(),
63 new_hosts)); 64 new_hosts));
64 } 65 }
65 66
66 bool ActiveTabPermissionManager::IsGranted(const Extension* extension) { 67 bool ActiveTabPermissionManager::IsGranted(const Extension* extension) {
67 return granted_extensions_.Contains(extension->id()); 68 return granted_extensions_.Contains(extension->id());
68 } 69 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 108
108 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); 109 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids));
109 granted_extensions_.Clear(); 110 granted_extensions_.Clear();
110 } 111 }
111 112
112 int32 ActiveTabPermissionManager::GetPageID() { 113 int32 ActiveTabPermissionManager::GetPageID() {
113 return web_contents()->GetController().GetActiveEntry()->GetPageID(); 114 return web_contents()->GetController().GetActiveEntry()->GetPageID();
114 } 115 }
115 116
116 } // namespace extensions 117 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/extension.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698