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 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 } | 1166 } |
1167 | 1167 |
1168 // Don't let the extension crash the browser or renderers. | 1168 // Don't let the extension crash the browser or renderers. |
1169 if (ExtensionTabUtil::IsCrashURL(url)) { | 1169 if (ExtensionTabUtil::IsCrashURL(url)) { |
1170 error_ = keys::kNoCrashBrowserError; | 1170 error_ = keys::kNoCrashBrowserError; |
1171 return false; | 1171 return false; |
1172 } | 1172 } |
1173 | 1173 |
1174 // JavaScript URLs can do the same kinds of things as cross-origin XHR, so | 1174 // JavaScript URLs can do the same kinds of things as cross-origin XHR, so |
1175 // we need to check host permissions before allowing them. | 1175 // we need to check host permissions before allowing them. |
1176 if (url.SchemeIs(content::kJavaScriptScheme)) { | 1176 if (url.SchemeIs(url::kJavaScriptScheme)) { |
1177 content::RenderProcessHost* process = web_contents_->GetRenderProcessHost(); | 1177 content::RenderProcessHost* process = web_contents_->GetRenderProcessHost(); |
1178 if (!PermissionsData::CanExecuteScriptOnPage( | 1178 if (!PermissionsData::CanExecuteScriptOnPage( |
1179 GetExtension(), | 1179 GetExtension(), |
1180 web_contents_->GetURL(), | 1180 web_contents_->GetURL(), |
1181 web_contents_->GetURL(), | 1181 web_contents_->GetURL(), |
1182 tab_id, | 1182 tab_id, |
1183 NULL, | 1183 NULL, |
1184 process ? process->GetID() : -1, | 1184 process ? process->GetID() : -1, |
1185 &error_)) { | 1185 &error_)) { |
1186 return false; | 1186 return false; |
(...skipping 16 matching lines...) Expand all Loading... |
1203 | 1203 |
1204 *is_async = true; | 1204 *is_async = true; |
1205 return true; | 1205 return true; |
1206 } | 1206 } |
1207 | 1207 |
1208 web_contents_->GetController().LoadURL( | 1208 web_contents_->GetController().LoadURL( |
1209 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); | 1209 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); |
1210 | 1210 |
1211 // The URL of a tab contents never actually changes to a JavaScript URL, so | 1211 // The URL of a tab contents never actually changes to a JavaScript URL, so |
1212 // this check only makes sense in other cases. | 1212 // this check only makes sense in other cases. |
1213 if (!url.SchemeIs(content::kJavaScriptScheme)) | 1213 if (!url.SchemeIs(url::kJavaScriptScheme)) |
1214 DCHECK_EQ(url.spec(), web_contents_->GetURL().spec()); | 1214 DCHECK_EQ(url.spec(), web_contents_->GetURL().spec()); |
1215 | 1215 |
1216 return true; | 1216 return true; |
1217 } | 1217 } |
1218 | 1218 |
1219 void TabsUpdateFunction::PopulateResult() { | 1219 void TabsUpdateFunction::PopulateResult() { |
1220 if (!has_callback()) | 1220 if (!has_callback()) |
1221 return; | 1221 return; |
1222 | 1222 |
1223 SetResult(ExtensionTabUtil::CreateTabValue(web_contents_, GetExtension())); | 1223 SetResult(ExtensionTabUtil::CreateTabValue(web_contents_, GetExtension())); |
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1736 execute_tab_id_ = tab_id; | 1736 execute_tab_id_ = tab_id; |
1737 details_ = details.Pass(); | 1737 details_ = details.Pass(); |
1738 return true; | 1738 return true; |
1739 } | 1739 } |
1740 | 1740 |
1741 bool TabsInsertCSSFunction::ShouldInsertCSS() const { | 1741 bool TabsInsertCSSFunction::ShouldInsertCSS() const { |
1742 return true; | 1742 return true; |
1743 } | 1743 } |
1744 | 1744 |
1745 } // namespace extensions | 1745 } // namespace extensions |
OLD | NEW |