OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/views/keyword_editor_view.h" | 5 #include "chrome/browser/views/keyword_editor_view.h" |
6 | 6 |
7 #include <atlbase.h> | |
8 #include <atlapp.h> | |
9 #include <vector> | 7 #include <vector> |
10 | 8 |
11 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/gfx/point.h" |
12 #include "base/stl_util-inl.h" | 11 #include "base/stl_util-inl.h" |
13 #include "base/string_util.h" | 12 #include "base/string_util.h" |
14 #include "chrome/browser/profile.h" | 13 #include "chrome/browser/profile.h" |
15 #include "chrome/browser/search_engines/template_url.h" | 14 #include "chrome/browser/search_engines/template_url.h" |
16 #include "chrome/browser/search_engines/template_url_model.h" | 15 #include "chrome/browser/search_engines/template_url_model.h" |
17 #include "chrome/browser/search_engines/template_url_table_model.h" | 16 #include "chrome/browser/search_engines/template_url_table_model.h" |
18 #include "chrome/browser/views/browser_dialogs.h" | 17 #include "chrome/browser/views/browser_dialogs.h" |
19 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
20 #include "chrome/common/pref_service.h" | 19 #include "chrome/common/pref_service.h" |
21 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 can_make_default = controller_->CanMakeDefault(selected_url); | 211 can_make_default = controller_->CanMakeDefault(selected_url); |
213 can_remove = controller_->CanRemove(selected_url); | 212 can_remove = controller_->CanRemove(selected_url); |
214 } | 213 } |
215 remove_button_->SetEnabled(can_remove); | 214 remove_button_->SetEnabled(can_remove); |
216 make_default_button_->SetEnabled(can_make_default); | 215 make_default_button_->SetEnabled(can_make_default); |
217 } | 216 } |
218 | 217 |
219 void KeywordEditorView::OnDoubleClick() { | 218 void KeywordEditorView::OnDoubleClick() { |
220 if (edit_button_->IsEnabled()) { | 219 if (edit_button_->IsEnabled()) { |
221 DWORD pos = GetMessagePos(); | 220 DWORD pos = GetMessagePos(); |
222 POINT cursor_point = { GET_X_LPARAM(pos), GET_Y_LPARAM(pos) }; | 221 gfx::Point cursor_point(pos); |
223 views::MouseEvent event(views::Event::ET_MOUSE_RELEASED, | 222 views::MouseEvent event(views::Event::ET_MOUSE_RELEASED, |
224 cursor_point.x, cursor_point.y, | 223 cursor_point.x(), cursor_point.y(), |
225 views::Event::EF_LEFT_BUTTON_DOWN); | 224 views::Event::EF_LEFT_BUTTON_DOWN); |
226 ButtonPressed(edit_button_, event); | 225 ButtonPressed(edit_button_, event); |
227 } | 226 } |
228 } | 227 } |
229 | 228 |
230 void KeywordEditorView::ButtonPressed( | 229 void KeywordEditorView::ButtonPressed( |
231 views::Button* sender, const views::Event& event) { | 230 views::Button* sender, const views::Event& event) { |
232 if (sender == add_button_) { | 231 if (sender == add_button_) { |
233 browser::EditSearchEngine(GetWindow()->GetNativeWindow(), NULL, this, | 232 browser::EditSearchEngine(GetWindow()->GetNativeWindow(), NULL, this, |
234 profile_); | 233 profile_); |
235 } else if (sender == remove_button_) { | 234 } else if (sender == remove_button_) { |
236 DCHECK(table_view_->SelectedRowCount() == 1); | 235 DCHECK_EQ(1, table_view_->SelectedRowCount()); |
237 int last_view_row = -1; | 236 int last_view_row = -1; |
238 for (views::TableView::iterator i = table_view_->SelectionBegin(); | 237 for (views::TableView::iterator i = table_view_->SelectionBegin(); |
239 i != table_view_->SelectionEnd(); ++i) { | 238 i != table_view_->SelectionEnd(); ++i) { |
240 last_view_row = table_view_->model_to_view(*i); | 239 last_view_row = table_view_->model_to_view(*i); |
241 controller_->RemoveTemplateURL(*i); | 240 controller_->RemoveTemplateURL(*i); |
242 } | 241 } |
243 if (last_view_row >= controller_->table_model()->RowCount()) | 242 if (last_view_row >= controller_->table_model()->RowCount()) |
244 last_view_row = controller_->table_model()->RowCount() - 1; | 243 last_view_row = controller_->table_model()->RowCount() - 1; |
245 if (last_view_row >= 0) | 244 if (last_view_row >= 0) |
246 table_view_->Select(table_view_->view_to_model(last_view_row)); | 245 table_view_->Select(table_view_->view_to_model(last_view_row)); |
(...skipping 13 matching lines...) Expand all Loading... |
260 void KeywordEditorView::OnTemplateURLModelChanged() { | 259 void KeywordEditorView::OnTemplateURLModelChanged() { |
261 add_button_->SetEnabled(controller_->loaded()); | 260 add_button_->SetEnabled(controller_->loaded()); |
262 } | 261 } |
263 | 262 |
264 void KeywordEditorView::MakeDefaultTemplateURL() { | 263 void KeywordEditorView::MakeDefaultTemplateURL() { |
265 int new_index = | 264 int new_index = |
266 controller_->MakeDefaultTemplateURL(table_view_->FirstSelectedRow()); | 265 controller_->MakeDefaultTemplateURL(table_view_->FirstSelectedRow()); |
267 if (new_index >= 0) | 266 if (new_index >= 0) |
268 table_view_->Select(new_index); | 267 table_view_->Select(new_index); |
269 } | 268 } |
OLD | NEW |