Index: apps/url_redirector.h |
diff --git a/apps/url_redirector.h b/apps/url_redirector.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..084e8fe68c14defa22faad0436d665a82f9aeb02 |
--- /dev/null |
+++ b/apps/url_redirector.h |
@@ -0,0 +1,50 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef APPS_URL_REDIRECTOR_H_ |
+#define APPS_URL_REDIRECTOR_H_ |
+ |
+#include "content/public/browser/web_contents_observer.h" |
+#include "content/public/browser/web_contents_user_data.h" |
+ |
+class ExtensionSet; |
+class GURL; |
+class Profile; |
+ |
+namespace apps { |
+ |
+// This class observes a WebContent and handles IPCs related to redirecting URLs |
+// to apps (in particular related to the 'url_handlers' manifest key), launching |
+// a handling app for the requested URL. |
+// |
+// Also provides a static convenience wrapper to maybe find and launch |
+// a handler app for a given URL, if any. |
+class UrlRedirector : public content::WebContentsObserver, |
+ public content::WebContentsUserData<UrlRedirector> { |
+ public: |
+ virtual ~UrlRedirector(); |
+ |
+ // Looks for an app that's registered itself for handling a URL pattern |
+ // that matches |url|. If found, launches the app by issuing an onLaunched |
+ // event with |url| and |referrer_url| available through the launch data. |
benwells
2013/09/03 01:10:56
Tiny nit: document return value.
sergeygs
2013/09/03 06:15:24
Done.
|
+ static bool MaybeLaunchAppWithUrl(Profile* profile, |
+ const GURL& url, |
+ const GURL& referrer_url); |
+ |
+ private: |
+ explicit UrlRedirector(content::WebContents* web_contents); |
+ friend class content::WebContentsUserData<UrlRedirector>; |
+ |
+ // content::WebContentsObserver |
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
+ |
+ void LaunchAppWithUrl(const GURL& url, const GURL& referrer_url) const; |
+ |
+ // The normal profile associated with this ExtensionService. |
+ Profile* profile_; |
+}; |
+ |
+} // namespace apps |
+ |
+#endif // APPS_URL_REDIRECTOR_H_ |