| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/chromeos/login/screens/terms_of_service_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/terms_of_service_screen.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 122 |
| 123 void TermsOfServiceScreen::OnURLFetchComplete(const net::URLFetcher* source) { | 123 void TermsOfServiceScreen::OnURLFetchComplete(const net::URLFetcher* source) { |
| 124 if (source != terms_of_service_fetcher_.get()) { | 124 if (source != terms_of_service_fetcher_.get()) { |
| 125 NOTREACHED() << "Callback from foreign URL fetcher"; | 125 NOTREACHED() << "Callback from foreign URL fetcher"; |
| 126 return; | 126 return; |
| 127 } | 127 } |
| 128 | 128 |
| 129 download_timer_.Stop(); | 129 download_timer_.Stop(); |
| 130 | 130 |
| 131 // Destroy the fetcher when this method returns. | 131 // Destroy the fetcher when this method returns. |
| 132 scoped_ptr<net::URLFetcher> fetcher(std::move(terms_of_service_fetcher_)); | 132 std::unique_ptr<net::URLFetcher> fetcher( |
| 133 std::move(terms_of_service_fetcher_)); |
| 133 if (!actor_) | 134 if (!actor_) |
| 134 return; | 135 return; |
| 135 | 136 |
| 136 std::string terms_of_service; | 137 std::string terms_of_service; |
| 137 std::string mime_type; | 138 std::string mime_type; |
| 138 // If the Terms of Service could not be downloaded, do not have a MIME type of | 139 // If the Terms of Service could not be downloaded, do not have a MIME type of |
| 139 // text/plain or are empty, show an error message to the user. | 140 // text/plain or are empty, show an error message to the user. |
| 140 if (!source->GetStatus().is_success() || | 141 if (!source->GetStatus().is_success() || |
| 141 !source->GetResponseHeaders()->GetMimeType(&mime_type) || | 142 !source->GetResponseHeaders()->GetMimeType(&mime_type) || |
| 142 mime_type != "text/plain" || | 143 mime_type != "text/plain" || |
| 143 !source->GetResponseAsString(&terms_of_service)) { | 144 !source->GetResponseAsString(&terms_of_service)) { |
| 144 actor_->OnLoadError(); | 145 actor_->OnLoadError(); |
| 145 } else { | 146 } else { |
| 146 // If the Terms of Service were downloaded successfully, show them to the | 147 // If the Terms of Service were downloaded successfully, show them to the |
| 147 // user. | 148 // user. |
| 148 actor_->OnLoadSuccess(terms_of_service); | 149 actor_->OnLoadSuccess(terms_of_service); |
| 149 } | 150 } |
| 150 } | 151 } |
| 151 | 152 |
| 152 } // namespace chromeos | 153 } // namespace chromeos |
| OLD | NEW |