OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 } | 168 } |
169 | 169 |
170 GURL webstore_data_url(extension_urls::GetWebstoreItemJsonDataURL(id_)); | 170 GURL webstore_data_url(extension_urls::GetWebstoreItemJsonDataURL(id_)); |
171 | 171 |
172 webstore_data_url_fetcher_.reset(content::URLFetcher::Create( | 172 webstore_data_url_fetcher_.reset(content::URLFetcher::Create( |
173 webstore_data_url, content::URLFetcher::GET, this)); | 173 webstore_data_url, content::URLFetcher::GET, this)); |
174 Profile* profile = Profile::FromBrowserContext( | 174 Profile* profile = Profile::FromBrowserContext( |
175 tab_contents()->browser_context()); | 175 tab_contents()->browser_context()); |
176 webstore_data_url_fetcher_->SetRequestContext( | 176 webstore_data_url_fetcher_->SetRequestContext( |
177 profile->GetRequestContext()); | 177 profile->GetRequestContext()); |
| 178 // Use the requesting page as the referrer both since that is more correct |
| 179 // (it is the page that caused this request to happen) and so that we can |
| 180 // track top sites that trigger inline install requests. |
| 181 webstore_data_url_fetcher_->SetReferrer(requestor_url_.spec()); |
178 webstore_data_url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 182 webstore_data_url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
179 net::LOAD_DO_NOT_SAVE_COOKIES | | 183 net::LOAD_DO_NOT_SAVE_COOKIES | |
180 net::LOAD_DISABLE_CACHE); | 184 net::LOAD_DISABLE_CACHE); |
181 webstore_data_url_fetcher_->Start(); | 185 webstore_data_url_fetcher_->Start(); |
182 } | 186 } |
183 | 187 |
184 void WebstoreInlineInstaller::OnURLFetchComplete( | 188 void WebstoreInlineInstaller::OnURLFetchComplete( |
185 const content::URLFetcher* source) { | 189 const content::URLFetcher* source) { |
186 CHECK_EQ(webstore_data_url_fetcher_.get(), source); | 190 CHECK_EQ(webstore_data_url_fetcher_.get(), source); |
187 // We shouldn't be getting UrlFetcher callbacks if the TabContents has gone | 191 // We shouldn't be getting UrlFetcher callbacks if the TabContents has gone |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 if (tab_contents()) { | 426 if (tab_contents()) { |
423 if (error.empty()) { | 427 if (error.empty()) { |
424 delegate_->OnInlineInstallSuccess(install_id_); | 428 delegate_->OnInlineInstallSuccess(install_id_); |
425 } else { | 429 } else { |
426 delegate_->OnInlineInstallFailure(install_id_, error); | 430 delegate_->OnInlineInstallFailure(install_id_, error); |
427 } | 431 } |
428 } | 432 } |
429 | 433 |
430 Release(); // Matches the AddRef in BeginInstall. | 434 Release(); // Matches the AddRef in BeginInstall. |
431 } | 435 } |
OLD | NEW |