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