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

Unified Diff: apps/url_redirector.h

Issue 23847004: "Redirecting URLs to Packaged Apps" implementation: revised (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comment in app_window_contents.cc Created 7 years, 3 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
Index: apps/url_redirector.h
diff --git a/apps/url_redirector.h b/apps/url_redirector.h
new file mode 100644
index 0000000000000000000000000000000000000000..d264b94d3fd5390a39dc7599a4dababe66652f6e
--- /dev/null
+++ b/apps/url_redirector.h
@@ -0,0 +1,51 @@
+// 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,
+ // and returns true. Otherwise, returns false.
+ 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_
« no previous file with comments | « apps/launcher.cc ('k') | apps/url_redirector.cc » ('j') | apps/url_redirector.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698