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/renderer_host/chrome_resource_dispatcher_host_delegate.
h" | 5 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/prerender/prerender_tracker.h" | 23 #include "chrome/browser/prerender/prerender_tracker.h" |
24 #include "chrome/browser/profiles/profile_io_data.h" | 24 #include "chrome/browser/profiles/profile_io_data.h" |
25 #include "chrome/browser/renderer_host/chrome_url_request_user_data.h" | 25 #include "chrome/browser/renderer_host/chrome_url_request_user_data.h" |
26 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h" | 26 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle.h" |
27 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 27 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
28 #include "chrome/browser/ui/auto_login_prompter.h" | 28 #include "chrome/browser/ui/auto_login_prompter.h" |
29 #include "chrome/browser/ui/login/login_prompt.h" | 29 #include "chrome/browser/ui/login/login_prompt.h" |
30 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 30 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
31 #include "chrome/common/chrome_notification_types.h" | 31 #include "chrome/common/chrome_notification_types.h" |
32 #include "chrome/common/extensions/user_script.h" | 32 #include "chrome/common/extensions/user_script.h" |
33 #include "chrome/common/metrics/experiments_helper.h" | 33 #include "chrome/common/metrics/variations_util.h" |
34 #include "chrome/common/metrics/proto/chrome_experiments.pb.h" | 34 #include "chrome/common/metrics/proto/chrome_experiments.pb.h" |
35 #include "chrome/common/render_messages.h" | 35 #include "chrome/common/render_messages.h" |
36 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
37 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
38 #include "content/public/browser/render_view_host.h" | 38 #include "content/public/browser/render_view_host.h" |
39 #include "content/public/browser/resource_context.h" | 39 #include "content/public/browser/resource_context.h" |
40 #include "content/public/browser/resource_dispatcher_host.h" | 40 #include "content/public/browser/resource_dispatcher_host.h" |
41 #include "content/public/browser/resource_request_info.h" | 41 #include "content/public/browser/resource_request_info.h" |
42 #include "net/base/load_flags.h" | 42 #include "net/base/load_flags.h" |
43 #include "net/base/ssl_config_service.h" | 43 #include "net/base/ssl_config_service.h" |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 io_data->resource_prefetch_predictor_observer()->OnRequestRedirected( | 382 io_data->resource_prefetch_predictor_observer()->OnRequestRedirected( |
383 redirect_url, request); | 383 redirect_url, request); |
384 } | 384 } |
385 } | 385 } |
386 | 386 |
387 void ChromeResourceDispatcherHostDelegate::OnFieldTrialGroupFinalized( | 387 void ChromeResourceDispatcherHostDelegate::OnFieldTrialGroupFinalized( |
388 const std::string& trial_name, | 388 const std::string& trial_name, |
389 const std::string& group_name) { | 389 const std::string& group_name) { |
390 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 390 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
391 chrome_variations::VariationID new_id = | 391 chrome_variations::VariationID new_id = |
392 experiments_helper::GetGoogleVariationID(trial_name, group_name); | 392 chrome_variations::GetGoogleVariationID(trial_name, group_name); |
393 if (new_id == chrome_variations::kEmptyID) | 393 if (new_id == chrome_variations::kEmptyID) |
394 return; | 394 return; |
395 variation_ids_set_.insert(new_id); | 395 variation_ids_set_.insert(new_id); |
396 UpdateVariationIDsHeaderValue(); | 396 UpdateVariationIDsHeaderValue(); |
397 } | 397 } |
398 | 398 |
399 void ChromeResourceDispatcherHostDelegate::InitVariationIDsCacheIfNeeded() { | 399 void ChromeResourceDispatcherHostDelegate::InitVariationIDsCacheIfNeeded() { |
400 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 400 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
401 if (variation_ids_cache_initialized_) | 401 if (variation_ids_cache_initialized_) |
402 return; | 402 return; |
403 | 403 |
404 // Register for additional cache updates. We do this first to avoid a race | 404 // Register for additional cache updates. We do this first to avoid a race |
405 // that could cause us to miss registered FieldTrials. | 405 // that could cause us to miss registered FieldTrials. |
406 base::FieldTrialList::AddObserver(this); | 406 base::FieldTrialList::AddObserver(this); |
407 | 407 |
408 base::FieldTrial::SelectedGroups initial_groups; | 408 base::FieldTrial::SelectedGroups initial_groups; |
409 base::FieldTrialList::GetFieldTrialSelectedGroups(&initial_groups); | 409 base::FieldTrialList::GetFieldTrialSelectedGroups(&initial_groups); |
410 for (base::FieldTrial::SelectedGroups::const_iterator it = | 410 for (base::FieldTrial::SelectedGroups::const_iterator it = |
411 initial_groups.begin(); it != initial_groups.end(); ++it) { | 411 initial_groups.begin(); it != initial_groups.end(); ++it) { |
412 chrome_variations::VariationID id = | 412 chrome_variations::VariationID id = |
413 experiments_helper::GetGoogleVariationID(it->trial, it->group); | 413 chrome_variations::GetGoogleVariationID(it->trial, it->group); |
414 if (id != chrome_variations::kEmptyID) | 414 if (id != chrome_variations::kEmptyID) |
415 variation_ids_set_.insert(id); | 415 variation_ids_set_.insert(id); |
416 } | 416 } |
417 UpdateVariationIDsHeaderValue(); | 417 UpdateVariationIDsHeaderValue(); |
418 | 418 |
419 variation_ids_cache_initialized_ = true; | 419 variation_ids_cache_initialized_ = true; |
420 } | 420 } |
421 | 421 |
422 void ChromeResourceDispatcherHostDelegate::UpdateVariationIDsHeaderValue() { | 422 void ChromeResourceDispatcherHostDelegate::UpdateVariationIDsHeaderValue() { |
423 // The header value is a serialized protobuffer of Variation IDs which we | 423 // The header value is a serialized protobuffer of Variation IDs which we |
(...skipping 12 matching lines...) Expand all Loading... |
436 if (base::Base64Encode(serialized, &hashed)) { | 436 if (base::Base64Encode(serialized, &hashed)) { |
437 // If successful, swap the header value with the new one. | 437 // If successful, swap the header value with the new one. |
438 // Note that the list of IDs and the header could be temporarily out of sync | 438 // Note that the list of IDs and the header could be temporarily out of sync |
439 // if IDs are added as we are recreating the header, but we're OK with those | 439 // if IDs are added as we are recreating the header, but we're OK with those |
440 // descrepancies. | 440 // descrepancies. |
441 variation_ids_header_ = hashed; | 441 variation_ids_header_ = hashed; |
442 } else { | 442 } else { |
443 DVLOG(1) << "Failed to base64 encode Variation IDs value: " << serialized; | 443 DVLOG(1) << "Failed to base64 encode Variation IDs value: " << serialized; |
444 } | 444 } |
445 } | 445 } |
OLD | NEW |