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

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

Issue 191093002: Simplify the user agent code some more since after r255534 it's not affected by the site's URL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: patchset 15 which works 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"
20 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
21 #include "chromeos/chromeos_switches.h" 22 #include "chromeos/chromeos_switches.h"
22 #include "components/policy/core/browser/browser_policy_connector.h" 23 #include "components/policy/core/browser/browser_policy_connector.h"
23 #include "components/policy/core/common/cloud/device_management_service.h" 24 #include "components/policy/core/common/cloud/device_management_service.h"
24 #include "components/policy/core/common/cloud/system_policy_request_context.h" 25 #include "components/policy/core/common/cloud/system_policy_request_context.h"
25 #include "content/public/browser/browser_thread.h" 26 #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, 106 system_request_context, GetUserAgent());
107 content::GetUserAgent(
108 GURL(device_management_service_->GetServerUrl())));
109 107
110 DCHECK_LE(power_initial_, power_limit_); 108 DCHECK_LE(power_initial_, power_limit_);
111 DCHECK(!completion_callback_.is_null()); 109 DCHECK(!completion_callback_.is_null());
112 if (!serial_number.empty()) 110 if (!serial_number.empty())
113 serial_number_hash_ = crypto::SHA256HashString(serial_number); 111 serial_number_hash_ = crypto::SHA256HashString(serial_number);
114 net::NetworkChangeNotifier::AddNetworkChangeObserver(this); 112 net::NetworkChangeNotifier::AddNetworkChangeObserver(this);
115 } 113 }
116 114
117 AutoEnrollmentClient::~AutoEnrollmentClient() { 115 AutoEnrollmentClient::~AutoEnrollmentClient() {
118 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); 116 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 request_job_.reset(); 390 request_job_.reset();
393 time_start_ = base::Time(); 391 time_start_ = base::Time();
394 392
395 if (completion_callback_.is_null()) { 393 if (completion_callback_.is_null()) {
396 // CancelAndDeleteSoon() was invoked before. 394 // CancelAndDeleteSoon() was invoked before.
397 base::MessageLoopProxy::current()->DeleteSoon(FROM_HERE, this); 395 base::MessageLoopProxy::current()->DeleteSoon(FROM_HERE, this);
398 } 396 }
399 } 397 }
400 398
401 } // namespace policy 399 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698