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 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 } | 1393 } |
1394 | 1394 |
1395 // Don't let the extension crash the browser or renderers. | 1395 // Don't let the extension crash the browser or renderers. |
1396 if (ExtensionTabUtil::IsCrashURL(url)) { | 1396 if (ExtensionTabUtil::IsCrashURL(url)) { |
1397 error_ = keys::kNoCrashBrowserError; | 1397 error_ = keys::kNoCrashBrowserError; |
1398 return false; | 1398 return false; |
1399 } | 1399 } |
1400 | 1400 |
1401 // JavaScript URLs can do the same kinds of things as cross-origin XHR, so | 1401 // JavaScript URLs can do the same kinds of things as cross-origin XHR, so |
1402 // we need to check host permissions before allowing them. | 1402 // we need to check host permissions before allowing them. |
1403 if (url.SchemeIs(chrome::kJavaScriptScheme)) { | 1403 if (url.SchemeIs(content::kJavaScriptScheme)) { |
1404 content::RenderProcessHost* process = web_contents_->GetRenderProcessHost(); | 1404 content::RenderProcessHost* process = web_contents_->GetRenderProcessHost(); |
1405 if (!PermissionsData::CanExecuteScriptOnPage( | 1405 if (!PermissionsData::CanExecuteScriptOnPage( |
1406 GetExtension(), | 1406 GetExtension(), |
1407 web_contents_->GetURL(), | 1407 web_contents_->GetURL(), |
1408 web_contents_->GetURL(), | 1408 web_contents_->GetURL(), |
1409 tab_id, | 1409 tab_id, |
1410 NULL, | 1410 NULL, |
1411 process ? process->GetID() : -1, | 1411 process ? process->GetID() : -1, |
1412 &error_)) { | 1412 &error_)) { |
1413 return false; | 1413 return false; |
(...skipping 12 matching lines...) Expand all Loading... |
1426 | 1426 |
1427 *is_async = true; | 1427 *is_async = true; |
1428 return true; | 1428 return true; |
1429 } | 1429 } |
1430 | 1430 |
1431 web_contents_->GetController().LoadURL( | 1431 web_contents_->GetController().LoadURL( |
1432 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); | 1432 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); |
1433 | 1433 |
1434 // The URL of a tab contents never actually changes to a JavaScript URL, so | 1434 // The URL of a tab contents never actually changes to a JavaScript URL, so |
1435 // this check only makes sense in other cases. | 1435 // this check only makes sense in other cases. |
1436 if (!url.SchemeIs(chrome::kJavaScriptScheme)) | 1436 if (!url.SchemeIs(content::kJavaScriptScheme)) |
1437 DCHECK_EQ(url.spec(), web_contents_->GetURL().spec()); | 1437 DCHECK_EQ(url.spec(), web_contents_->GetURL().spec()); |
1438 | 1438 |
1439 return true; | 1439 return true; |
1440 } | 1440 } |
1441 | 1441 |
1442 void TabsUpdateFunction::PopulateResult() { | 1442 void TabsUpdateFunction::PopulateResult() { |
1443 if (!has_callback()) | 1443 if (!has_callback()) |
1444 return; | 1444 return; |
1445 | 1445 |
1446 SetResult(ExtensionTabUtil::CreateTabValue(web_contents_, GetExtension())); | 1446 SetResult(ExtensionTabUtil::CreateTabValue(web_contents_, GetExtension())); |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 execute_tab_id_ = tab_id; | 2065 execute_tab_id_ = tab_id; |
2066 details_ = details.Pass(); | 2066 details_ = details.Pass(); |
2067 return true; | 2067 return true; |
2068 } | 2068 } |
2069 | 2069 |
2070 bool TabsInsertCSSFunction::ShouldInsertCSS() const { | 2070 bool TabsInsertCSSFunction::ShouldInsertCSS() const { |
2071 return true; | 2071 return true; |
2072 } | 2072 } |
2073 | 2073 |
2074 } // namespace extensions | 2074 } // namespace extensions |
OLD | NEW |