OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/webstore_inline_installer.h" | 5 #include "chrome/browser/extensions/webstore_inline_installer.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/extensions/crx_installer.h" | 13 #include "chrome/browser/extensions/crx_installer.h" |
14 #include "chrome/browser/extensions/extension_install_dialog.h" | 14 #include "chrome/browser/extensions/extension_install_dialog.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/browser_finder.h" | 17 #include "chrome/browser/ui/browser_finder.h" |
18 #include "chrome/common/chrome_utility_messages.h" | 18 #include "chrome/common/chrome_utility_messages.h" |
19 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
20 #include "chrome/common/extensions/extension_constants.h" | 20 #include "chrome/common/extensions/extension_constants.h" |
21 #include "chrome/common/extensions/url_pattern.h" | 21 #include "chrome/common/extensions/url_pattern.h" |
22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
23 #include "content/public/browser/utility_process_host.h" | 23 #include "content/public/browser/utility_process_host.h" |
24 #include "content/public/browser/utility_process_host_client.h" | 24 #include "content/public/browser/utility_process_host_client.h" |
25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
26 #include "content/public/common/url_fetcher.h" | |
27 #include "net/base/escape.h" | 26 #include "net/base/escape.h" |
28 #include "net/base/load_flags.h" | 27 #include "net/base/load_flags.h" |
| 28 #include "net/url_request/url_fetcher.h" |
29 #include "net/url_request/url_request_status.h" | 29 #include "net/url_request/url_request_status.h" |
30 | 30 |
31 using content::BrowserThread; | 31 using content::BrowserThread; |
32 using content::OpenURLParams; | 32 using content::OpenURLParams; |
33 using content::UtilityProcessHost; | 33 using content::UtilityProcessHost; |
34 using content::UtilityProcessHostClient; | 34 using content::UtilityProcessHostClient; |
35 using content::WebContents; | 35 using content::WebContents; |
36 | 36 |
37 const char kManifestKey[] = "manifest"; | 37 const char kManifestKey[] = "manifest"; |
38 const char kIconUrlKey[] = "icon_url"; | 38 const char kIconUrlKey[] = "icon_url"; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 void WebstoreInlineInstaller::BeginInstall() { | 164 void WebstoreInlineInstaller::BeginInstall() { |
165 AddRef(); // Balanced in CompleteInstall or WebContentsDestroyed. | 165 AddRef(); // Balanced in CompleteInstall or WebContentsDestroyed. |
166 | 166 |
167 if (!extensions::Extension::IdIsValid(id_)) { | 167 if (!extensions::Extension::IdIsValid(id_)) { |
168 CompleteInstall(kInvalidWebstoreItemId); | 168 CompleteInstall(kInvalidWebstoreItemId); |
169 return; | 169 return; |
170 } | 170 } |
171 | 171 |
172 GURL webstore_data_url(extension_urls::GetWebstoreItemJsonDataURL(id_)); | 172 GURL webstore_data_url(extension_urls::GetWebstoreItemJsonDataURL(id_)); |
173 | 173 |
174 webstore_data_url_fetcher_.reset(content::URLFetcher::Create( | 174 webstore_data_url_fetcher_.reset(net::URLFetcher::Create( |
175 webstore_data_url, net::URLFetcher::GET, this)); | 175 webstore_data_url, net::URLFetcher::GET, this)); |
176 Profile* profile = Profile::FromBrowserContext( | 176 Profile* profile = Profile::FromBrowserContext( |
177 web_contents()->GetBrowserContext()); | 177 web_contents()->GetBrowserContext()); |
178 webstore_data_url_fetcher_->SetRequestContext( | 178 webstore_data_url_fetcher_->SetRequestContext( |
179 profile->GetRequestContext()); | 179 profile->GetRequestContext()); |
180 // Use the requesting page as the referrer both since that is more correct | 180 // Use the requesting page as the referrer both since that is more correct |
181 // (it is the page that caused this request to happen) and so that we can | 181 // (it is the page that caused this request to happen) and so that we can |
182 // track top sites that trigger inline install requests. | 182 // track top sites that trigger inline install requests. |
183 webstore_data_url_fetcher_->SetReferrer(requestor_url_.spec()); | 183 webstore_data_url_fetcher_->SetReferrer(requestor_url_.spec()); |
184 webstore_data_url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 184 webstore_data_url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 verified_site_pattern.Parse(verified_site_url); | 448 verified_site_pattern.Parse(verified_site_url); |
449 if (parse_result != URLPattern::PARSE_SUCCESS) { | 449 if (parse_result != URLPattern::PARSE_SUCCESS) { |
450 DLOG(WARNING) << "Could not parse " << verified_site_url << | 450 DLOG(WARNING) << "Could not parse " << verified_site_url << |
451 " as URL pattern " << parse_result; | 451 " as URL pattern " << parse_result; |
452 return false; | 452 return false; |
453 } | 453 } |
454 verified_site_pattern.SetScheme("*"); | 454 verified_site_pattern.SetScheme("*"); |
455 | 455 |
456 return verified_site_pattern.MatchesURL(requestor_url); | 456 return verified_site_pattern.MatchesURL(requestor_url); |
457 } | 457 } |
OLD | NEW |