Index: chrome/browser/extensions/platform_app_redirector.h |
diff --git a/chrome/browser/extensions/platform_app_redirector.h b/chrome/browser/extensions/platform_app_redirector.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2e48ab8bf8f06f3c140cb67b9d91b5c85e4bdd61 |
--- /dev/null |
+++ b/chrome/browser/extensions/platform_app_redirector.h |
@@ -0,0 +1,63 @@ |
+// Copyright (c) 2012 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 CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_REDIRECTOR_H_ |
benwells
2013/08/30 05:41:39
This stuff should go in the src/apps component.
sergeygs
2013/09/02 07:36:22
Done.
|
+#define CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_REDIRECTOR_H_ |
+ |
+#include <string> |
+ |
+#include "base/compiler_specific.h" |
+#include "content/public/browser/notification_observer.h" |
+#include "content/public/browser/notification_registrar.h" |
+ |
+class ExtensionSet; |
+class GURL; |
+class Profile; |
+ |
+namespace content { |
+class NotificationDetails; |
+class NotificationSource; |
+} |
+ |
+namespace extensions { |
benwells
2013/08/30 05:41:39
This namespace should be apps.
sergeygs
2013/09/02 07:36:22
Done.
|
+ |
+// This class listens to notifications related to redirecting URLs to platform |
+// apps (in particular related to the 'url_handlers' manifest key), and launches |
+// a handling app for the requested URL. A handling app must exist before a |
+// notification is sent. |
+// |
+// Also provides a direct way of launching a possible handling app for a given |
+// URL (in that case, an app doesn't have to exist). |
+class PlatformAppRedirector : public content::NotificationObserver { |
+ public: |
+ explicit PlatformAppRedirector(Profile* profile); |
+ virtual ~PlatformAppRedirector(); |
+ |
+ // Looks for an app that's registered itself for handling a URL pattern |
+ // matching |url|. If found, launches the app by issuing an onLaunched event |
+ // to it, with |url| and |referrer_url| available through the launch data. |
+ bool MaybeLaunchPlatformAppWithUrl(const GURL& url, |
+ const GURL& referrer_url) const; |
+ |
+ private: |
+ // content::NotificationObserver |
+ // TODO(sergeygs): It could be nice if a content::DelegateXxx of some sort |
+ // could be used here instead of a notification. |
+ virtual void Observe(int type, |
+ const content::NotificationSource& source, |
+ const content::NotificationDetails& details) OVERRIDE; |
+ |
+ // The normal profile associated with this ExtensionService. |
benwells
2013/08/30 05:41:39
s/ExtensionService/PlatformAppRedirector/
sergeygs
2013/09/02 07:36:22
Done.
|
+ Profile* profile_; |
+ |
+ // Alias to the extension set in the ExtensionService associated with the |
+ // profile above. |
+ const ExtensionSet* extensions_; |
benwells
2013/08/30 05:41:39
Holding on to this pointer might work now but it m
not at google - send to devlin
2013/08/30 17:07:58
yeah, better make it a helper function e.g. extens
sergeygs
2013/09/02 07:36:22
Done.
|
+ |
+ content::NotificationRegistrar registrar_; |
+}; |
+ |
+} // namespace extensions |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_REDIRECTOR_H_ |