1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/chromeos/first_run/first_run_handler.h"
8 #include "base/values.h"
9 #include "content/public/browser/web_ui.h"
13 FirstRunHandler::FirstRunHandler()
14 : is_initialized_(false) {
17 bool FirstRunHandler::IsInitialized() {
18 return is_initialized_;
21 void FirstRunHandler::AddBackgroundHole(int x, int y, int width, int height) {
22 web_ui()->CallJavascriptFunction("cr.FirstRun.addHole",
23 base::FundamentalValue(x),
24 base::FundamentalValue(y),
25 base::FundamentalValue(width),
26 base::FundamentalValue(height));
29 void FirstRunHandler::RemoveBackgroundHoles() {
30 web_ui()->CallJavascriptFunction("cr.FirstRun.removeHoles");
33 void FirstRunHandler::ShowStep(const std::string& name,
34 const StepPosition& position) {
35 web_ui()->CallJavascriptFunction("cr.FirstRun.showStep",
36 base::StringValue(name),
40 void FirstRunHandler::RegisterMessages() {
41 web_ui()->RegisterMessageCallback("initialized",
42 base::Bind(&FirstRunHandler::HandleInitialized, base::Unretained(this)));
43 web_ui()->RegisterMessageCallback("nextButtonClicked",
44 base::Bind(&FirstRunHandler::HandleNextButtonClicked,
45 base::Unretained(this)));
48 void FirstRunHandler::HandleInitialized(const base::ListValue* args) {
49 is_initialized_ = true;
51 delegate()->OnActorInitialized();
54 void FirstRunHandler::HandleNextButtonClicked(const base::ListValue* args) {
55 std::string step_name;
56 CHECK(args->GetString(0, &step_name));
58 delegate()->OnNextButtonClicked(step_name);
61 } // namespace chromeos