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