OLD | NEW |
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/ui/webui/input_window_dialog_webui.h" | 5 #include "chrome/browser/ui/webui/input_window_dialog_webui.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 144 |
145 //////////////////////////////////////////////////////////////////////////////// | 145 //////////////////////////////////////////////////////////////////////////////// |
146 // InputWindowDialogHandler methods | 146 // InputWindowDialogHandler methods |
147 | 147 |
148 InputWindowDialogHandler::InputWindowDialogHandler( | 148 InputWindowDialogHandler::InputWindowDialogHandler( |
149 InputWindowDialog::Delegate* delegate) | 149 InputWindowDialog::Delegate* delegate) |
150 : delegate_(delegate) { | 150 : delegate_(delegate) { |
151 } | 151 } |
152 | 152 |
153 void InputWindowDialogHandler::CloseDialog() { | 153 void InputWindowDialogHandler::CloseDialog() { |
154 static_cast<HtmlDialogUI*>(web_ui())->CloseDialog(NULL); | 154 static_cast<HtmlDialogUI*>(web_ui()->GetController())->CloseDialog(NULL); |
155 } | 155 } |
156 | 156 |
157 void InputWindowDialogHandler::RegisterMessages() { | 157 void InputWindowDialogHandler::RegisterMessages() { |
158 web_ui()->RegisterMessageCallback("validate", | 158 web_ui()->RegisterMessageCallback("validate", |
159 base::Bind(&InputWindowDialogHandler::Validate, | 159 base::Bind(&InputWindowDialogHandler::Validate, |
160 base::Unretained(this))); | 160 base::Unretained(this))); |
161 } | 161 } |
162 | 162 |
163 void InputWindowDialogHandler::Validate(const base::ListValue* args) { | 163 void InputWindowDialogHandler::Validate(const base::ListValue* args) { |
164 DCHECK(args->GetSize() == 1U || args->GetSize() == 2U); | 164 DCHECK(args->GetSize() == 1U || args->GetSize() == 2U); |
165 InputWindowDialog::InputTexts texts; | 165 InputWindowDialog::InputTexts texts; |
166 string16 name; | 166 string16 name; |
167 if (args->GetString(0, &name)) { | 167 if (args->GetString(0, &name)) { |
168 texts.push_back(name); | 168 texts.push_back(name); |
169 } | 169 } |
170 string16 url; | 170 string16 url; |
171 if (args->GetSize() == 2 && args->GetString(0, &url)) { | 171 if (args->GetSize() == 2 && args->GetString(0, &url)) { |
172 texts.push_back(url); | 172 texts.push_back(url); |
173 } | 173 } |
174 const bool valid = delegate_->IsValid(texts); | 174 const bool valid = delegate_->IsValid(texts); |
175 scoped_ptr<Value> result(Value::CreateBooleanValue(valid)); | 175 scoped_ptr<Value> result(Value::CreateBooleanValue(valid)); |
176 web_ui()->CallJavascriptFunction("inputWindowDialog.ackValidation", | 176 web_ui()->CallJavascriptFunction("inputWindowDialog.ackValidation", |
177 *result); | 177 *result); |
178 } | 178 } |
OLD | NEW |