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

Side by Side Diff: chrome/browser/ui/webui/edit_search_engine_dialog_webui.cc

Issue 8676008: Add automated test for the edit search engine dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix save.onclick. Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/edit_search_engine_dialog_webui.h" 5 #include "chrome/browser/ui/webui/edit_search_engine_dialog_webui.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/json/json_reader.h" 12 #include "base/json/json_reader.h"
13 #include "base/string16.h" 13 #include "base/string16.h"
14 #include "chrome/browser/search_engines/template_url.h" 14 #include "chrome/browser/search_engines/template_url.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list.h"
17 #include "chrome/browser/ui/search_engines/edit_search_engine_controller.h" 17 #include "chrome/browser/ui/search_engines/edit_search_engine_controller.h"
18 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
19 #include "grit/generated_resources.h"
20 #include "grit/theme_resources.h"
19 #include "grit/ui_resources.h" 21 #include "grit/ui_resources.h"
20 #include "grit/theme_resources.h"
21 #include "grit/generated_resources.h"
22 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
23 23
24 namespace { 24 namespace {
25 const int kEditSearchEngineDialogWidth = 394; 25 const int kEditSearchEngineDialogWidth = 394;
26 const int kEditSearchEngineDialogHeight = 180; 26 const int kEditSearchEngineDialogHeight = 180;
27 } 27 }
28 28
29 //////////////////////////////////////////////////////////////////////////////// 29 ////////////////////////////////////////////////////////////////////////////////
30 // Browser dialog API implementation 30 // Browser dialog API implementation
31 31
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 string16 description_str; 143 string16 description_str;
144 string16 keyword_str; 144 string16 keyword_str;
145 std::string url_str; 145 std::string url_str;
146 if (args && args->GetString(0, &description_str) && 146 if (args && args->GetString(0, &description_str) &&
147 args->GetString(1, &keyword_str) && 147 args->GetString(1, &keyword_str) &&
148 args->GetString(2, &url_str)) { 148 args->GetString(2, &url_str)) {
149 DictionaryValue validation; 149 DictionaryValue validation;
150 bool isDescriptionValid = controller_->IsTitleValid(description_str); 150 bool isDescriptionValid = controller_->IsTitleValid(description_str);
151 bool isKeywordValid = controller_->IsKeywordValid(keyword_str); 151 bool isKeywordValid = controller_->IsKeywordValid(keyword_str);
152 bool isUrlValid = controller_->IsURLValid(url_str); 152 bool isUrlValid = controller_->IsURLValid(url_str);
153 validation.SetBoolean("description", isDescriptionValid ); 153 validation.SetBoolean("description", isDescriptionValid);
154 validation.SetBoolean("keyword", isKeywordValid ); 154 validation.SetBoolean("keyword", isKeywordValid);
155 validation.SetBoolean("url", isUrlValid ); 155 validation.SetBoolean("url", isUrlValid);
156 validation.SetBoolean("ok", isDescriptionValid && isKeywordValid && 156 validation.SetBoolean("ok", isDescriptionValid && isKeywordValid &&
157 isUrlValid ); 157 isUrlValid);
158 web_ui_->CallJavascriptFunction("editSearchEngineDialog.setValidation", 158 web_ui_->CallJavascriptFunction("editSearchEngineDialog.setValidation",
159 validation); 159 validation);
160 } 160 }
161 } 161 }
162 162
163 // Returns true if adding. Returns false if editing. 163 // Returns true if adding. Returns false if editing.
164 bool EditSearchEngineDialogHandlerWebUI::IsAdding() { 164 bool EditSearchEngineDialogHandlerWebUI::IsAdding() {
165 return !template_url_; 165 return !template_url_;
166 } 166 }
167 167
(...skipping 11 matching lines...) Expand all
179 dict->GetString("keyword", &keyword_str) && 179 dict->GetString("keyword", &keyword_str) &&
180 dict->GetString("url", &url_str)) { 180 dict->GetString("url", &url_str)) {
181 controller_->AcceptAddOrEdit(description_str, 181 controller_->AcceptAddOrEdit(description_str,
182 keyword_str, 182 keyword_str,
183 url_str); 183 url_str);
184 } else { 184 } else {
185 controller_->CleanUpCancelledAdd(); 185 controller_->CleanUpCancelledAdd();
186 } 186 }
187 } 187 }
188 } 188 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698