OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/bookmark_editor_view.h" | 5 #include "chrome/browser/views/bookmark_editor_view.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "chrome/browser/bookmarks/bookmark_utils.h" | 11 #include "chrome/browser/bookmarks/bookmark_utils.h" |
12 #include "chrome/browser/history/history.h" | 12 #include "chrome/browser/history/history.h" |
13 #include "chrome/browser/profile.h" | 13 #include "chrome/browser/profile.h" |
14 #include "chrome/browser/net/url_fixer_upper.h" | 14 #include "chrome/browser/net/url_fixer_upper.h" |
| 15 #include "chrome/common/pref_names.h" |
| 16 #include "chrome/common/pref_service.h" |
15 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
16 #include "grit/chromium_strings.h" | 18 #include "grit/chromium_strings.h" |
17 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
18 #include "grit/locale_settings.h" | 20 #include "grit/locale_settings.h" |
| 21 #include "net/base/net_util.h" |
19 #include "views/background.h" | 22 #include "views/background.h" |
20 #include "views/focus/focus_manager.h" | 23 #include "views/focus/focus_manager.h" |
21 #include "views/grid_layout.h" | 24 #include "views/grid_layout.h" |
22 #include "views/controls/button/native_button.h" | 25 #include "views/controls/button/native_button.h" |
23 #include "views/controls/label.h" | 26 #include "views/controls/label.h" |
24 #include "views/standard_layout.h" | 27 #include "views/standard_layout.h" |
25 #include "views/widget/widget.h" | 28 #include "views/widget/widget.h" |
26 #include "views/window/window.h" | 29 #include "views/window/window.h" |
27 | 30 |
28 using views::Button; | 31 using views::Button; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 bb_model_ = profile_->GetBookmarkModel(); | 242 bb_model_ = profile_->GetBookmarkModel(); |
240 DCHECK(bb_model_); | 243 DCHECK(bb_model_); |
241 bb_model_->AddObserver(this); | 244 bb_model_->AddObserver(this); |
242 | 245 |
243 url_tf_.SetParentOwned(false); | 246 url_tf_.SetParentOwned(false); |
244 title_tf_.SetParentOwned(false); | 247 title_tf_.SetParentOwned(false); |
245 | 248 |
246 title_tf_.SetText(node_ ? node_->GetTitle() : std::wstring()); | 249 title_tf_.SetText(node_ ? node_->GetTitle() : std::wstring()); |
247 title_tf_.SetController(this); | 250 title_tf_.SetController(this); |
248 | 251 |
249 url_tf_.SetText(node_ ? UTF8ToWide(node_->GetURL().spec()) : std::wstring()); | 252 std::wstring url_text; |
| 253 if (node_) { |
| 254 std::wstring languages = profile_ |
| 255 ? profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) |
| 256 : std::wstring(); |
| 257 // The following URL is user-editable. We specify omit_username_password= |
| 258 // false and unescape=false to show the original URL except IDN. |
| 259 url_text = |
| 260 net::FormatUrl(node_->GetURL(), languages, false, false, NULL, NULL); |
| 261 } |
| 262 url_tf_.SetText(url_text); |
250 url_tf_.SetController(this); | 263 url_tf_.SetController(this); |
251 | 264 |
252 if (show_tree_) { | 265 if (show_tree_) { |
253 tree_view_ = new views::TreeView(); | 266 tree_view_ = new views::TreeView(); |
254 new_group_button_.reset(new views::NativeButton( | 267 new_group_button_.reset(new views::NativeButton( |
255 this, l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_BUTTON))); | 268 this, l10n_util::GetString(IDS_BOOMARK_EDITOR_NEW_FOLDER_BUTTON))); |
256 new_group_button_->SetParentOwned(false); | 269 new_group_button_->SetParentOwned(false); |
257 tree_view_->SetContextMenuController(this); | 270 tree_view_->SetContextMenuController(this); |
258 | 271 |
259 tree_view_->SetRootShown(false); | 272 tree_view_->SetRootShown(false); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 break; | 538 break; |
526 } | 539 } |
527 } | 540 } |
528 DCHECK(child_bb_node); | 541 DCHECK(child_bb_node); |
529 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle()); | 542 bb_model_->SetTitle(child_bb_node, child_b_node->GetTitle()); |
530 } | 543 } |
531 ApplyNameChangesAndCreateNewGroups(child_bb_node, child_b_node, | 544 ApplyNameChangesAndCreateNewGroups(child_bb_node, child_b_node, |
532 parent_b_node, parent_bb_node); | 545 parent_b_node, parent_bb_node); |
533 } | 546 } |
534 } | 547 } |
OLD | NEW |