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_factory.h" | 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
15 #include "chrome/browser/history/history_service.h" | 15 #include "chrome/browser/history/history_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 17 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
18 #include "chrome/browser/ui/views/constrained_window_views.h" | 18 #include "chrome/browser/ui/views/constrained_window_views.h" |
19 #include "chrome/common/net/url_fixer_upper.h" | |
20 #include "components/bookmarks/browser/bookmark_model.h" | 19 #include "components/bookmarks/browser/bookmark_model.h" |
21 #include "components/bookmarks/browser/bookmark_utils.h" | 20 #include "components/bookmarks/browser/bookmark_utils.h" |
| 21 #include "components/url_fixer/url_fixer.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/accessibility/ax_view_state.h" | 26 #include "ui/accessibility/ax_view_state.h" |
27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
28 #include "ui/events/event.h" | 28 #include "ui/events/event.h" |
29 #include "ui/views/background.h" | 29 #include "ui/views/background.h" |
30 #include "ui/views/controls/button/label_button.h" | 30 #include "ui/views/controls/button/label_button.h" |
31 #include "ui/views/controls/label.h" | 31 #include "ui/views/controls/label.h" |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 | 426 |
427 context_menu_runner_.reset(); | 427 context_menu_runner_.reset(); |
428 | 428 |
429 if (parent()) | 429 if (parent()) |
430 ExpandAndSelect(); | 430 ExpandAndSelect(); |
431 } | 431 } |
432 | 432 |
433 GURL BookmarkEditorView::GetInputURL() const { | 433 GURL BookmarkEditorView::GetInputURL() const { |
434 if (details_.GetNodeType() == BookmarkNode::FOLDER) | 434 if (details_.GetNodeType() == BookmarkNode::FOLDER) |
435 return GURL(); | 435 return GURL(); |
436 return URLFixerUpper::FixupURL( | 436 return url_fixer::FixupURL(base::UTF16ToUTF8(url_tf_->text()), std::string()); |
437 base::UTF16ToUTF8(url_tf_->text()), std::string()); | |
438 } | 437 } |
439 | 438 |
440 void BookmarkEditorView::UserInputChanged() { | 439 void BookmarkEditorView::UserInputChanged() { |
441 if (details_.GetNodeType() != BookmarkNode::FOLDER) { | 440 if (details_.GetNodeType() != BookmarkNode::FOLDER) { |
442 const GURL url(GetInputURL()); | 441 const GURL url(GetInputURL()); |
443 if (!url.is_valid()) | 442 if (!url.is_valid()) |
444 url_tf_->SetBackgroundColor(kErrorColor); | 443 url_tf_->SetBackgroundColor(kErrorColor); |
445 else | 444 else |
446 url_tf_->UseDefaultBackgroundColor(); | 445 url_tf_->UseDefaultBackgroundColor(); |
447 } | 446 } |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 } | 636 } |
638 return context_menu_model_.get(); | 637 return context_menu_model_.get(); |
639 } | 638 } |
640 | 639 |
641 void BookmarkEditorView::EditorTreeModel::SetTitle( | 640 void BookmarkEditorView::EditorTreeModel::SetTitle( |
642 ui::TreeModelNode* node, | 641 ui::TreeModelNode* node, |
643 const base::string16& title) { | 642 const base::string16& title) { |
644 if (!title.empty()) | 643 if (!title.empty()) |
645 ui::TreeNodeModel<EditorNode>::SetTitle(node, title); | 644 ui::TreeNodeModel<EditorNode>::SetTitle(node, title); |
646 } | 645 } |
OLD | NEW |