OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef APPS_URL_REDIRECTOR_H_ |
| 6 #define APPS_URL_REDIRECTOR_H_ |
| 7 |
| 8 #include "content/public/browser/web_contents_observer.h" |
| 9 #include "content/public/browser/web_contents_user_data.h" |
| 10 |
| 11 class ExtensionSet; |
| 12 class GURL; |
| 13 class Profile; |
| 14 |
| 15 namespace apps { |
| 16 |
| 17 // This class observes a WebContent and handles IPCs related to redirecting URLs |
| 18 // to apps (in particular related to the 'url_handlers' manifest key), launching |
| 19 // a handling app for the requested URL. |
| 20 // |
| 21 // Also provides a static convenience wrapper to maybe find and launch |
| 22 // a handler app for a given URL, if any. |
| 23 class UrlRedirector : public content::WebContentsObserver, |
| 24 public content::WebContentsUserData<UrlRedirector> { |
| 25 public: |
| 26 virtual ~UrlRedirector(); |
| 27 |
| 28 // Looks for an app that's registered itself for handling a URL pattern |
| 29 // that matches |url|. If found, launches the app by issuing an onLaunched |
| 30 // event with |url| and |referrer_url| available through the launch data, |
| 31 // and returns true. Otherwise, returns false. |
| 32 static bool MaybeLaunchAppWithUrl(Profile* profile, |
| 33 const GURL& url, |
| 34 const GURL& referrer_url); |
| 35 |
| 36 private: |
| 37 explicit UrlRedirector(content::WebContents* web_contents); |
| 38 friend class content::WebContentsUserData<UrlRedirector>; |
| 39 |
| 40 // content::WebContentsObserver |
| 41 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 42 |
| 43 void LaunchAppWithUrl(const GURL& url, const GURL& referrer_url) const; |
| 44 |
| 45 // The normal profile associated with this ExtensionService. |
| 46 Profile* profile_; |
| 47 }; |
| 48 |
| 49 } // namespace apps |
| 50 |
| 51 #endif // APPS_URL_REDIRECTOR_H_ |
OLD | NEW |