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

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

Issue 296483011: Run any pending injections in ActiveScriptController if permission is granted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ben's Created 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/active_script_controller_unittest.cc ('k') | 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) 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/active_script_controller.h"
7 #include "chrome/browser/profiles/profile.h" 8 #include "chrome/browser/profiles/profile.h"
8 #include "content/public/browser/navigation_details.h" 9 #include "content/public/browser/navigation_details.h"
9 #include "content/public/browser/navigation_entry.h" 10 #include "content/public/browser/navigation_entry.h"
10 #include "content/public/browser/web_contents.h" 11 #include "content/public/browser/web_contents.h"
11 #include "extensions/browser/extension_registry.h" 12 #include "extensions/browser/extension_registry.h"
12 #include "extensions/common/extension_messages.h" 13 #include "extensions/common/extension_messages.h"
13 #include "extensions/common/permissions/permission_set.h" 14 #include "extensions/common/permissions/permission_set.h"
14 #include "extensions/common/permissions/permissions_data.h" 15 #include "extensions/common/permissions/permissions_data.h"
15 #include "extensions/common/user_script.h" 16 #include "extensions/common/user_script.h"
16 #include "url/gurl.h" 17 #include "url/gurl.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 tab_id_, 77 tab_id_,
77 new_permissions); 78 new_permissions);
78 const content::NavigationEntry* navigation_entry = 79 const content::NavigationEntry* navigation_entry =
79 web_contents()->GetController().GetVisibleEntry(); 80 web_contents()->GetController().GetVisibleEntry();
80 if (navigation_entry) { 81 if (navigation_entry) {
81 Send(new ExtensionMsg_UpdateTabSpecificPermissions( 82 Send(new ExtensionMsg_UpdateTabSpecificPermissions(
82 navigation_entry->GetPageID(), 83 navigation_entry->GetPageID(),
83 tab_id_, 84 tab_id_,
84 extension->id(), 85 extension->id(),
85 new_hosts)); 86 new_hosts));
87 // If more things ever need to know about this, we should consider making
88 // an observer class.
89 // It's important that this comes after the IPC is sent to the renderer,
90 // so that any tasks executing in the renderer occur after it has the
91 // updated permissions.
92 ActiveScriptController::GetForWebContents(web_contents())
93 ->OnActiveTabPermissionGranted(extension);
86 } 94 }
87 } 95 }
88 } 96 }
89 97
90 void ActiveTabPermissionGranter::DidNavigateMainFrame( 98 void ActiveTabPermissionGranter::DidNavigateMainFrame(
91 const content::LoadCommittedDetails& details, 99 const content::LoadCommittedDetails& details,
92 const content::FrameNavigateParams& params) { 100 const content::FrameNavigateParams& params) {
93 if (details.is_in_page) 101 if (details.is_in_page)
94 return; 102 return;
95 DCHECK(details.is_main_frame); // important: sub-frames don't get granted! 103 DCHECK(details.is_main_frame); // important: sub-frames don't get granted!
(...skipping 23 matching lines...) Expand all
119 it != granted_extensions_.end(); ++it) { 127 it != granted_extensions_.end(); ++it) {
120 PermissionsData::ClearTabSpecificPermissions(it->get(), tab_id_); 128 PermissionsData::ClearTabSpecificPermissions(it->get(), tab_id_);
121 extension_ids.push_back((*it)->id()); 129 extension_ids.push_back((*it)->id());
122 } 130 }
123 131
124 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids)); 132 Send(new ExtensionMsg_ClearTabSpecificPermissions(tab_id_, extension_ids));
125 granted_extensions_.Clear(); 133 granted_extensions_.Clear();
126 } 134 }
127 135
128 } // namespace extensions 136 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/active_script_controller_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698