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

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

Issue 204703002: Rename NOTIFICATION_EXTENSION_UNLOADED to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: maybe upload wont do something bizarre this time Created 6 years, 9 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 | Annotate | Revision Log
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/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.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 12 matching lines...) Expand all
23 23
24 using content::RenderProcessHost; 24 using content::RenderProcessHost;
25 using content::WebContentsObserver; 25 using content::WebContentsObserver;
26 26
27 namespace extensions { 27 namespace extensions {
28 28
29 ActiveTabPermissionGranter::ActiveTabPermissionGranter( 29 ActiveTabPermissionGranter::ActiveTabPermissionGranter(
30 content::WebContents* web_contents, int tab_id, Profile* profile) 30 content::WebContents* web_contents, int tab_id, Profile* profile)
31 : WebContentsObserver(web_contents), tab_id_(tab_id) { 31 : WebContentsObserver(web_contents), tab_id_(tab_id) {
32 registrar_.Add(this, 32 registrar_.Add(this,
33 chrome::NOTIFICATION_EXTENSION_UNLOADED, 33 chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
34 content::Source<Profile>(profile)); 34 content::Source<Profile>(profile));
35 } 35 }
36 36
37 ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {} 37 ActiveTabPermissionGranter::~ActiveTabPermissionGranter() {}
38 38
39 void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) { 39 void ActiveTabPermissionGranter::GrantIfRequested(const Extension* extension) {
40 if (granted_extensions_.Contains(extension->id())) 40 if (granted_extensions_.Contains(extension->id()))
41 return; 41 return;
42 42
43 APIPermissionSet new_apis; 43 APIPermissionSet new_apis;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 87
88 void ActiveTabPermissionGranter::WebContentsDestroyed( 88 void ActiveTabPermissionGranter::WebContentsDestroyed(
89 content::WebContents* web_contents) { 89 content::WebContents* web_contents) {
90 ClearActiveExtensionsAndNotify(); 90 ClearActiveExtensionsAndNotify();
91 } 91 }
92 92
93 void ActiveTabPermissionGranter::Observe( 93 void ActiveTabPermissionGranter::Observe(
94 int type, 94 int type,
95 const content::NotificationSource& source, 95 const content::NotificationSource& source,
96 const content::NotificationDetails& details) { 96 const content::NotificationDetails& details) {
97 DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_UNLOADED); 97 DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED);
98 const Extension* extension = 98 const Extension* extension =
99 content::Details<UnloadedExtensionInfo>(details)->extension; 99 content::Details<UnloadedExtensionInfo>(details)->extension;
100 // Note: don't need to clear the permissions (nor tell the renderer about it) 100 // Note: don't need to clear the permissions (nor tell the renderer about it)
101 // because it's being unloaded anyway. 101 // because it's being unloaded anyway.
102 granted_extensions_.Remove(extension->id()); 102 granted_extensions_.Remove(extension->id());
103 } 103 }
104 104
105 void ActiveTabPermissionGranter::ClearActiveExtensionsAndNotify() { 105 void ActiveTabPermissionGranter::ClearActiveExtensionsAndNotify() {
106 if (granted_extensions_.is_empty()) 106 if (granted_extensions_.is_empty())
107 return; 107 return;
108 108
109 std::vector<std::string> extension_ids; 109 std::vector<std::string> extension_ids;
110 110
111 for (ExtensionSet::const_iterator it = granted_extensions_.begin(); 111 for (ExtensionSet::const_iterator it = granted_extensions_.begin();
112 it != granted_extensions_.end(); ++it) { 112 it != granted_extensions_.end(); ++it) {
113 PermissionsData::ClearTabSpecificPermissions(it->get(), tab_id_); 113 PermissionsData::ClearTabSpecificPermissions(it->get(), tab_id_);
114 extension_ids.push_back((*it)->id()); 114 extension_ids.push_back((*it)->id());
115 } 115 }
116 116
117 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); 117 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids));
118 granted_extensions_.Clear(); 118 granted_extensions_.Clear();
119 } 119 }
120 120
121 } // namespace extensions 121 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698