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/views/bookmarks/bookmark_editor_view.h" | 5 #include "chrome/browser/ui/views/bookmarks/bookmark_editor_view.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/bookmarks/bookmark_model.h" | 14 #include "chrome/browser/bookmarks/bookmark_model.h" |
15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
16 #include "chrome/browser/bookmarks/bookmark_utils.h" | 16 #include "chrome/browser/bookmarks/bookmark_utils.h" |
17 #include "chrome/browser/history/history_service.h" | 17 #include "chrome/browser/history/history_service.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 19 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
20 #include "chrome/browser/ui/views/constrained_window_views.h" | 20 #include "chrome/browser/ui/views/constrained_window_views.h" |
21 #include "chrome/common/net/url_fixer_upper.h" | 21 #include "chrome/common/net/url_fixer_upper.h" |
22 #include "components/user_prefs/user_prefs.h" | 22 #include "components/user_prefs/user_prefs.h" |
23 #include "grit/chromium_strings.h" | 23 #include "grit/chromium_strings.h" |
24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
25 #include "grit/locale_settings.h" | 25 #include "grit/locale_settings.h" |
| 26 #include "ui/base/accessibility/accessible_view_state.h" |
26 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
27 #include "ui/events/event.h" | 28 #include "ui/events/event.h" |
28 #include "ui/views/background.h" | 29 #include "ui/views/background.h" |
29 #include "ui/views/controls/button/label_button.h" | 30 #include "ui/views/controls/button/label_button.h" |
30 #include "ui/views/controls/label.h" | 31 #include "ui/views/controls/label.h" |
31 #include "ui/views/controls/menu/menu_runner.h" | 32 #include "ui/views/controls/menu/menu_runner.h" |
32 #include "ui/views/controls/textfield/textfield.h" | 33 #include "ui/views/controls/textfield/textfield.h" |
33 #include "ui/views/controls/tree/tree_view.h" | 34 #include "ui/views/controls/tree/tree_view.h" |
34 #include "ui/views/focus/focus_manager.h" | 35 #include "ui/views/focus/focus_manager.h" |
35 #include "ui/views/layout/grid_layout.h" | 36 #include "ui/views/layout/grid_layout.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 void BookmarkEditorView::ContentsChanged(views::Textfield* sender, | 157 void BookmarkEditorView::ContentsChanged(views::Textfield* sender, |
157 const string16& new_contents) { | 158 const string16& new_contents) { |
158 UserInputChanged(); | 159 UserInputChanged(); |
159 } | 160 } |
160 | 161 |
161 bool BookmarkEditorView::HandleKeyEvent(views::Textfield* sender, | 162 bool BookmarkEditorView::HandleKeyEvent(views::Textfield* sender, |
162 const ui::KeyEvent& key_event) { | 163 const ui::KeyEvent& key_event) { |
163 return false; | 164 return false; |
164 } | 165 } |
165 | 166 |
| 167 void BookmarkEditorView::GetAccessibleState(ui::AccessibleViewState* state) { |
| 168 state->name = |
| 169 l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_TITLE); |
| 170 state->role = ui::AccessibilityTypes::ROLE_DIALOG; |
| 171 } |
| 172 |
166 void BookmarkEditorView::ButtonPressed(views::Button* sender, | 173 void BookmarkEditorView::ButtonPressed(views::Button* sender, |
167 const ui::Event& event) { | 174 const ui::Event& event) { |
168 DCHECK_EQ(new_folder_button_.get(), sender); | 175 DCHECK_EQ(new_folder_button_.get(), sender); |
169 NewFolder(); | 176 NewFolder(); |
170 } | 177 } |
171 | 178 |
172 bool BookmarkEditorView::IsCommandIdChecked(int command_id) const { | 179 bool BookmarkEditorView::IsCommandIdChecked(int command_id) const { |
173 return false; | 180 return false; |
174 } | 181 } |
175 | 182 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 if (details_.type == EditDetails::EXISTING_NODE) { | 270 if (details_.type == EditDetails::EXISTING_NODE) { |
264 title = details_.existing_node->GetTitle(); | 271 title = details_.existing_node->GetTitle(); |
265 url = details_.existing_node->url(); | 272 url = details_.existing_node->url(); |
266 } else if (details_.type == EditDetails::NEW_FOLDER) { | 273 } else if (details_.type == EditDetails::NEW_FOLDER) { |
267 title = l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_NEW_FOLDER_NAME); | 274 title = l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_NEW_FOLDER_NAME); |
268 } else if (details_.type == EditDetails::NEW_URL) { | 275 } else if (details_.type == EditDetails::NEW_URL) { |
269 url = details_.url; | 276 url = details_.url; |
270 title = details_.title; | 277 title = details_.title; |
271 } | 278 } |
272 title_tf_ = new views::Textfield; | 279 title_tf_ = new views::Textfield; |
| 280 title_tf_->SetAccessibleName( |
| 281 l10n_util::GetStringUTF16(IDS_BOOKMARK_AX_EDITOR_NAME_LABEL)); |
273 title_tf_->SetText(title); | 282 title_tf_->SetText(title); |
274 title_tf_->SetController(this); | 283 title_tf_->SetController(this); |
275 title_tf_->SetAccessibleName(title_label_->text()); | |
276 | 284 |
277 if (show_tree_) { | 285 if (show_tree_) { |
278 tree_view_ = new views::TreeView; | 286 tree_view_ = new views::TreeView; |
279 tree_view_->SetRootShown(false); | 287 tree_view_->SetRootShown(false); |
280 tree_view_->set_context_menu_controller(this); | 288 tree_view_->set_context_menu_controller(this); |
281 | 289 |
282 new_folder_button_.reset(new views::LabelButton(this, | 290 new_folder_button_.reset(new views::LabelButton(this, |
283 l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_NEW_FOLDER_BUTTON))); | 291 l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_NEW_FOLDER_BUTTON))); |
284 new_folder_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); | 292 new_folder_button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); |
285 new_folder_button_->set_owned_by_client(); | 293 new_folder_button_->set_owned_by_client(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 329 |
322 if (details_.GetNodeType() != BookmarkNode::FOLDER) { | 330 if (details_.GetNodeType() != BookmarkNode::FOLDER) { |
323 url_label_ = new views::Label( | 331 url_label_ = new views::Label( |
324 l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_URL_LABEL)); | 332 l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_URL_LABEL)); |
325 | 333 |
326 url_tf_ = new views::Textfield; | 334 url_tf_ = new views::Textfield; |
327 PrefService* prefs = | 335 PrefService* prefs = |
328 profile_ ? user_prefs::UserPrefs::Get(profile_) : NULL; | 336 profile_ ? user_prefs::UserPrefs::Get(profile_) : NULL; |
329 url_tf_->SetText(chrome::FormatBookmarkURLForDisplay(url, prefs)); | 337 url_tf_->SetText(chrome::FormatBookmarkURLForDisplay(url, prefs)); |
330 url_tf_->SetController(this); | 338 url_tf_->SetController(this); |
331 url_tf_->SetAccessibleName(url_label_->text()); | 339 url_tf_->SetAccessibleName( |
| 340 l10n_util::GetStringUTF16(IDS_BOOKMARK_AX_EDITOR_URL_LABEL)); |
332 | 341 |
333 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 342 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
334 | 343 |
335 layout->StartRow(0, labels_column_set_id); | 344 layout->StartRow(0, labels_column_set_id); |
336 layout->AddView(url_label_); | 345 layout->AddView(url_label_); |
337 layout->AddView(url_tf_); | 346 layout->AddView(url_tf_); |
338 } | 347 } |
339 | 348 |
340 if (show_tree_) { | 349 if (show_tree_) { |
341 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 350 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM); | 623 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM); |
615 } | 624 } |
616 return context_menu_model_.get(); | 625 return context_menu_model_.get(); |
617 } | 626 } |
618 | 627 |
619 void BookmarkEditorView::EditorTreeModel::SetTitle(ui::TreeModelNode* node, | 628 void BookmarkEditorView::EditorTreeModel::SetTitle(ui::TreeModelNode* node, |
620 const string16& title) { | 629 const string16& title) { |
621 if (!title.empty()) | 630 if (!title.empty()) |
622 ui::TreeNodeModel<EditorNode>::SetTitle(node, title); | 631 ui::TreeNodeModel<EditorNode>::SetTitle(node, title); |
623 } | 632 } |
OLD | NEW |