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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 CompleteInstall(kInvalidWebstoreItemId); | 164 CompleteInstall(kInvalidWebstoreItemId); |
165 return; | 165 return; |
166 } | 166 } |
167 | 167 |
168 GURL webstore_data_url(extension_urls::GetWebstoreItemJsonDataURL(id_)); | 168 GURL webstore_data_url(extension_urls::GetWebstoreItemJsonDataURL(id_)); |
169 | 169 |
170 webstore_data_url_fetcher_.reset( | 170 webstore_data_url_fetcher_.reset( |
171 new URLFetcher(webstore_data_url, URLFetcher::GET, this)); | 171 new URLFetcher(webstore_data_url, URLFetcher::GET, this)); |
172 Profile* profile = Profile::FromBrowserContext( | 172 Profile* profile = Profile::FromBrowserContext( |
173 tab_contents()->browser_context()); | 173 tab_contents()->browser_context()); |
174 webstore_data_url_fetcher_->set_request_context( | 174 webstore_data_url_fetcher_->SetRequestContext( |
175 profile->GetRequestContext()); | 175 profile->GetRequestContext()); |
176 webstore_data_url_fetcher_->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES | | 176 webstore_data_url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
177 net::LOAD_DO_NOT_SAVE_COOKIES | | 177 net::LOAD_DO_NOT_SAVE_COOKIES | |
178 net::LOAD_DISABLE_CACHE); | 178 net::LOAD_DISABLE_CACHE); |
179 webstore_data_url_fetcher_->Start(); | 179 webstore_data_url_fetcher_->Start(); |
180 } | 180 } |
181 | 181 |
182 void WebstoreInlineInstaller::OnURLFetchComplete(const URLFetcher* source) { | 182 void WebstoreInlineInstaller::OnURLFetchComplete( |
| 183 const content::URLFetcher* source) { |
183 CHECK_EQ(webstore_data_url_fetcher_.get(), source); | 184 CHECK_EQ(webstore_data_url_fetcher_.get(), source); |
184 // We shouldn't be getting UrlFetcher callbacks if the TabContents has gone | 185 // We shouldn't be getting UrlFetcher callbacks if the TabContents has gone |
185 // away; we stop any in in-progress fetches in TabContentsDestroyed. | 186 // away; we stop any in in-progress fetches in TabContentsDestroyed. |
186 CHECK(tab_contents()); | 187 CHECK(tab_contents()); |
187 | 188 |
188 if (!webstore_data_url_fetcher_->status().is_success() || | 189 if (!webstore_data_url_fetcher_->GetStatus().is_success() || |
189 webstore_data_url_fetcher_->response_code() != 200) { | 190 webstore_data_url_fetcher_->GetResponseCode() != 200) { |
190 CompleteInstall(kWebstoreRequestError); | 191 CompleteInstall(kWebstoreRequestError); |
191 return; | 192 return; |
192 } | 193 } |
193 | 194 |
194 std::string webstore_json_data; | 195 std::string webstore_json_data; |
195 webstore_data_url_fetcher_->GetResponseAsString(&webstore_json_data); | 196 webstore_data_url_fetcher_->GetResponseAsString(&webstore_json_data); |
196 webstore_data_url_fetcher_.reset(); | 197 webstore_data_url_fetcher_.reset(); |
197 | 198 |
198 scoped_refptr<SafeWebstoreResponseParser> parser = | 199 scoped_refptr<SafeWebstoreResponseParser> parser = |
199 new SafeWebstoreResponseParser(this, webstore_json_data); | 200 new SafeWebstoreResponseParser(this, webstore_json_data); |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 if (tab_contents()) { | 416 if (tab_contents()) { |
416 if (error.empty()) { | 417 if (error.empty()) { |
417 delegate_->OnInlineInstallSuccess(install_id_); | 418 delegate_->OnInlineInstallSuccess(install_id_); |
418 } else { | 419 } else { |
419 delegate_->OnInlineInstallFailure(install_id_, error); | 420 delegate_->OnInlineInstallFailure(install_id_, error); |
420 } | 421 } |
421 } | 422 } |
422 | 423 |
423 Release(); // Matches the AddRef in BeginInstall. | 424 Release(); // Matches the AddRef in BeginInstall. |
424 } | 425 } |
OLD | NEW |