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

Side by Side Diff: chrome/browser/extensions/api/tabs/tabs.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: 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/tabs.h" 5 #include "chrome/browser/extensions/api/tabs/tabs.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 // Don't let the extension crash the browser or renderers. 1300 // Don't let the extension crash the browser or renderers.
1301 if (ExtensionTabUtil::IsCrashURL(url)) { 1301 if (ExtensionTabUtil::IsCrashURL(url)) {
1302 error_ = keys::kNoCrashBrowserError; 1302 error_ = keys::kNoCrashBrowserError;
1303 return false; 1303 return false;
1304 } 1304 }
1305 1305
1306 // JavaScript URLs can do the same kinds of things as cross-origin XHR, so 1306 // JavaScript URLs can do the same kinds of things as cross-origin XHR, so
1307 // we need to check host permissions before allowing them. 1307 // we need to check host permissions before allowing them.
1308 if (url.SchemeIs(chrome::kJavaScriptScheme)) { 1308 if (url.SchemeIs(chrome::kJavaScriptScheme)) {
1309 if (!GetExtension()->CanExecuteScriptOnPage( 1309 if (!GetExtension()->CanExecuteScriptOnPage(
1310 tab_contents_->web_contents()->GetURL(), tab_id, NULL, &error_)) { 1310 tab_contents_->web_contents()->GetURL(),
1311 tab_contents_->web_contents()->GetURL(),
1312 tab_id,
1313 NULL,
1314 &error_)) {
1311 return false; 1315 return false;
1312 } 1316 }
1313 1317
1314 tab_contents_->extension_tab_helper()->script_executor()->ExecuteScript( 1318 tab_contents_->extension_tab_helper()->script_executor()->ExecuteScript(
1315 extension_id(), 1319 extension_id(),
1316 ScriptExecutor::JAVASCRIPT, 1320 ScriptExecutor::JAVASCRIPT,
1317 url.path(), 1321 url.path(),
1318 ScriptExecutor::TOP_FRAME, 1322 ScriptExecutor::TOP_FRAME,
1319 extensions::UserScript::DOCUMENT_IDLE, 1323 extensions::UserScript::DOCUMENT_IDLE,
1320 ScriptExecutor::MAIN_WORLD, 1324 ScriptExecutor::MAIN_WORLD,
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 // called for every API call the extension made. 1823 // called for every API call the extension made.
1820 GotLanguage(language); 1824 GotLanguage(language);
1821 } 1825 }
1822 1826
1823 void DetectTabLanguageFunction::GotLanguage(const std::string& language) { 1827 void DetectTabLanguageFunction::GotLanguage(const std::string& language) {
1824 SetResult(Value::CreateStringValue(language.c_str())); 1828 SetResult(Value::CreateStringValue(language.c_str()));
1825 SendResponse(true); 1829 SendResponse(true);
1826 1830
1827 Release(); // Balanced in Run() 1831 Release(); // Balanced in Run()
1828 } 1832 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698