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

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

Issue 14651017: Move RuntimeData and related permissions out of Extension class (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_unref_permissions
Patch Set: Latest master Created 7 years, 7 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
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_granter.h" 5 #include "chrome/browser/extensions/active_tab_permission_granter.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"
11 #include "chrome/common/chrome_notification_types.h" 11 #include "chrome/common/chrome_notification_types.h"
12 #include "chrome/common/extensions/extension.h" 12 #include "chrome/common/extensions/extension.h"
13 #include "chrome/common/extensions/extension_messages.h" 13 #include "chrome/common/extensions/extension_messages.h"
14 #include "chrome/common/extensions/permissions/permission_set.h" 14 #include "chrome/common/extensions/permissions/permission_set.h"
15 #include "chrome/common/extensions/permissions/permissions_data.h"
15 #include "content/public/browser/navigation_entry.h" 16 #include "content/public/browser/navigation_entry.h"
16 #include "content/public/browser/navigation_details.h" 17 #include "content/public/browser/navigation_details.h"
17 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/notification_source.h" 19 #include "content/public/browser/notification_source.h"
19 #include "content/public/browser/render_process_host.h" 20 #include "content/public/browser/render_process_host.h"
20 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
21 22
22 using content::RenderProcessHost; 23 using content::RenderProcessHost;
23 using content::WebContentsObserver; 24 using content::WebContentsObserver;
24 25
(...skipping 25 matching lines...) Expand all
50 return; 51 return;
51 } 52 }
52 53
53 APIPermissionSet new_apis; 54 APIPermissionSet new_apis;
54 new_apis.insert(APIPermission::kTab); 55 new_apis.insert(APIPermission::kTab);
55 URLPatternSet new_hosts; 56 URLPatternSet new_hosts;
56 new_hosts.AddPattern(pattern); 57 new_hosts.AddPattern(pattern);
57 scoped_refptr<const PermissionSet> new_permissions = 58 scoped_refptr<const PermissionSet> new_permissions =
58 new PermissionSet(new_apis, new_hosts, URLPatternSet()); 59 new PermissionSet(new_apis, new_hosts, URLPatternSet());
59 60
60 extension->UpdateTabSpecificPermissions(tab_id_, new_permissions); 61 PermissionsData::UpdateTabSpecificPermissions(extension,
62 tab_id_,
63 new_permissions);
61 granted_extensions_.Insert(extension); 64 granted_extensions_.Insert(extension);
62 Send(new ExtensionMsg_UpdateTabSpecificPermissions(GetPageID(), 65 Send(new ExtensionMsg_UpdateTabSpecificPermissions(GetPageID(),
63 tab_id_, 66 tab_id_,
64 extension->id(), 67 extension->id(),
65 new_hosts)); 68 new_hosts));
66 } 69 }
67 70
68 bool ActiveTabPermissionGranter::IsGranted(const Extension* extension) { 71 bool ActiveTabPermissionGranter::IsGranted(const Extension* extension) {
69 return granted_extensions_.Contains(extension->id()); 72 return granted_extensions_.Contains(extension->id());
70 } 73 }
(...skipping 25 matching lines...) Expand all
96 } 99 }
97 100
98 void ActiveTabPermissionGranter::ClearActiveExtensionsAndNotify() { 101 void ActiveTabPermissionGranter::ClearActiveExtensionsAndNotify() {
99 if (granted_extensions_.is_empty()) 102 if (granted_extensions_.is_empty())
100 return; 103 return;
101 104
102 std::vector<std::string> extension_ids; 105 std::vector<std::string> extension_ids;
103 106
104 for (ExtensionSet::const_iterator it = granted_extensions_.begin(); 107 for (ExtensionSet::const_iterator it = granted_extensions_.begin();
105 it != granted_extensions_.end(); ++it) { 108 it != granted_extensions_.end(); ++it) {
106 (*it)->ClearTabSpecificPermissions(tab_id_); 109 PermissionsData::ClearTabSpecificPermissions(*it, tab_id_);
107 extension_ids.push_back((*it)->id()); 110 extension_ids.push_back((*it)->id());
108 } 111 }
109 112
110 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); 113 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids));
111 granted_extensions_.Clear(); 114 granted_extensions_.Clear();
112 } 115 }
113 116
114 int32 ActiveTabPermissionGranter::GetPageID() { 117 int32 ActiveTabPermissionGranter::GetPageID() {
115 return web_contents()->GetController().GetActiveEntry()->GetPageID(); 118 return web_contents()->GetController().GetActiveEntry()->GetPageID();
116 } 119 }
117 120
118 } // namespace extensions 121 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | chrome/browser/extensions/active_tab_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698