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

Side by Side Diff: chrome/browser/ui/webui/chromeos/first_run/first_run_handler.cc

Issue 1995113002: Rename WebUI::CallJavascriptFunction to WebUI::CallJavascriptFunctionUnsafe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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/ui/webui/chromeos/first_run/first_run_handler.h" 5 #include "chrome/browser/ui/webui/chromeos/first_run/first_run_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "content/public/browser/web_ui.h" 9 #include "content/public/browser/web_ui.h"
10 10
11 namespace chromeos { 11 namespace chromeos {
12 12
13 FirstRunHandler::FirstRunHandler() 13 FirstRunHandler::FirstRunHandler()
14 : is_initialized_(false), 14 : is_initialized_(false),
15 is_finalizing_(false) { 15 is_finalizing_(false) {
16 } 16 }
17 17
18 bool FirstRunHandler::IsInitialized() { 18 bool FirstRunHandler::IsInitialized() {
19 return is_initialized_; 19 return is_initialized_;
20 } 20 }
21 21
22 void FirstRunHandler::SetBackgroundVisible(bool visible) { 22 void FirstRunHandler::SetBackgroundVisible(bool visible) {
23 web_ui()->CallJavascriptFunction("cr.FirstRun.setBackgroundVisible", 23 web_ui()->CallJavascriptFunctionUnsafe("cr.FirstRun.setBackgroundVisible",
24 base::FundamentalValue(visible)); 24 base::FundamentalValue(visible));
25 } 25 }
26 26
27 void FirstRunHandler::AddRectangularHole(int x, int y, int width, int height) { 27 void FirstRunHandler::AddRectangularHole(int x, int y, int width, int height) {
28 web_ui()->CallJavascriptFunction("cr.FirstRun.addRectangularHole", 28 web_ui()->CallJavascriptFunctionUnsafe(
29 base::FundamentalValue(x), 29 "cr.FirstRun.addRectangularHole", base::FundamentalValue(x),
30 base::FundamentalValue(y), 30 base::FundamentalValue(y), base::FundamentalValue(width),
31 base::FundamentalValue(width), 31 base::FundamentalValue(height));
32 base::FundamentalValue(height));
33 } 32 }
34 33
35 void FirstRunHandler::AddRoundHole(int x, int y, float radius) { 34 void FirstRunHandler::AddRoundHole(int x, int y, float radius) {
36 web_ui()->CallJavascriptFunction("cr.FirstRun.addRoundHole", 35 web_ui()->CallJavascriptFunctionUnsafe(
37 base::FundamentalValue(x), 36 "cr.FirstRun.addRoundHole", base::FundamentalValue(x),
38 base::FundamentalValue(y), 37 base::FundamentalValue(y), base::FundamentalValue(radius));
39 base::FundamentalValue(radius));
40 } 38 }
41 39
42 void FirstRunHandler::RemoveBackgroundHoles() { 40 void FirstRunHandler::RemoveBackgroundHoles() {
43 web_ui()->CallJavascriptFunction("cr.FirstRun.removeHoles"); 41 web_ui()->CallJavascriptFunctionUnsafe("cr.FirstRun.removeHoles");
44 } 42 }
45 43
46 void FirstRunHandler::ShowStepPositioned(const std::string& name, 44 void FirstRunHandler::ShowStepPositioned(const std::string& name,
47 const StepPosition& position) { 45 const StepPosition& position) {
48 web_ui()->CallJavascriptFunction("cr.FirstRun.showStep", 46 web_ui()->CallJavascriptFunctionUnsafe(
49 base::StringValue(name), 47 "cr.FirstRun.showStep", base::StringValue(name), *position.AsValue());
50 *position.AsValue());
51 } 48 }
52 49
53 void FirstRunHandler::ShowStepPointingTo(const std::string& name, 50 void FirstRunHandler::ShowStepPointingTo(const std::string& name,
54 int x, 51 int x,
55 int y, 52 int y,
56 int offset) { 53 int offset) {
57 std::unique_ptr<base::Value> null = base::Value::CreateNullValue(); 54 std::unique_ptr<base::Value> null = base::Value::CreateNullValue();
58 base::ListValue point_with_offset; 55 base::ListValue point_with_offset;
59 point_with_offset.AppendInteger(x); 56 point_with_offset.AppendInteger(x);
60 point_with_offset.AppendInteger(y); 57 point_with_offset.AppendInteger(y);
61 point_with_offset.AppendInteger(offset); 58 point_with_offset.AppendInteger(offset);
62 web_ui()->CallJavascriptFunction("cr.FirstRun.showStep", 59 web_ui()->CallJavascriptFunctionUnsafe("cr.FirstRun.showStep",
63 base::StringValue(name), 60 base::StringValue(name), *null,
64 *null, 61 point_with_offset);
65 point_with_offset);
66 } 62 }
67 63
68 void FirstRunHandler::HideCurrentStep() { 64 void FirstRunHandler::HideCurrentStep() {
69 web_ui()->CallJavascriptFunction("cr.FirstRun.hideCurrentStep"); 65 web_ui()->CallJavascriptFunctionUnsafe("cr.FirstRun.hideCurrentStep");
70 } 66 }
71 67
72 void FirstRunHandler::Finalize() { 68 void FirstRunHandler::Finalize() {
73 is_finalizing_ = true; 69 is_finalizing_ = true;
74 web_ui()->CallJavascriptFunction("cr.FirstRun.finalize"); 70 web_ui()->CallJavascriptFunctionUnsafe("cr.FirstRun.finalize");
75 } 71 }
76 72
77 bool FirstRunHandler::IsFinalizing() { 73 bool FirstRunHandler::IsFinalizing() {
78 return is_finalizing_; 74 return is_finalizing_;
79 } 75 }
80 76
81 void FirstRunHandler::RegisterMessages() { 77 void FirstRunHandler::RegisterMessages() {
82 web_ui()->RegisterMessageCallback("initialized", 78 web_ui()->RegisterMessageCallback("initialized",
83 base::Bind(&FirstRunHandler::HandleInitialized, base::Unretained(this))); 79 base::Bind(&FirstRunHandler::HandleInitialized, base::Unretained(this)));
84 web_ui()->RegisterMessageCallback("nextButtonClicked", 80 web_ui()->RegisterMessageCallback("nextButtonClicked",
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 delegate()->OnStepHidden(step_name); 126 delegate()->OnStepHidden(step_name);
131 } 127 }
132 128
133 void FirstRunHandler::HandleFinalized(const base::ListValue* args) { 129 void FirstRunHandler::HandleFinalized(const base::ListValue* args) {
134 is_finalizing_ = false; 130 is_finalizing_ = false;
135 if (delegate()) 131 if (delegate())
136 delegate()->OnActorFinalized(); 132 delegate()->OnActorFinalized();
137 } 133 }
138 134
139 } // namespace chromeos 135 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698