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 <stddef.h> | 7 #include <stddef.h> |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <limits> | 9 #include <limits> |
10 #include <memory> | 10 #include <memory> |
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 ScriptExecutor::SINGLE_FRAME, ExtensionApiFrameIdMap::kTopFrameId, | 1313 ScriptExecutor::SINGLE_FRAME, ExtensionApiFrameIdMap::kTopFrameId, |
1314 ScriptExecutor::DONT_MATCH_ABOUT_BLANK, UserScript::DOCUMENT_IDLE, | 1314 ScriptExecutor::DONT_MATCH_ABOUT_BLANK, UserScript::DOCUMENT_IDLE, |
1315 ScriptExecutor::MAIN_WORLD, ScriptExecutor::DEFAULT_PROCESS, GURL(), | 1315 ScriptExecutor::MAIN_WORLD, ScriptExecutor::DEFAULT_PROCESS, GURL(), |
1316 GURL(), user_gesture(), ScriptExecutor::NO_RESULT, | 1316 GURL(), user_gesture(), ScriptExecutor::NO_RESULT, |
1317 base::Bind(&TabsUpdateFunction::OnExecuteCodeFinished, this)); | 1317 base::Bind(&TabsUpdateFunction::OnExecuteCodeFinished, this)); |
1318 | 1318 |
1319 *is_async = true; | 1319 *is_async = true; |
1320 return true; | 1320 return true; |
1321 } | 1321 } |
1322 | 1322 |
1323 web_contents_->GetController().LoadURL( | 1323 // Load the URL, but treat it as renderer-initiated so that it does not show |
1324 url, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); | 1324 // in the omnibox until it commits. This avoids URL spoofs when the tabs API |
| 1325 // is used on behalf of untrusted content. |
| 1326 NavigationController::LoadURLParams load_params(url); |
| 1327 load_params.is_renderer_initiated = true; |
| 1328 web_contents_->GetController().LoadURLWithParams(load_params); |
1325 | 1329 |
1326 // The URL of a tab contents never actually changes to a JavaScript URL, so | 1330 // The URL of a tab contents never actually changes to a JavaScript URL, so |
1327 // this check only makes sense in other cases. | 1331 // this check only makes sense in other cases. |
1328 if (!url.SchemeIs(url::kJavaScriptScheme)) | 1332 if (!url.SchemeIs(url::kJavaScriptScheme)) { |
1329 DCHECK_EQ(url.spec(), web_contents_->GetURL().spec()); | 1333 // The URL should be present in the pending entry, though it won't be |
| 1334 // visible in the omnibox until it commits. |
| 1335 DCHECK_EQ( |
| 1336 url, web_contents_->GetController().GetPendingEntry()->GetVirtualURL()); |
| 1337 } |
1330 | 1338 |
1331 return true; | 1339 return true; |
1332 } | 1340 } |
1333 | 1341 |
1334 void TabsUpdateFunction::PopulateResult() { | 1342 void TabsUpdateFunction::PopulateResult() { |
1335 if (!has_callback()) | 1343 if (!has_callback()) |
1336 return; | 1344 return; |
1337 | 1345 |
1338 results_ = tabs::Get::Results::Create( | 1346 results_ = tabs::Get::Results::Create( |
1339 *ExtensionTabUtil::CreateTabObject(web_contents_, extension())); | 1347 *ExtensionTabUtil::CreateTabObject(web_contents_, extension())); |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2092 params->tab_id | 2100 params->tab_id |
2093 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, | 2101 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, |
2094 base::IntToString(*params->tab_id)) | 2102 base::IntToString(*params->tab_id)) |
2095 : keys::kCannotFindTabToDiscard)); | 2103 : keys::kCannotFindTabToDiscard)); |
2096 } | 2104 } |
2097 | 2105 |
2098 TabsDiscardFunction::TabsDiscardFunction() {} | 2106 TabsDiscardFunction::TabsDiscardFunction() {} |
2099 TabsDiscardFunction::~TabsDiscardFunction() {} | 2107 TabsDiscardFunction::~TabsDiscardFunction() {} |
2100 | 2108 |
2101 } // namespace extensions | 2109 } // namespace extensions |
OLD | NEW |