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

Side by Side Diff: trunk/src/chrome/browser/chromeos/policy/auto_enrollment_client.cc

Issue 192283002: Revert 255858 "Simplify the user agent code some more since afte..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 9 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) 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/chromeos/policy/auto_enrollment_client.h" 5 #include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop/message_loop_proxy.h" 12 #include "base/message_loop/message_loop_proxy.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/metrics/sparse_histogram.h" 14 #include "base/metrics/sparse_histogram.h"
15 #include "base/prefs/pref_registry_simple.h" 15 #include "base/prefs/pref_registry_simple.h"
16 #include "base/prefs/pref_service.h" 16 #include "base/prefs/pref_service.h"
17 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
18 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
19 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h" 19 #include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
20 #include "chrome/common/chrome_content_client.h"
21 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
22 #include "chromeos/chromeos_switches.h" 21 #include "chromeos/chromeos_switches.h"
23 #include "components/policy/core/browser/browser_policy_connector.h" 22 #include "components/policy/core/browser/browser_policy_connector.h"
24 #include "components/policy/core/common/cloud/device_management_service.h" 23 #include "components/policy/core/common/cloud/device_management_service.h"
25 #include "components/policy/core/common/cloud/system_policy_request_context.h" 24 #include "components/policy/core/common/cloud/system_policy_request_context.h"
26 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
26 #include "content/public/common/content_client.h"
27 #include "crypto/sha2.h" 27 #include "crypto/sha2.h"
28 #include "net/url_request/url_request_context_getter.h" 28 #include "net/url_request/url_request_context_getter.h"
29 #include "url/gurl.h" 29 #include "url/gurl.h"
30 30
31 using content::BrowserThread; 31 using content::BrowserThread;
32 32
33 namespace em = enterprise_management; 33 namespace em = enterprise_management;
34 34
35 namespace { 35 namespace {
36 36
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 int power_limit) 96 int power_limit)
97 : completion_callback_(callback), 97 : completion_callback_(callback),
98 should_auto_enroll_(false), 98 should_auto_enroll_(false),
99 device_id_(base::GenerateGUID()), 99 device_id_(base::GenerateGUID()),
100 power_initial_(power_initial), 100 power_initial_(power_initial),
101 power_limit_(power_limit), 101 power_limit_(power_limit),
102 modulus_updates_received_(0), 102 modulus_updates_received_(0),
103 device_management_service_(service), 103 device_management_service_(service),
104 local_state_(local_state) { 104 local_state_(local_state) {
105 request_context_ = new SystemPolicyRequestContext( 105 request_context_ = new SystemPolicyRequestContext(
106 system_request_context, GetUserAgent()); 106 system_request_context,
107 content::GetUserAgent(
108 GURL(device_management_service_->GetServerUrl())));
107 109
108 DCHECK_LE(power_initial_, power_limit_); 110 DCHECK_LE(power_initial_, power_limit_);
109 DCHECK(!completion_callback_.is_null()); 111 DCHECK(!completion_callback_.is_null());
110 if (!serial_number.empty()) 112 if (!serial_number.empty())
111 serial_number_hash_ = crypto::SHA256HashString(serial_number); 113 serial_number_hash_ = crypto::SHA256HashString(serial_number);
112 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); 114 net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
113 } 115 }
114 116
115 AutoEnrollmentClient::~AutoEnrollmentClient() { 117 AutoEnrollmentClient::~AutoEnrollmentClient() {
116 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); 118 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 request_job_.reset(); 392 request_job_.reset();
391 time_start_ = base::Time(); 393 time_start_ = base::Time();
392 394
393 if (completion_callback_.is_null()) { 395 if (completion_callback_.is_null()) {
394 // CancelAndDeleteSoon() was invoked before. 396 // CancelAndDeleteSoon() was invoked before.
395 base::MessageLoopProxy::current()->DeleteSoon(FROM_HERE, this); 397 base::MessageLoopProxy::current()->DeleteSoon(FROM_HERE, this);
396 } 398 }
397 } 399 }
398 400
399 } // namespace policy 401 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698