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

Unified Diff: chrome/browser/ui/webui/input_window_dialog_webui.cc

Issue 8438037: Change 'Add Page' to show a simple input dialog with --use-more-webui. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/input_window_dialog_webui.cc
diff --git a/chrome/browser/ui/webui/input_window_dialog_webui.cc b/chrome/browser/ui/webui/input_window_dialog_webui.cc
index 9ec98ea7748c6fdba84a29564a626f5464440998..7440c0d54829eab31c938f222c96ceac3085c613 100644
--- a/chrome/browser/ui/webui/input_window_dialog_webui.cc
+++ b/chrome/browser/ui/webui/input_window_dialog_webui.cc
@@ -19,8 +19,9 @@
namespace {
-const int kInputWindowDialogWidth = 240;
-const int kInputWindowDialogHeight = 120;
+const int kInputWindowDialogWidth = 300;
+const int kInputWindowDialogBaseHeight = 90;
+const int kInputWindowDialogContentsHeight = 20;
}
@@ -29,13 +30,11 @@ const int kInputWindowDialogHeight = 120;
InputWindowDialogWebUI::InputWindowDialogWebUI(
const string16& window_title,
- const string16& label,
- const string16& contents,
+ const LabelContentsPairs& label_contents_pairs,
InputWindowDialog::Delegate* delegate)
: handler_(new InputWindowDialogHandler(delegate)),
window_title_(window_title),
- label_(label),
- contents_(contents),
+ label_contents_pairs_(label_contents_pairs),
closed_(true),
delegate_(delegate) {
}
@@ -75,13 +74,19 @@ void InputWindowDialogWebUI::GetWebUIMessageHandlers(
}
void InputWindowDialogWebUI::GetDialogSize(gfx::Size* size) const {
- size->SetSize(kInputWindowDialogWidth, kInputWindowDialogHeight);
+ const int height = kInputWindowDialogBaseHeight +
+ kInputWindowDialogContentsHeight * label_contents_pairs_.size();
+ size->SetSize(kInputWindowDialogWidth, height);
}
std::string InputWindowDialogWebUI::GetDialogArgs() const {
DictionaryValue value;
- value.SetString("label", label_);
- value.SetString("contents", contents_);
+ value.SetString("nameLabel", label_contents_pairs_[0].first);
+ value.SetString("name", label_contents_pairs_[0].second);
+ if (label_contents_pairs_.size() == 2) {
+ value.SetString("urlLabel", label_contents_pairs_[1].first);
+ value.SetString("url", label_contents_pairs_[1].second);
+ }
std::string json;
base::JSONWriter::Write(&value, false, &json);
return json;
@@ -97,10 +102,18 @@ void InputWindowDialogWebUI::OnDialogClosed(const std::string& json_retval) {
// field is added to the list.
if (root.get() && root->GetAsList(&list) && list &&
list->GetBoolean(0, &response) && response) {
- DCHECK_EQ(2U, list->GetSize());
- string16 text;
- if (list->GetString(1, &text)) {
- delegate_->InputAccepted(text);
+ DCHECK(list->GetSize() == 2 || list->GetSize() == 3);
+ InputTexts texts;
+ string16 name;
+ if (list->GetString(1, &name)) {
+ texts.push_back(name);
+ }
+ string16 url;
+ if (list->GetSize() == 3 && list->GetString(2, &url)) {
+ texts.push_back(url);
+ }
+ if (delegate_->IsValid(texts)) {
+ delegate_->InputAccepted(texts);
accepted = true;
}
}
@@ -138,12 +151,17 @@ void InputWindowDialogHandler::RegisterMessages() {
}
void InputWindowDialogHandler::Validate(const base::ListValue* args) {
- DCHECK_EQ(1U, args->GetSize());
- bool valid = false;
- string16 text;
- if (args->GetString(0, &text)) {
- valid = delegate_->IsValid(text);
+ DCHECK(args->GetSize() == 1U || args->GetSize() == 2U);
+ InputWindowDialog::InputTexts texts;
+ string16 name;
+ if (args->GetString(0, &name)) {
+ texts.push_back(name);
+ }
+ string16 url;
+ if (args->GetSize() == 2 && args->GetString(0, &url)) {
+ texts.push_back(url);
}
+ const bool valid = delegate_->IsValid(texts);
scoped_ptr<Value> result(Value::CreateBooleanValue(valid));
web_ui_->CallJavascriptFunction("inputWindowDialog.ackValidation",
*result);

Powered by Google App Engine
This is Rietveld 408576698