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. | |
benwells
2013/09/03 01:10:56
Tiny nit: document return value.
sergeygs
2013/09/03 06:15:24
Done.
| |
31 static bool MaybeLaunchAppWithUrl(Profile* profile, | |
32 const GURL& url, | |
33 const GURL& referrer_url); | |
34 | |
35 private: | |
36 explicit UrlRedirector(content::WebContents* web_contents); | |
37 friend class content::WebContentsUserData<UrlRedirector>; | |
38 | |
39 // content::WebContentsObserver | |
40 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
41 | |
42 void LaunchAppWithUrl(const GURL& url, const GURL& referrer_url) const; | |
43 | |
44 // The normal profile associated with this ExtensionService. | |
45 Profile* profile_; | |
46 }; | |
47 | |
48 } // namespace apps | |
49 | |
50 #endif // APPS_URL_REDIRECTOR_H_ | |
OLD | NEW |