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

Side by Side Diff: chrome/browser/extensions/api/tabs/execute_code_in_tab_function.cc

Issue 10863002: Added check to prevent extensions from injecting scrips into other extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added license comments Created 8 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
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/api/tabs/execute_code_in_tab_function.h" 5 #include "chrome/browser/extensions/api/tabs/execute_code_in_tab_function.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/api/tabs/tabs.h" 10 #include "chrome/browser/extensions/api/tabs/tabs.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 if (!ExtensionTabUtil::GetTabById(execute_tab_id_, profile(), 71 if (!ExtensionTabUtil::GetTabById(execute_tab_id_, profile(),
72 include_incognito(), 72 include_incognito(),
73 NULL, NULL, &contents, NULL)) { 73 NULL, NULL, &contents, NULL)) {
74 return false; 74 return false;
75 } 75 }
76 76
77 // NOTE: This can give the wrong answer due to race conditions, but it is OK, 77 // NOTE: This can give the wrong answer due to race conditions, but it is OK,
78 // we check again in the renderer. 78 // we check again in the renderer.
79 CHECK(contents); 79 CHECK(contents);
80 if (!GetExtension()->CanExecuteScriptOnPage( 80 if (!GetExtension()->CanExecuteScriptOnPage(
81 contents->web_contents()->GetURL(), execute_tab_id_, NULL, &error_)) { 81 contents->web_contents()->GetURL(),
82 contents->web_contents()->GetURL(),
83 execute_tab_id_,
84 NULL,
85 &error_)) {
82 return false; 86 return false;
83 } 87 }
84 88
85 if (details_->code.get()) 89 if (details_->code.get())
86 return Execute(*details_->code); 90 return Execute(*details_->code);
87 91
88 CHECK(details_->file.get()); 92 CHECK(details_->file.get());
89 resource_ = GetExtension()->GetResource(*details_->file); 93 resource_ = GetExtension()->GetResource(*details_->file);
90 94
91 if (resource_.extension_root().empty() || resource_.relative_path().empty()) { 95 if (resource_.extension_root().empty() || resource_.relative_path().empty()) {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 contents->extension_tab_helper()->script_executor()->ExecuteScript( 268 contents->extension_tab_helper()->script_executor()->ExecuteScript(
265 extension->id(), 269 extension->id(),
266 script_type, 270 script_type,
267 code_string, 271 code_string,
268 frame_scope, 272 frame_scope,
269 run_at, 273 run_at,
270 ScriptExecutor::ISOLATED_WORLD, 274 ScriptExecutor::ISOLATED_WORLD,
271 base::Bind(&ExecuteCodeInTabFunction::OnExecuteCodeFinished, this)); 275 base::Bind(&ExecuteCodeInTabFunction::OnExecuteCodeFinished, this));
272 return true; 276 return true;
273 } 277 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/active_tab_unittest.cc ('k') | chrome/browser/extensions/api/tabs/tabs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698