Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1160)

Side by Side Diff: chrome/browser/chromeos/customization_document.cc

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and remove unncessary forward declares Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/chromeos/customization_document.h" 5 #include "chrome/browser/chromeos/customization_document.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/string_tokenizer.h" 11 #include "base/string_tokenizer.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chromeos/cros/cros_library.h" 16 #include "chrome/browser/chromeos/cros/cros_library.h"
17 #include "chrome/browser/chromeos/cros/network_library.h" 17 #include "chrome/browser/chromeos/cros/network_library.h"
18 #include "chrome/browser/chromeos/login/wizard_controller.h" 18 #include "chrome/browser/chromeos/login/wizard_controller.h"
19 #include "chrome/browser/chromeos/system/statistics_provider.h" 19 #include "chrome/browser/chromeos/system/statistics_provider.h"
20 #include "chrome/browser/prefs/pref_service.h" 20 #include "chrome/browser/prefs/pref_service.h"
21 #include "chrome/browser/profiles/profile_manager.h" 21 #include "chrome/browser/profiles/profile_manager.h"
22 #include "content/browser/browser_thread.h" 22 #include "content/browser/browser_thread.h"
23 #include "content/common/net/url_fetcher.h"
23 24
24 // Manifest attributes names. 25 // Manifest attributes names.
25 26
26 namespace { 27 namespace {
27 28
28 const char kVersionAttr[] = "version"; 29 const char kVersionAttr[] = "version";
29 const char kDefaultAttr[] = "default"; 30 const char kDefaultAttr[] = "default";
30 const char kInitialLocaleAttr[] = "initial_locale"; 31 const char kInitialLocaleAttr[] = "initial_locale";
31 const char kInitialTimezoneAttr[] = "initial_timezone"; 32 const char kInitialTimezoneAttr[] = "initial_timezone";
32 const char kKeyboardLayoutAttr[] = "keyboard_layout"; 33 const char kKeyboardLayoutAttr[] = "keyboard_layout";
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 294
294 void ServicesCustomizationDocument::StartFileFetch() { 295 void ServicesCustomizationDocument::StartFileFetch() {
295 DCHECK(url_.is_valid()); 296 DCHECK(url_.is_valid());
296 url_fetcher_.reset(new URLFetcher(url_, URLFetcher::GET, this)); 297 url_fetcher_.reset(new URLFetcher(url_, URLFetcher::GET, this));
297 url_fetcher_->set_request_context( 298 url_fetcher_->set_request_context(
298 ProfileManager::GetDefaultProfile()->GetRequestContext()); 299 ProfileManager::GetDefaultProfile()->GetRequestContext());
299 url_fetcher_->Start(); 300 url_fetcher_->Start();
300 } 301 }
301 302
302 void ServicesCustomizationDocument::OnURLFetchComplete( 303 void ServicesCustomizationDocument::OnURLFetchComplete(
303 const URLFetcher* source, 304 const URLFetcher* source) {
304 const GURL& url, 305 if (source->response_code() == 200) {
305 const net::URLRequestStatus& status, 306 std::string data;
306 int response_code, 307 source->GetResponseAsString(&data);
307 const net::ResponseCookies& cookies,
308 const std::string& data) {
309 if (response_code == 200) {
310 LoadManifestFromString(data); 308 LoadManifestFromString(data);
311 } else { 309 } else {
312 NetworkLibrary* network = CrosLibrary::Get()->GetNetworkLibrary(); 310 NetworkLibrary* network = CrosLibrary::Get()->GetNetworkLibrary();
313 if (!network->Connected() && num_retries_ < kMaxFetchRetries) { 311 if (!network->Connected() && num_retries_ < kMaxFetchRetries) {
314 num_retries_++; 312 num_retries_++;
315 retry_timer_.Start(FROM_HERE, 313 retry_timer_.Start(FROM_HERE,
316 base::TimeDelta::FromSeconds(kRetriesDelayInSec), 314 base::TimeDelta::FromSeconds(kRetriesDelayInSec),
317 this, &ServicesCustomizationDocument::StartFileFetch); 315 this, &ServicesCustomizationDocument::StartFileFetch);
318 return; 316 return;
319 } 317 }
320 LOG(ERROR) << "URL fetch for services customization failed:" 318 LOG(ERROR) << "URL fetch for services customization failed:"
321 << " response code = " << response_code 319 << " response code = " << source->response_code()
322 << " URL = " << url.spec(); 320 << " URL = " << source->url().spec();
323 } 321 }
324 } 322 }
325 323
326 bool ServicesCustomizationDocument::ApplyCustomization() { 324 bool ServicesCustomizationDocument::ApplyCustomization() {
327 // TODO(dpolukhin): apply customized apps, exts and support page. 325 // TODO(dpolukhin): apply customized apps, exts and support page.
328 SetApplied(true); 326 SetApplied(true);
329 return true; 327 return true;
330 } 328 }
331 329
332 std::string ServicesCustomizationDocument::GetInitialStartPage( 330 std::string ServicesCustomizationDocument::GetInitialStartPage(
333 const std::string& locale) const { 331 const std::string& locale) const {
334 return GetLocaleSpecificString( 332 return GetLocaleSpecificString(
335 locale, kAppContentAttr, kInitialStartPageAttr); 333 locale, kAppContentAttr, kInitialStartPageAttr);
336 } 334 }
337 335
338 std::string ServicesCustomizationDocument::GetSupportPage( 336 std::string ServicesCustomizationDocument::GetSupportPage(
339 const std::string& locale) const { 337 const std::string& locale) const {
340 return GetLocaleSpecificString( 338 return GetLocaleSpecificString(
341 locale, kAppContentAttr, kSupportPageAttr); 339 locale, kAppContentAttr, kSupportPageAttr);
342 } 340 }
343 341
344 } // namespace chromeos 342 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698