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

Unified Diff: chrome/browser/extensions/extension_host.cc

Issue 10830102: [Web Intents] Add ability to dispatch intents from extension-caused code (i.e. context menus) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ifdef out impl for android Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_host.h ('k') | chrome/browser/intents/web_intents_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_host.cc
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index 4136689fc4d3ba4fee3dee8cf8126c860c06fbe5..8fd4756ee6a7e047d246fd8f32e3dc7b0a8b080d 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -45,6 +45,7 @@
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
+#include "content/public/browser/web_intents_dispatcher.h"
#include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -418,6 +419,28 @@ void ExtensionHost::OnStartDownload(
OnStartDownload(source, download);
}
+void ExtensionHost::WebIntentDispatch(
+ content::WebContents* web_contents,
+ content::WebIntentsDispatcher* intents_dispatcher) {
+#if !defined(OS_ANDROID)
+ scoped_ptr<content::WebIntentsDispatcher> dispatcher(intents_dispatcher);
+
+ Browser* browser = view() ? view()->browser()
+ : browser::FindBrowserWithWebContents(web_contents);
+
+ // For background scripts/pages, there will be no view(). In this case, we
+ // want to treat the intent as a browser-initiated one and deliver it into the
+ // current browser. It probably came from a context menu click or similar.
+ if (!browser)
+ browser = web_intents::GetBrowserForBackgroundWebIntentDelivery(profile());
+
+ if (browser) {
+ static_cast<WebContentsDelegate*>(browser)->
+ WebIntentDispatch(NULL, dispatcher.release());
+ }
+#endif
+}
+
void ExtensionHost::WillRunJavaScriptDialog() {
ExtensionProcessManager* pm =
ExtensionSystem::Get(profile_)->process_manager();
« no previous file with comments | « chrome/browser/extensions/extension_host.h ('k') | chrome/browser/intents/web_intents_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698