Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: chrome/browser/ui/browser.cc

Issue 11187058: Add flag to enable web content to invoke web intents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after
1649 const webkit_glue::WebIntentServiceData& data, 1649 const webkit_glue::WebIntentServiceData& data,
1650 bool user_gesture) { 1650 bool user_gesture) {
1651 RegisterIntentHandlerHelper(web_contents, data, user_gesture); 1651 RegisterIntentHandlerHelper(web_contents, data, user_gesture);
1652 } 1652 }
1653 1653
1654 void Browser::WebIntentDispatch( 1654 void Browser::WebIntentDispatch(
1655 WebContents* web_contents, 1655 WebContents* web_contents,
1656 content::WebIntentsDispatcher* intents_dispatcher) { 1656 content::WebIntentsDispatcher* intents_dispatcher) {
1657 if (!web_intents::IsWebIntentsEnabledForProfile(profile_)) { 1657 if (!web_intents::IsWebIntentsEnabledForProfile(profile_)) {
1658 web_intents::RecordIntentsDispatchDisabled(); 1658 web_intents::RecordIntentsDispatchDisabled();
1659 delete intents_dispatcher;
1659 return; 1660 return;
1660 } 1661 }
1661 1662
1663 // Make sure the requester is coming from an extension/app page.
1664 // Internal dispatches set |web_contents| to NULL.
1665 if (web_contents &&
1666 !CommandLine::ForCurrentProcess()->HasSwitch(
1667 switches::kWebIntentsEnabledForWebContent)) {
1668 ExtensionService* extensions_service = profile_->GetExtensionService();
1669 if (!extensions_service ||
1670 extensions_service->extensions()->GetExtensionOrAppIDByURL(
1671 ExtensionURLInfo(web_contents->GetURL())).empty()) {
1672 web_intents::RecordIntentsDispatchDisabled();
1673 intents_dispatcher->SendReplyMessage(
1674 webkit_glue::WEB_INTENT_REPLY_FAILURE,
1675 ASCIIToUTF16("Intents may only be invoked from extensions/apps."));
1676 return;
1677 }
1678 }
1679
1662 web_intents::RecordIntentDispatchRequested(); 1680 web_intents::RecordIntentDispatchRequested();
1663 1681
1664 if (!web_contents) { 1682 if (!web_contents) {
1665 // Intent is system-caused and the picker will show over the currently 1683 // Intent is system-caused and the picker will show over the currently
1666 // active web contents. 1684 // active web contents.
1667 web_contents = chrome::GetActiveWebContents(this); 1685 web_contents = chrome::GetActiveWebContents(this);
1668 } 1686 }
1669 WebIntentPickerController* web_intent_picker_controller = 1687 WebIntentPickerController* web_intent_picker_controller =
1670 WebIntentPickerController::FromWebContents(web_contents); 1688 WebIntentPickerController::FromWebContents(web_contents);
1671 web_intent_picker_controller->SetIntentsDispatcher(intents_dispatcher); 1689 web_intent_picker_controller->SetIntentsDispatcher(intents_dispatcher);
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
2313 if (contents && !allow_js_access) { 2331 if (contents && !allow_js_access) {
2314 contents->web_contents()->GetController().LoadURL( 2332 contents->web_contents()->GetController().LoadURL(
2315 target_url, 2333 target_url,
2316 content::Referrer(), 2334 content::Referrer(),
2317 content::PAGE_TRANSITION_LINK, 2335 content::PAGE_TRANSITION_LINK,
2318 std::string()); // No extra headers. 2336 std::string()); // No extra headers.
2319 } 2337 }
2320 2338
2321 return contents != NULL; 2339 return contents != NULL;
2322 } 2340 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698