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 bool use_renderer_initiated = false; |
1324 url, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); | 1324 // For the PDF extension, treat it as renderer-initiated so that it does not |
| 1325 // show in the omnibox until it commits. This avoids URL spoofs since urls |
| 1326 // can be opened on behalf of untrusted content. |
| 1327 // TODO(devlin|nasko): Make this the default for all extensions. |
| 1328 if (extension() && extension()->id() == extension_misc::kPdfExtensionId) |
| 1329 use_renderer_initiated = true; |
| 1330 NavigationController::LoadURLParams load_params(url); |
| 1331 load_params.is_renderer_initiated = use_renderer_initiated; |
| 1332 web_contents_->GetController().LoadURLWithParams(load_params); |
1325 | 1333 |
1326 // The URL of a tab contents never actually changes to a JavaScript URL, so | 1334 // The URL of a tab contents never actually changes to a JavaScript URL, so |
1327 // this check only makes sense in other cases. | 1335 // this check only makes sense in other cases. |
1328 if (!url.SchemeIs(url::kJavaScriptScheme)) | 1336 if (!url.SchemeIs(url::kJavaScriptScheme)) { |
1329 DCHECK_EQ(url.spec(), web_contents_->GetURL().spec()); | 1337 // The URL should be present in the pending entry, though it may not be |
| 1338 // visible in the omnibox until it commits. |
| 1339 DCHECK_EQ( |
| 1340 url, web_contents_->GetController().GetPendingEntry()->GetVirtualURL()); |
| 1341 } |
1330 | 1342 |
1331 return true; | 1343 return true; |
1332 } | 1344 } |
1333 | 1345 |
1334 void TabsUpdateFunction::PopulateResult() { | 1346 void TabsUpdateFunction::PopulateResult() { |
1335 if (!has_callback()) | 1347 if (!has_callback()) |
1336 return; | 1348 return; |
1337 | 1349 |
1338 results_ = tabs::Get::Results::Create( | 1350 results_ = tabs::Get::Results::Create( |
1339 *ExtensionTabUtil::CreateTabObject(web_contents_, extension())); | 1351 *ExtensionTabUtil::CreateTabObject(web_contents_, extension())); |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2092 params->tab_id | 2104 params->tab_id |
2093 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, | 2105 ? ErrorUtils::FormatErrorMessage(keys::kCannotDiscardTab, |
2094 base::IntToString(*params->tab_id)) | 2106 base::IntToString(*params->tab_id)) |
2095 : keys::kCannotFindTabToDiscard)); | 2107 : keys::kCannotFindTabToDiscard)); |
2096 } | 2108 } |
2097 | 2109 |
2098 TabsDiscardFunction::TabsDiscardFunction() {} | 2110 TabsDiscardFunction::TabsDiscardFunction() {} |
2099 TabsDiscardFunction::~TabsDiscardFunction() {} | 2111 TabsDiscardFunction::~TabsDiscardFunction() {} |
2100 | 2112 |
2101 } // namespace extensions | 2113 } // namespace extensions |
OLD | NEW |