OLD | NEW |
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_api.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1171 // Don't let the extension crash the browser or renderers. | 1171 // Don't let the extension crash the browser or renderers. |
1172 if (ExtensionTabUtil::IsCrashURL(url)) { | 1172 if (ExtensionTabUtil::IsCrashURL(url)) { |
1173 error_ = keys::kNoCrashBrowserError; | 1173 error_ = keys::kNoCrashBrowserError; |
1174 return false; | 1174 return false; |
1175 } | 1175 } |
1176 | 1176 |
1177 // JavaScript URLs can do the same kinds of things as cross-origin XHR, so | 1177 // JavaScript URLs can do the same kinds of things as cross-origin XHR, so |
1178 // we need to check host permissions before allowing them. | 1178 // we need to check host permissions before allowing them. |
1179 if (url.SchemeIs(url::kJavaScriptScheme)) { | 1179 if (url.SchemeIs(url::kJavaScriptScheme)) { |
1180 content::RenderProcessHost* process = web_contents_->GetRenderProcessHost(); | 1180 content::RenderProcessHost* process = web_contents_->GetRenderProcessHost(); |
1181 if (!GetExtension()->permissions_data()->CanExecuteScriptOnPage( | 1181 if (!GetExtension()->permissions_data()->CanAccessPage( |
1182 GetExtension(), | 1182 GetExtension(), |
1183 web_contents_->GetURL(), | 1183 web_contents_->GetURL(), |
1184 web_contents_->GetURL(), | 1184 web_contents_->GetURL(), |
1185 tab_id, | 1185 tab_id, |
1186 NULL, | |
1187 process ? process->GetID() : -1, | 1186 process ? process->GetID() : -1, |
1188 &error_)) { | 1187 &error_)) { |
1189 return false; | 1188 return false; |
1190 } | 1189 } |
1191 | 1190 |
1192 TabHelper::FromWebContents(web_contents_)->script_executor()->ExecuteScript( | 1191 TabHelper::FromWebContents(web_contents_)->script_executor()->ExecuteScript( |
1193 extension_id(), | 1192 extension_id(), |
1194 ScriptExecutor::JAVASCRIPT, | 1193 ScriptExecutor::JAVASCRIPT, |
1195 url.GetContent(), | 1194 url.GetContent(), |
1196 ScriptExecutor::TOP_FRAME, | 1195 ScriptExecutor::TOP_FRAME, |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1649 NULL, | 1648 NULL, |
1650 &error_)) { | 1649 &error_)) { |
1651 return false; | 1650 return false; |
1652 } | 1651 } |
1653 | 1652 |
1654 CHECK(contents); | 1653 CHECK(contents); |
1655 | 1654 |
1656 // NOTE: This can give the wrong answer due to race conditions, but it is OK, | 1655 // NOTE: This can give the wrong answer due to race conditions, but it is OK, |
1657 // we check again in the renderer. | 1656 // we check again in the renderer. |
1658 content::RenderProcessHost* process = contents->GetRenderProcessHost(); | 1657 content::RenderProcessHost* process = contents->GetRenderProcessHost(); |
1659 if (!GetExtension()->permissions_data()->CanExecuteScriptOnPage( | 1658 if (!GetExtension()->permissions_data()->CanAccessPage( |
1660 GetExtension(), | 1659 GetExtension(), |
1661 contents->GetURL(), | 1660 contents->GetURL(), |
1662 contents->GetURL(), | 1661 contents->GetURL(), |
1663 execute_tab_id_, | 1662 execute_tab_id_, |
1664 NULL, | |
1665 process ? process->GetID() : -1, | 1663 process ? process->GetID() : -1, |
1666 &error_)) { | 1664 &error_)) { |
1667 return false; | 1665 return false; |
1668 } | 1666 } |
1669 | 1667 |
1670 return true; | 1668 return true; |
1671 } | 1669 } |
1672 | 1670 |
1673 ScriptExecutor* ExecuteCodeInTabFunction::GetScriptExecutor() { | 1671 ScriptExecutor* ExecuteCodeInTabFunction::GetScriptExecutor() { |
1674 Browser* browser = NULL; | 1672 Browser* browser = NULL; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1744 execute_tab_id_ = tab_id; | 1742 execute_tab_id_ = tab_id; |
1745 details_ = details.Pass(); | 1743 details_ = details.Pass(); |
1746 return true; | 1744 return true; |
1747 } | 1745 } |
1748 | 1746 |
1749 bool TabsInsertCSSFunction::ShouldInsertCSS() const { | 1747 bool TabsInsertCSSFunction::ShouldInsertCSS() const { |
1750 return true; | 1748 return true; |
1751 } | 1749 } |
1752 | 1750 |
1753 } // namespace extensions | 1751 } // namespace extensions |
OLD | NEW |