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

Side by Side Diff: chrome/renderer/extensions/user_script_slave.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
« no previous file with comments | « chrome/renderer/extensions/user_script_scheduler.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/renderer/extensions/user_script_slave.h" 5 #include "chrome/renderer/extensions/user_script_slave.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/perftimer.h" 12 #include "base/perftimer.h"
13 #include "base/pickle.h" 13 #include "base/pickle.h"
14 #include "base/shared_memory.h" 14 #include "base/shared_memory.h"
15 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
16 #include "chrome/common/extensions/csp_handler.h" 16 #include "chrome/common/extensions/csp_handler.h"
17 #include "chrome/common/extensions/extension.h" 17 #include "chrome/common/extensions/extension.h"
18 #include "chrome/common/extensions/extension_messages.h" 18 #include "chrome/common/extensions/extension_messages.h"
19 #include "chrome/common/extensions/extension_set.h" 19 #include "chrome/common/extensions/extension_set.h"
20 #include "chrome/common/extensions/permissions/permissions_data.h"
20 #include "chrome/common/url_constants.h" 21 #include "chrome/common/url_constants.h"
21 #include "chrome/renderer/chrome_render_process_observer.h" 22 #include "chrome/renderer/chrome_render_process_observer.h"
22 #include "chrome/renderer/extensions/dom_activity_logger.h" 23 #include "chrome/renderer/extensions/dom_activity_logger.h"
23 #include "chrome/renderer/extensions/extension_groups.h" 24 #include "chrome/renderer/extensions/extension_groups.h"
24 #include "chrome/renderer/isolated_world_ids.h" 25 #include "chrome/renderer/isolated_world_ids.h"
25 #include "content/public/renderer/render_thread.h" 26 #include "content/public/renderer/render_thread.h"
26 #include "content/public/renderer/render_view.h" 27 #include "content/public/renderer/render_view.h"
27 #include "googleurl/src/gurl.h" 28 #include "googleurl/src/gurl.h"
28 #include "grit/renderer_resources.h" 29 #include "grit/renderer_resources.h"
29 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h" 30 #include "third_party/WebKit/Source/Platform/chromium/public/WebURLRequest.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 if (iter->second == isolated_world_id) 93 if (iter->second == isolated_world_id)
93 return iter->first; 94 return iter->first;
94 } 95 }
95 return std::string(); 96 return std::string();
96 } 97 }
97 98
98 // static 99 // static
99 void UserScriptSlave::InitializeIsolatedWorld(int isolated_world_id, 100 void UserScriptSlave::InitializeIsolatedWorld(int isolated_world_id,
100 const Extension* extension) { 101 const Extension* extension) {
101 const URLPatternSet& permissions = 102 const URLPatternSet& permissions =
102 extension->GetEffectiveHostPermissions(); 103 PermissionsData::GetEffectiveHostPermissions(extension);
103 for (URLPatternSet::const_iterator i = permissions.begin(); 104 for (URLPatternSet::const_iterator i = permissions.begin();
104 i != permissions.end(); ++i) { 105 i != permissions.end(); ++i) {
105 const char* schemes[] = { 106 const char* schemes[] = {
106 chrome::kHttpScheme, 107 chrome::kHttpScheme,
107 chrome::kHttpsScheme, 108 chrome::kHttpsScheme,
108 chrome::kFileScheme, 109 chrome::kFileScheme,
109 chrome::kChromeUIScheme, 110 chrome::kChromeUIScheme,
110 }; 111 };
111 for (size_t j = 0; j < arraysize(schemes); ++j) { 112 for (size_t j = 0; j < arraysize(schemes); ++j) {
112 if (i->MatchesScheme(schemes[j])) { 113 if (i->MatchesScheme(schemes[j])) {
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 282
282 const Extension* extension = extensions_->GetByID(script->extension_id()); 283 const Extension* extension = extensions_->GetByID(script->extension_id());
283 284
284 // Since extension info is sent separately from user script info, they can 285 // Since extension info is sent separately from user script info, they can
285 // be out of sync. We just ignore this situation. 286 // be out of sync. We just ignore this situation.
286 if (!extension) 287 if (!extension)
287 continue; 288 continue;
288 289
289 // Content scripts are not tab-specific. 290 // Content scripts are not tab-specific.
290 int kNoTabId = -1; 291 int kNoTabId = -1;
291 if (!extension->CanExecuteScriptOnPage(data_source_url, 292 if (!PermissionsData::CanExecuteScriptOnPage(extension,
292 frame->top()->document().url(), 293 data_source_url,
293 kNoTabId, 294 frame->top()->document().url(),
294 script, 295 kNoTabId,
295 NULL)) { 296 script,
297 NULL)) {
296 continue; 298 continue;
297 } 299 }
298 300
299 // We rely on WebCore for CSS injection, but it's still useful to know how 301 // We rely on WebCore for CSS injection, but it's still useful to know how
300 // many css files there are. 302 // many css files there are.
301 if (location == UserScript::DOCUMENT_START) 303 if (location == UserScript::DOCUMENT_START)
302 num_css += script->css_scripts().size(); 304 num_css += script->css_scripts().size();
303 305
304 if (script->run_location() == location) { 306 if (script->run_location() == location) {
305 num_scripts += script->js_scripts().size(); 307 num_scripts += script->js_scripts().size();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 } else if (location == UserScript::DOCUMENT_IDLE) { 376 } else if (location == UserScript::DOCUMENT_IDLE) {
375 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts); 377 UMA_HISTOGRAM_COUNTS_100("Extensions.InjectIdle_ScriptCount", num_scripts);
376 if (num_scripts) 378 if (num_scripts)
377 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed()); 379 UMA_HISTOGRAM_TIMES("Extensions.InjectIdle_Time", timer.Elapsed());
378 } else { 380 } else {
379 NOTREACHED(); 381 NOTREACHED();
380 } 382 }
381 } 383 }
382 384
383 } // namespace extensions 385 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/user_script_scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698