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

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

Issue 480883002: Move session_id.{cc,h} from chrome/browser/sessions to components/sessions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | chrome/browser/extensions/active_tab_unittest.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_script_controller.h" 5 #include "chrome/browser/extensions/active_script_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "chrome/browser/extensions/active_tab_permission_granter.h" 12 #include "chrome/browser/extensions/active_tab_permission_granter.h"
13 #include "chrome/browser/extensions/extension_action.h" 13 #include "chrome/browser/extensions/extension_action.h"
14 #include "chrome/browser/extensions/extension_action_manager.h" 14 #include "chrome/browser/extensions/extension_action_manager.h"
15 #include "chrome/browser/extensions/extension_util.h" 15 #include "chrome/browser/extensions/extension_util.h"
16 #include "chrome/browser/extensions/location_bar_controller.h" 16 #include "chrome/browser/extensions/location_bar_controller.h"
17 #include "chrome/browser/extensions/permissions_updater.h" 17 #include "chrome/browser/extensions/permissions_updater.h"
18 #include "chrome/browser/extensions/tab_helper.h" 18 #include "chrome/browser/extensions/tab_helper.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/sessions/session_id.h" 20 #include "chrome/browser/sessions/session_tab_helper.h"
21 #include "chrome/common/extensions/api/extension_action/action_info.h" 21 #include "chrome/common/extensions/api/extension_action/action_info.h"
22 #include "content/public/browser/navigation_controller.h" 22 #include "content/public/browser/navigation_controller.h"
23 #include "content/public/browser/navigation_entry.h" 23 #include "content/public/browser/navigation_entry.h"
24 #include "content/public/browser/render_view_host.h" 24 #include "content/public/browser/render_view_host.h"
25 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
26 #include "extensions/browser/extension_registry.h" 26 #include "extensions/browser/extension_registry.h"
27 #include "extensions/common/extension.h" 27 #include "extensions/common/extension.h"
28 #include "extensions/common/extension_messages.h" 28 #include "extensions/common/extension_messages.h"
29 #include "extensions/common/extension_set.h" 29 #include "extensions/common/extension_set.h"
30 #include "extensions/common/feature_switch.h" 30 #include "extensions/common/feature_switch.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 // If the feature is not enabled, we automatically allow all extensions to 189 // If the feature is not enabled, we automatically allow all extensions to
190 // run scripts. 190 // run scripts.
191 if (!enabled_) 191 if (!enabled_)
192 permitted_extensions_.insert(extension->id()); 192 permitted_extensions_.insert(extension->id());
193 193
194 // Allow the extension if it's been explicitly granted permission. 194 // Allow the extension if it's been explicitly granted permission.
195 if (permitted_extensions_.count(extension->id()) > 0) 195 if (permitted_extensions_.count(extension->id()) > 0)
196 return PermissionsData::ACCESS_ALLOWED; 196 return PermissionsData::ACCESS_ALLOWED;
197 197
198 GURL url = web_contents()->GetVisibleURL(); 198 GURL url = web_contents()->GetVisibleURL();
199 int tab_id = SessionID::IdForTab(web_contents()); 199 int tab_id = SessionTabHelper::IdForTab(web_contents());
200 switch (type) { 200 switch (type) {
201 case UserScript::CONTENT_SCRIPT: 201 case UserScript::CONTENT_SCRIPT:
202 return extension->permissions_data()->GetContentScriptAccess( 202 return extension->permissions_data()->GetContentScriptAccess(
203 extension, url, url, tab_id, -1, NULL); 203 extension, url, url, tab_id, -1, NULL);
204 case UserScript::PROGRAMMATIC_SCRIPT: 204 case UserScript::PROGRAMMATIC_SCRIPT:
205 return extension->permissions_data()->GetPageAccess( 205 return extension->permissions_data()->GetPageAccess(
206 extension, url, url, tab_id, -1, NULL); 206 extension, url, url, tab_id, -1, NULL);
207 } 207 }
208 208
209 NOTREACHED(); 209 NOTREACHED();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 UMA_HISTOGRAM_COUNTS_100( 346 UMA_HISTOGRAM_COUNTS_100(
347 "Extensions.ActiveScriptController.PermittedExtensions", 347 "Extensions.ActiveScriptController.PermittedExtensions",
348 permitted_extensions_.size()); 348 permitted_extensions_.size());
349 UMA_HISTOGRAM_COUNTS_100( 349 UMA_HISTOGRAM_COUNTS_100(
350 "Extensions.ActiveScriptController.DeniedExtensions", 350 "Extensions.ActiveScriptController.DeniedExtensions",
351 pending_requests_.size()); 351 pending_requests_.size());
352 } 352 }
353 } 353 }
354 354
355 } // namespace extensions 355 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/android/tab_android.h ('k') | chrome/browser/extensions/active_tab_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698