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

Unified Diff: chrome/browser/apps/app_url_redirector.h

Issue 23847004: "Redirecting URLs to Packaged Apps" implementation: revised (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed an editing error 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: chrome/browser/apps/app_url_redirector.h
diff --git a/chrome/browser/apps/app_url_redirector.h b/chrome/browser/apps/app_url_redirector.h
new file mode 100644
index 0000000000000000000000000000000000000000..28b85864eb2944027f6280c3b8aa2974c970e315
--- /dev/null
+++ b/chrome/browser/apps/app_url_redirector.h
@@ -0,0 +1,47 @@
+// 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 CHROME_BROWSER_APPS_APP_URL_REDIRECTOR_H_
+#define CHROME_BROWSER_APPS_APP_URL_REDIRECTOR_H_
+
+#include "content/public/browser/web_contents_observer.h"
+#include "content/public/browser/web_contents_user_data.h"
+
+class ExtensionSet;
benwells 2013/09/04 23:54:20 Nit: forward decl. not used any more.
sergeygs 2013/09/05 09:19:03 Obsolete.
+class GURL;
+class Profile;
+
+// 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 AppUrlRedirector : public content::WebContentsObserver,
+ public content::WebContentsUserData<AppUrlRedirector> {
+ public:
+ virtual ~AppUrlRedirector();
+
+ // 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 AppUrlRedirector(content::WebContents* web_contents);
+ friend class content::WebContentsUserData<AppUrlRedirector>;
+
+ // 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.
benwells 2013/09/04 23:54:20 Nit: s/ExtensionService/AppUrlRedirectory/
sergeygs 2013/09/05 09:19:03 Obsolete.
+ Profile* profile_;
+};
+
+#endif // CHROME_BROWSER_APPS_APP_URL_REDIRECTOR_H_

Powered by Google App Engine
This is Rietveld 408576698