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

Side by Side Diff: components/pairing/fake_host_pairing_controller.cc

Issue 1519883003: 1) Add basic configuration (network connection, language, keyboard layout, timezone) setup page. 2)… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/pairing/fake_host_pairing_controller.h" 5 #include "components/pairing/fake_host_pairing_controller.h"
6 6
7 #include <map> 7 #include <map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 CHECK(confirmation_code_.length() == kCodeLength && 65 CHECK(confirmation_code_.length() == kCodeLength &&
66 confirmation_code_.find_first_not_of("0123456789") == std::string::npos) 66 confirmation_code_.find_first_not_of("0123456789") == std::string::npos)
67 << "Wrong 'code' format."; 67 << "Wrong 'code' format.";
68 68
69 device_name_ = 69 device_name_ =
70 dict.count("device_name") ? dict["device_name"] : "Chromebox-01"; 70 dict.count("device_name") ? dict["device_name"] : "Chromebox-01";
71 71
72 enrollment_domain_ = dict.count("domain") ? dict["domain"] : "example.com"; 72 enrollment_domain_ = dict.count("domain") ? dict["domain"] : "example.com";
73 } 73 }
74 74
75 void FakeHostPairingController::ChangeStage(Stage new_stage) {
76 if (current_stage_ == new_stage)
77 return;
78 current_stage_ = new_stage;
79 FOR_EACH_OBSERVER(Observer, observers_, PairingStageChanged(new_stage));
80 }
81
82 void FakeHostPairingController::ChangeStageLater(Stage new_stage) { 75 void FakeHostPairingController::ChangeStageLater(Stage new_stage) {
83 base::MessageLoop::current()->PostDelayedTask( 76 base::MessageLoop::current()->PostDelayedTask(
84 FROM_HERE, 77 FROM_HERE,
85 base::Bind(&FakeHostPairingController::ChangeStage, 78 base::Bind(&FakeHostPairingController::ChangeStage,
86 base::Unretained(this), 79 base::Unretained(this),
87 new_stage), 80 new_stage),
88 async_duration_); 81 async_duration_);
89 } 82 }
90 83
91 void FakeHostPairingController::AddObserver(Observer* observer) { 84 void FakeHostPairingController::AddObserver(Observer* observer) {
92 observers_.AddObserver(observer); 85 observers_.AddObserver(observer);
93 } 86 }
94 87
95 void FakeHostPairingController::RemoveObserver(Observer* observer) { 88 void FakeHostPairingController::RemoveObserver(Observer* observer) {
96 observers_.RemoveObserver(observer); 89 observers_.RemoveObserver(observer);
97 } 90 }
98 91
99 HostPairingController::Stage FakeHostPairingController::GetCurrentStage() { 92 HostPairingController::Stage FakeHostPairingController::GetCurrentStage() {
100 return current_stage_; 93 return current_stage_;
101 } 94 }
102 95
96 void FakeHostPairingController::ChangeStage(Stage new_stage) {
97 if (current_stage_ == new_stage)
98 return;
99 current_stage_ = new_stage;
100 FOR_EACH_OBSERVER(Observer, observers_, PairingStageChanged(new_stage));
101 }
102
103 void FakeHostPairingController::StartPairing() { 103 void FakeHostPairingController::StartPairing() {
104 CHECK(current_stage_ == STAGE_NONE); 104 CHECK(current_stage_ == STAGE_NONE);
105 if (start_after_update_) { 105 if (start_after_update_) {
106 ChangeStage(STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE); 106 ChangeStage(STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE);
107 } else { 107 } else {
108 ChangeStage(STAGE_WAITING_FOR_CONTROLLER); 108 ChangeStage(STAGE_WAITING_FOR_CONTROLLER);
109 } 109 }
110 } 110 }
111 111
112 std::string FakeHostPairingController::GetDeviceName() { 112 std::string FakeHostPairingController::GetDeviceName() {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 167 }
168 case STAGE_ENROLLMENT_SUCCESS: { 168 case STAGE_ENROLLMENT_SUCCESS: {
169 ChangeStageLater(STAGE_FINISHED); 169 ChangeStageLater(STAGE_FINISHED);
170 break; 170 break;
171 } 171 }
172 default: { break; } 172 default: { break; }
173 } 173 }
174 } 174 }
175 175
176 } // namespace pairing_chromeos 176 } // namespace pairing_chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698