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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc

Issue 7744055: bookmarks: Fix an obvious typo in IDS_BOOMARK_*. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 months 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/views/bookmarks/bookmark_editor_view.h" 5 #include "chrome/browser/ui/views/bookmarks/bookmark_editor_view.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 bool BookmarkEditorView::IsModal() const { 100 bool BookmarkEditorView::IsModal() const {
101 return true; 101 return true;
102 } 102 }
103 103
104 bool BookmarkEditorView::CanResize() const { 104 bool BookmarkEditorView::CanResize() const {
105 return true; 105 return true;
106 } 106 }
107 107
108 std::wstring BookmarkEditorView::GetWindowTitle() const { 108 std::wstring BookmarkEditorView::GetWindowTitle() const {
109 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOMARK_EDITOR_TITLE)); 109 return UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_TITLE));
110 } 110 }
111 111
112 bool BookmarkEditorView::Accept() { 112 bool BookmarkEditorView::Accept() {
113 if (!IsDialogButtonEnabled(MessageBoxFlags::DIALOGBUTTON_OK)) { 113 if (!IsDialogButtonEnabled(MessageBoxFlags::DIALOGBUTTON_OK)) {
114 if (details_.type != EditDetails::NEW_FOLDER) { 114 if (details_.type != EditDetails::NEW_FOLDER) {
115 // The url is invalid, focus the url field. 115 // The url is invalid, focus the url field.
116 url_tf_->SelectAll(); 116 url_tf_->SelectAll();
117 url_tf_->RequestFocus(); 117 url_tf_->RequestFocus();
118 } 118 }
119 return false; 119 return false;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 202
203 bool BookmarkEditorView::IsCommandIdChecked(int command_id) const { 203 bool BookmarkEditorView::IsCommandIdChecked(int command_id) const {
204 return false; 204 return false;
205 } 205 }
206 206
207 bool BookmarkEditorView::IsCommandIdEnabled(int command_id) const { 207 bool BookmarkEditorView::IsCommandIdEnabled(int command_id) const {
208 switch (command_id) { 208 switch (command_id) {
209 case IDS_EDIT: 209 case IDS_EDIT:
210 case IDS_DELETE: 210 case IDS_DELETE:
211 return !running_menu_for_root_; 211 return !running_menu_for_root_;
212 case IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM: 212 case IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM:
213 return true; 213 return true;
214 default: 214 default:
215 NOTREACHED(); 215 NOTREACHED();
216 return false; 216 return false;
217 } 217 }
218 } 218 }
219 219
220 bool BookmarkEditorView::GetAcceleratorForCommandId( 220 bool BookmarkEditorView::GetAcceleratorForCommandId(
221 int command_id, 221 int command_id,
222 ui::Accelerator* accelerator) { 222 ui::Accelerator* accelerator) {
(...skipping 13 matching lines...) Expand all
236 if (!b_node->empty() && 236 if (!b_node->empty() &&
237 !bookmark_utils::ConfirmDeleteBookmarkNode(b_node, 237 !bookmark_utils::ConfirmDeleteBookmarkNode(b_node,
238 GetWidget()->GetNativeWindow())) { 238 GetWidget()->GetNativeWindow())) {
239 // The folder is not empty and the user didn't confirm. 239 // The folder is not empty and the user didn't confirm.
240 return; 240 return;
241 } 241 }
242 deletes_.push_back(node->value); 242 deletes_.push_back(node->value);
243 } 243 }
244 tree_model_->Remove(node->parent(), node); 244 tree_model_->Remove(node->parent(), node);
245 } else { 245 } else {
246 DCHECK(command_id == IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM); 246 DCHECK(command_id == IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM);
247 NewFolder(); 247 NewFolder();
248 } 248 }
249 } 249 }
250 250
251 void BookmarkEditorView::Show(gfx::NativeWindow parent_hwnd) { 251 void BookmarkEditorView::Show(gfx::NativeWindow parent_hwnd) {
252 views::Widget::CreateWindowWithParent(this, parent_hwnd); 252 views::Widget::CreateWindowWithParent(this, parent_hwnd);
253 UserInputChanged(); 253 UserInputChanged();
254 if (show_tree_ && bb_model_->IsLoaded()) 254 if (show_tree_ && bb_model_->IsLoaded())
255 ExpandAndSelect(); 255 ExpandAndSelect();
256 GetWidget()->Show(); 256 GetWidget()->Show();
(...skipping 15 matching lines...) Expand all
272 if (!tree_view_->GetSelectedNode()) 272 if (!tree_view_->GetSelectedNode())
273 return; 273 return;
274 running_menu_for_root_ = 274 running_menu_for_root_ =
275 (tree_model_->GetParent(tree_view_->GetSelectedNode()) == 275 (tree_model_->GetParent(tree_view_->GetSelectedNode()) ==
276 tree_model_->GetRoot()); 276 tree_model_->GetRoot());
277 if (!context_menu_contents_.get()) { 277 if (!context_menu_contents_.get()) {
278 context_menu_contents_.reset(new ui::SimpleMenuModel(this)); 278 context_menu_contents_.reset(new ui::SimpleMenuModel(this));
279 context_menu_contents_->AddItemWithStringId(IDS_EDIT, IDS_EDIT); 279 context_menu_contents_->AddItemWithStringId(IDS_EDIT, IDS_EDIT);
280 context_menu_contents_->AddItemWithStringId(IDS_DELETE, IDS_DELETE); 280 context_menu_contents_->AddItemWithStringId(IDS_DELETE, IDS_DELETE);
281 context_menu_contents_->AddItemWithStringId( 281 context_menu_contents_->AddItemWithStringId(
282 IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM, 282 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM,
283 IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM); 283 IDS_BOOKMARK_EDITOR_NEW_FOLDER_MENU_ITEM);
284 context_menu_.reset(new views::Menu2(context_menu_contents_.get())); 284 context_menu_.reset(new views::Menu2(context_menu_contents_.get()));
285 } 285 }
286 context_menu_->RunContextMenuAt(p); 286 context_menu_->RunContextMenuAt(p);
287 } 287 }
288 288
289 void BookmarkEditorView::Init() { 289 void BookmarkEditorView::Init() {
290 bb_model_ = profile_->GetBookmarkModel(); 290 bb_model_ = profile_->GetBookmarkModel();
291 DCHECK(bb_model_); 291 DCHECK(bb_model_);
292 bb_model_->AddObserver(this); 292 bb_model_->AddObserver(this);
293 293
294 title_tf_.set_parent_owned(false); 294 title_tf_.set_parent_owned(false);
295 295
296 std::wstring title; 296 std::wstring title;
297 GURL url; 297 GURL url;
298 if (details_.type == EditDetails::EXISTING_NODE) { 298 if (details_.type == EditDetails::EXISTING_NODE) {
299 title = details_.existing_node->GetTitle(); 299 title = details_.existing_node->GetTitle();
300 url = details_.existing_node->url(); 300 url = details_.existing_node->url();
301 } else if (details_.type == EditDetails::NEW_FOLDER) { 301 } else if (details_.type == EditDetails::NEW_FOLDER) {
302 title = UTF16ToWide( 302 title = UTF16ToWide(
303 l10n_util::GetStringUTF16(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME)); 303 l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_NEW_FOLDER_NAME));
304 } else if (details_.type == EditDetails::NEW_URL) { 304 } else if (details_.type == EditDetails::NEW_URL) {
305 string16 title16; 305 string16 title16;
306 bookmark_utils::GetURLAndTitleToBookmarkFromCurrentTab(profile_, 306 bookmark_utils::GetURLAndTitleToBookmarkFromCurrentTab(profile_,
307 &url, &title16); 307 &url, &title16);
308 title = UTF16ToWide(title16); 308 title = UTF16ToWide(title16);
309 } 309 }
310 title_tf_.SetText(title); 310 title_tf_.SetText(title);
311 title_tf_.SetController(this); 311 title_tf_.SetController(this);
312 312
313 title_label_ = new views::Label( 313 title_label_ = new views::Label(
314 UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOMARK_EDITOR_NAME_LABEL))); 314 UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_NAME_LABEL)));
315 title_tf_.SetAccessibleName(WideToUTF16Hack(title_label_->GetText())); 315 title_tf_.SetAccessibleName(WideToUTF16Hack(title_label_->GetText()));
316 316
317 if (show_tree_) { 317 if (show_tree_) {
318 tree_view_ = new views::TreeView(); 318 tree_view_ = new views::TreeView();
319 tree_view_->set_lines_at_root(true); 319 tree_view_->set_lines_at_root(true);
320 new_folder_button_.reset(new views::NativeTextButton( 320 new_folder_button_.reset(new views::NativeTextButton(
321 this, 321 this,
322 UTF16ToWide(l10n_util::GetStringUTF16( 322 UTF16ToWide(l10n_util::GetStringUTF16(
323 IDS_BOOMARK_EDITOR_NEW_FOLDER_BUTTON)))); 323 IDS_BOOKMARK_EDITOR_NEW_FOLDER_BUTTON))));
324 new_folder_button_->set_parent_owned(false); 324 new_folder_button_->set_parent_owned(false);
325 tree_view_->set_context_menu_controller(this); 325 tree_view_->set_context_menu_controller(this);
326 326
327 tree_view_->SetRootShown(false); 327 tree_view_->SetRootShown(false);
328 new_folder_button_->SetEnabled(false); 328 new_folder_button_->SetEnabled(false);
329 new_folder_button_->set_id(kNewFolderButtonID); 329 new_folder_button_->set_id(kNewFolderButtonID);
330 } 330 }
331 331
332 // Yummy layout code. 332 // Yummy layout code.
333 GridLayout* layout = GridLayout::CreatePanel(this); 333 GridLayout* layout = GridLayout::CreatePanel(this);
(...skipping 25 matching lines...) Expand all
359 GridLayout::USE_PREF, 0, 0); 359 GridLayout::USE_PREF, 0, 0);
360 column_set->LinkColumnSizes(0, 2, 4, -1); 360 column_set->LinkColumnSizes(0, 2, 4, -1);
361 361
362 layout->StartRow(0, labels_column_set_id); 362 layout->StartRow(0, labels_column_set_id);
363 363
364 layout->AddView(title_label_); 364 layout->AddView(title_label_);
365 layout->AddView(&title_tf_); 365 layout->AddView(&title_tf_);
366 366
367 if (details_.type != EditDetails::NEW_FOLDER) { 367 if (details_.type != EditDetails::NEW_FOLDER) {
368 url_label_ = new views::Label( 368 url_label_ = new views::Label(
369 UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOMARK_EDITOR_URL_LABEL))); 369 UTF16ToWide(l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_URL_LABEL)));
370 370
371 std::string languages = 371 std::string languages =
372 profile_ ? profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) 372 profile_ ? profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)
373 : std::string(); 373 : std::string();
374 // Because this gets parsed by FixupURL(), it's safe to omit the scheme or 374 // Because this gets parsed by FixupURL(), it's safe to omit the scheme or
375 // trailing slash, and unescape most characters, but we need to not drop any 375 // trailing slash, and unescape most characters, but we need to not drop any
376 // username/password, or unescape anything that changes the meaning. 376 // username/password, or unescape anything that changes the meaning.
377 string16 url_text = net::FormatUrl(url, languages, 377 string16 url_text = net::FormatUrl(url, languages,
378 net::kFormatUrlOmitAll & ~net::kFormatUrlOmitUsernamePassword, 378 net::kFormatUrlOmitAll & ~net::kFormatUrlOmitUsernamePassword,
379 UnescapeRule::SPACES, NULL, NULL, NULL); 379 UnescapeRule::SPACES, NULL, NULL, NULL);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 NOTREACHED(); 489 NOTREACHED();
490 return; 490 return;
491 } 491 }
492 492
493 tree_view_->StartEditing(AddNewFolder(parent)); 493 tree_view_->StartEditing(AddNewFolder(parent));
494 } 494 }
495 495
496 BookmarkEditorView::EditorNode* BookmarkEditorView::AddNewFolder( 496 BookmarkEditorView::EditorNode* BookmarkEditorView::AddNewFolder(
497 EditorNode* parent) { 497 EditorNode* parent) {
498 EditorNode* new_node = new EditorNode( 498 EditorNode* new_node = new EditorNode(
499 l10n_util::GetStringUTF16(IDS_BOOMARK_EDITOR_NEW_FOLDER_NAME), 0); 499 l10n_util::GetStringUTF16(IDS_BOOKMARK_EDITOR_NEW_FOLDER_NAME), 0);
500 // |new_node| is now owned by |parent|. 500 // |new_node| is now owned by |parent|.
501 tree_model_->Add(parent, new_node, parent->child_count()); 501 tree_model_->Add(parent, new_node, parent->child_count());
502 return new_node; 502 return new_node;
503 } 503 }
504 504
505 void BookmarkEditorView::ExpandAndSelect() { 505 void BookmarkEditorView::ExpandAndSelect() {
506 BookmarkExpandedStateTracker::Nodes expanded_nodes = 506 BookmarkExpandedStateTracker::Nodes expanded_nodes =
507 bb_model_->expanded_state_tracker()->GetExpandedNodes(); 507 bb_model_->expanded_state_tracker()->GetExpandedNodes();
508 for (BookmarkExpandedStateTracker::Nodes::const_iterator i = 508 for (BookmarkExpandedStateTracker::Nodes::const_iterator i =
509 expanded_nodes.begin(); i != expanded_nodes.end(); ++i) { 509 expanded_nodes.begin(); i != expanded_nodes.end(); ++i) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 EditorNode* editor_node, 647 EditorNode* editor_node,
648 BookmarkExpandedStateTracker::Nodes* expanded_nodes) { 648 BookmarkExpandedStateTracker::Nodes* expanded_nodes) {
649 if (!tree_view_->IsExpanded(editor_node)) 649 if (!tree_view_->IsExpanded(editor_node))
650 return; 650 return;
651 651
652 if (editor_node->value != 0) // The root is 0 652 if (editor_node->value != 0) // The root is 0
653 expanded_nodes->insert(bb_model_->GetNodeByID(editor_node->value)); 653 expanded_nodes->insert(bb_model_->GetNodeByID(editor_node->value));
654 for (int i = 0; i < editor_node->child_count(); ++i) 654 for (int i = 0; i < editor_node->child_count(); ++i)
655 UpdateExpandedNodes(editor_node->GetChild(i), expanded_nodes); 655 UpdateExpandedNodes(editor_node->GetChild(i), expanded_nodes);
656 } 656 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698