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/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1646 const webkit_glue::WebIntentServiceData& data, | 1646 const webkit_glue::WebIntentServiceData& data, |
1647 bool user_gesture) { | 1647 bool user_gesture) { |
1648 RegisterIntentHandlerHelper(web_contents, data, user_gesture); | 1648 RegisterIntentHandlerHelper(web_contents, data, user_gesture); |
1649 } | 1649 } |
1650 | 1650 |
1651 void Browser::WebIntentDispatch( | 1651 void Browser::WebIntentDispatch( |
1652 WebContents* web_contents, | 1652 WebContents* web_contents, |
1653 content::WebIntentsDispatcher* intents_dispatcher) { | 1653 content::WebIntentsDispatcher* intents_dispatcher) { |
1654 if (!web_intents::IsWebIntentsEnabledForProfile(profile_)) { | 1654 if (!web_intents::IsWebIntentsEnabledForProfile(profile_)) { |
1655 web_intents::RecordIntentsDispatchDisabled(); | 1655 web_intents::RecordIntentsDispatchDisabled(); |
| 1656 delete intents_dispatcher; |
1656 return; | 1657 return; |
1657 } | 1658 } |
1658 | 1659 |
| 1660 // Make sure the requester is coming from an extension/app page. |
| 1661 // Internal dispatches set |web_contents| to NULL. |
| 1662 #if !defined(OS_CHROMEOS) |
| 1663 if (web_contents && |
| 1664 !CommandLine::ForCurrentProcess()->HasSwitch( |
| 1665 switches::kWebIntentsInvocationEnabled)) { |
| 1666 ExtensionService* extensions_service = profile_->GetExtensionService(); |
| 1667 if (!extensions_service || |
| 1668 extensions_service->extensions()->GetExtensionOrAppByURL( |
| 1669 ExtensionURLInfo(web_contents->GetURL())) == NULL) { |
| 1670 web_intents::RecordIntentsDispatchDisabled(); |
| 1671 intents_dispatcher->SendReplyMessage( |
| 1672 webkit_glue::WEB_INTENT_REPLY_FAILURE, |
| 1673 ASCIIToUTF16("Intents may only be invoked from extensions/apps.")); |
| 1674 return; |
| 1675 } |
| 1676 } |
| 1677 #endif |
| 1678 |
1659 web_intents::RecordIntentDispatchRequested(); | 1679 web_intents::RecordIntentDispatchRequested(); |
1660 | 1680 |
1661 if (!web_contents) { | 1681 if (!web_contents) { |
1662 // Intent is system-caused and the picker will show over the currently | 1682 // Intent is system-caused and the picker will show over the currently |
1663 // active web contents. | 1683 // active web contents. |
1664 web_contents = chrome::GetActiveWebContents(this); | 1684 web_contents = chrome::GetActiveWebContents(this); |
1665 } | 1685 } |
1666 WebIntentPickerController* web_intent_picker_controller = | 1686 WebIntentPickerController* web_intent_picker_controller = |
1667 WebIntentPickerController::FromWebContents(web_contents); | 1687 WebIntentPickerController::FromWebContents(web_contents); |
1668 web_intent_picker_controller->SetIntentsDispatcher(intents_dispatcher); | 1688 web_intent_picker_controller->SetIntentsDispatcher(intents_dispatcher); |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2310 if (contents && !allow_js_access) { | 2330 if (contents && !allow_js_access) { |
2311 contents->web_contents()->GetController().LoadURL( | 2331 contents->web_contents()->GetController().LoadURL( |
2312 target_url, | 2332 target_url, |
2313 content::Referrer(), | 2333 content::Referrer(), |
2314 content::PAGE_TRANSITION_LINK, | 2334 content::PAGE_TRANSITION_LINK, |
2315 std::string()); // No extra headers. | 2335 std::string()); // No extra headers. |
2316 } | 2336 } |
2317 | 2337 |
2318 return contents != NULL; | 2338 return contents != NULL; |
2319 } | 2339 } |
OLD | NEW |