| 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/ephemeral_app_throttle.h" | 5 #include "chrome/browser/apps/ephemeral_app_throttle.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/extensions/extension_info_map.h" | 8 #include "chrome/browser/extensions/extension_info_map.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_system.h" | 10 #include "chrome/browser/extensions/extension_system.h" |
| 11 #include "chrome/browser/extensions/webstore_ephemeral_installer.h" | 11 #include "chrome/browser/extensions/webstore_ephemeral_installer.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/profiles/profile_io_data.h" | 13 #include "chrome/browser/profiles/profile_io_data.h" |
| 14 #include "chrome/browser/ui/extensions/application_launch.h" | 14 #include "chrome/browser/ui/extensions/application_launch.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/common/extensions/extension_constants.h" | |
| 17 #include "components/navigation_interception/intercept_navigation_resource_throt
tle.h" | 16 #include "components/navigation_interception/intercept_navigation_resource_throt
tle.h" |
| 18 #include "components/navigation_interception/navigation_params.h" | 17 #include "components/navigation_interception/navigation_params.h" |
| 19 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
| 21 #include "content/public/browser/resource_throttle.h" | 20 #include "content/public/browser/resource_throttle.h" |
| 22 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/browser/web_contents_view.h" | 22 #include "content/public/browser/web_contents_view.h" |
| 23 #include "extensions/common/extension_urls.h" |
| 24 #include "net/url_request/url_request.h" | 24 #include "net/url_request/url_request.h" |
| 25 | 25 |
| 26 using content::BrowserThread; | 26 using content::BrowserThread; |
| 27 using content::WebContents; | 27 using content::WebContents; |
| 28 using extensions::Extension; | 28 using extensions::Extension; |
| 29 using extensions::WebstoreEphemeralInstaller; | 29 using extensions::WebstoreEphemeralInstaller; |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 bool LaunchEphemeralApp( | 33 bool LaunchEphemeralApp( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 if (profile_io_data->is_incognito()) | 92 if (profile_io_data->is_incognito()) |
| 93 return NULL; | 93 return NULL; |
| 94 | 94 |
| 95 // Crudely watch for links to Chrome Web Store detail pages and assume that | 95 // Crudely watch for links to Chrome Web Store detail pages and assume that |
| 96 // the app ID will be after the last slash of the URL. We cannot even | 96 // the app ID will be after the last slash of the URL. We cannot even |
| 97 // differentiate between apps and extensions, so attempt to launch both. | 97 // differentiate between apps and extensions, so attempt to launch both. |
| 98 // This is obviously for experimental purposes only and will be implemented | 98 // This is obviously for experimental purposes only and will be implemented |
| 99 // properly in production code - for example, links to ephemeral apps could | 99 // properly in production code - for example, links to ephemeral apps could |
| 100 // have a new scheme. | 100 // have a new scheme. |
| 101 if (request->url().spec().find( | 101 if (request->url().spec().find( |
| 102 extension_urls::GetWebstoreItemDetailURLPrefix()) != 0) | 102 extensions::GetWebstoreItemDetailURLPrefix()) != 0) |
| 103 return NULL; | 103 return NULL; |
| 104 | 104 |
| 105 std::string app_id(request->url().ExtractFileName()); | 105 std::string app_id(request->url().ExtractFileName()); |
| 106 if (!Extension::IdIsValid(app_id)) | 106 if (!Extension::IdIsValid(app_id)) |
| 107 return NULL; | 107 return NULL; |
| 108 | 108 |
| 109 return new navigation_interception::InterceptNavigationResourceThrottle( | 109 return new navigation_interception::InterceptNavigationResourceThrottle( |
| 110 request, | 110 request, |
| 111 base::Bind(&LaunchEphemeralApp, app_id)); | 111 base::Bind(&LaunchEphemeralApp, app_id)); |
| 112 } | 112 } |
| OLD | NEW |