OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/apps/app_url_redirector.h" | 5 #include "chrome/browser/apps/app_url_redirector.h" |
6 | 6 |
7 #include "apps/launcher.h" | 7 #include "apps/launcher.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/browser/prerender/prerender_contents.h" | 10 #include "chrome/browser/prerender/prerender_contents.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // If prerendering, don't launch the app but abort the navigation. | 50 // If prerendering, don't launch the app but abort the navigation. |
51 prerender::PrerenderContents* prerender_contents = | 51 prerender::PrerenderContents* prerender_contents = |
52 prerender::PrerenderContents::FromWebContents(source); | 52 prerender::PrerenderContents::FromWebContents(source); |
53 if (prerender_contents) { | 53 if (prerender_contents) { |
54 prerender_contents->Destroy(prerender::FINAL_STATUS_NAVIGATION_INTERCEPTED); | 54 prerender_contents->Destroy(prerender::FINAL_STATUS_NAVIGATION_INTERCEPTED); |
55 return true; | 55 return true; |
56 } | 56 } |
57 | 57 |
58 // These are guaranteed by CreateThrottleFor below. | 58 // These are guaranteed by CreateThrottleFor below. |
59 DCHECK(!params.is_post()); | 59 DCHECK(!params.is_post()); |
60 DCHECK(UrlHandlers::CanExtensionHandleUrl(app, params.url())); | 60 DCHECK(UrlHandlers::CanExtensionHandleUrl(app.get(), params.url())); |
61 | 61 |
62 Profile* profile = | 62 Profile* profile = |
63 Profile::FromBrowserContext(source->GetBrowserContext()); | 63 Profile::FromBrowserContext(source->GetBrowserContext()); |
64 | 64 |
65 DVLOG(1) << "Launching app handler with URL: " | 65 DVLOG(1) << "Launching app handler with URL: " |
66 << params.url().spec() << " -> " | 66 << params.url().spec() << " -> " |
67 << app->name() << "(" << app->id() << "):" << handler_id; | 67 << app->name() << "(" << app->id() << "):" << handler_id; |
68 apps::LaunchPlatformAppWithUrl( | 68 apps::LaunchPlatformAppWithUrl( |
69 profile, app, handler_id, params.url(), params.referrer().url); | 69 profile, app.get(), handler_id, params.url(), params.referrer().url); |
70 | 70 |
71 return true; | 71 return true; |
72 } | 72 } |
73 | 73 |
74 } // namespace | 74 } // namespace |
75 | 75 |
76 // static | 76 // static |
77 content::ResourceThrottle* | 77 content::ResourceThrottle* |
78 AppUrlRedirector::MaybeCreateThrottleFor(net::URLRequest* request, | 78 AppUrlRedirector::MaybeCreateThrottleFor(net::URLRequest* request, |
79 ProfileIOData* profile_io_data) { | 79 ProfileIOData* profile_io_data) { |
(...skipping 25 matching lines...) Expand all Loading... |
105 DVLOG(1) << "Skip redirection: unsupported in incognito"; | 105 DVLOG(1) << "Skip redirection: unsupported in incognito"; |
106 return NULL; | 106 return NULL; |
107 } | 107 } |
108 | 108 |
109 const extensions::ExtensionSet& extensions = | 109 const extensions::ExtensionSet& extensions = |
110 profile_io_data->GetExtensionInfoMap()->extensions(); | 110 profile_io_data->GetExtensionInfoMap()->extensions(); |
111 for (extensions::ExtensionSet::const_iterator iter = extensions.begin(); | 111 for (extensions::ExtensionSet::const_iterator iter = extensions.begin(); |
112 iter != extensions.end(); | 112 iter != extensions.end(); |
113 ++iter) { | 113 ++iter) { |
114 const UrlHandlerInfo* handler = | 114 const UrlHandlerInfo* handler = |
115 UrlHandlers::FindMatchingUrlHandler(*iter, request->url()); | 115 UrlHandlers::FindMatchingUrlHandler(iter->get(), request->url()); |
116 if (handler) { | 116 if (handler) { |
117 DVLOG(1) << "Found matching app handler for redirection: " | 117 DVLOG(1) << "Found matching app handler for redirection: " |
118 << (*iter)->name() << "(" << (*iter)->id() << "):" | 118 << (*iter)->name() << "(" << (*iter)->id() << "):" |
119 << handler->id; | 119 << handler->id; |
120 return new navigation_interception::InterceptNavigationResourceThrottle( | 120 return new navigation_interception::InterceptNavigationResourceThrottle( |
121 request, | 121 request, |
122 base::Bind(&LaunchAppWithUrl, | 122 base::Bind(&LaunchAppWithUrl, |
123 scoped_refptr<const Extension>(*iter), | 123 scoped_refptr<const Extension>(*iter), |
124 handler->id)); | 124 handler->id)); |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 DVLOG(1) << "Skipping redirection: no matching app handler found"; | 128 DVLOG(1) << "Skipping redirection: no matching app handler found"; |
129 return NULL; | 129 return NULL; |
130 } | 130 } |
OLD | NEW |