| 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/omnibox/omnibox_view_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
| 6 | 6 |
| 7 #include "base/property_bag.h" | 7 #include "base/property_bag.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" |
| 11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
| 12 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 12 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_match.h" | 13 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 14 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 15 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
| 16 #include "chrome/browser/command_updater.h" | 16 #include "chrome/browser/command_updater.h" |
| 17 #include "chrome/browser/ui/view_ids.h" | 17 #include "chrome/browser/ui/view_ids.h" |
| 18 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.
h" | 18 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.
h" |
| 19 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 19 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | |
| 21 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 22 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 23 #include "grit/app_locale_settings.h" | 22 #include "grit/app_locale_settings.h" |
| 24 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 25 #include "net/base/escape.h" | 24 #include "net/base/escape.h" |
| 26 #include "third_party/skia/include/core/SkColor.h" | 25 #include "third_party/skia/include/core/SkColor.h" |
| 27 #include "ui/base/accessibility/accessible_view_state.h" | 26 #include "ui/base/accessibility/accessible_view_state.h" |
| 28 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 27 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 29 #include "ui/base/dragdrop/drag_drop_types.h" | 28 #include "ui/base/dragdrop/drag_drop_types.h" |
| 30 #include "ui/base/dragdrop/os_exchange_data.h" | 29 #include "ui/base/dragdrop/os_exchange_data.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 textfield_->font(), this, model_.get(), location_bar_view_)); | 214 textfield_->font(), this, model_.get(), location_bar_view_)); |
| 216 | 215 |
| 217 const int vertical_margin = !popup_window_mode_ ? | 216 const int vertical_margin = !popup_window_mode_ ? |
| 218 kAutocompleteVerticalMargin : kAutocompleteVerticalMarginInPopup; | 217 kAutocompleteVerticalMargin : kAutocompleteVerticalMarginInPopup; |
| 219 set_border(views::Border::CreateEmptyBorder(vertical_margin, 0, | 218 set_border(views::Border::CreateEmptyBorder(vertical_margin, 0, |
| 220 vertical_margin, 0)); | 219 vertical_margin, 0)); |
| 221 #if defined(OS_CHROMEOS) | 220 #if defined(OS_CHROMEOS) |
| 222 chromeos::input_method::InputMethodManager::GetInstance()-> | 221 chromeos::input_method::InputMethodManager::GetInstance()-> |
| 223 AddCandidateWindowObserver(this); | 222 AddCandidateWindowObserver(this); |
| 224 #endif | 223 #endif |
| 225 | |
| 226 // Manually invoke SetBaseColor() because TOOLKIT_VIEWS doesn't observe | |
| 227 // themes. | |
| 228 SetBaseColor(); | |
| 229 } | |
| 230 | |
| 231 void OmniboxViewViews::SetBaseColor() { | |
| 232 // TODO(oshima): Implement style change. | |
| 233 NOTIMPLEMENTED(); | |
| 234 } | 224 } |
| 235 | 225 |
| 236 bool OmniboxViewViews::HandleAfterKeyEvent(const views::KeyEvent& event, | 226 bool OmniboxViewViews::HandleAfterKeyEvent(const views::KeyEvent& event, |
| 237 bool handled) { | 227 bool handled) { |
| 238 if (event.key_code() == ui::VKEY_RETURN) { | 228 if (event.key_code() == ui::VKEY_RETURN) { |
| 239 bool alt_held = event.IsAltDown(); | 229 bool alt_held = event.IsAltDown(); |
| 240 model_->AcceptInput(alt_held ? NEW_FOREGROUND_TAB : CURRENT_TAB, false); | 230 model_->AcceptInput(alt_held ? NEW_FOREGROUND_TAB : CURRENT_TAB, false); |
| 241 handled = true; | 231 handled = true; |
| 242 } else if (!handled && event.key_code() == ui::VKEY_ESCAPE) { | 232 } else if (!handled && event.key_code() == ui::VKEY_ESCAPE) { |
| 243 // We can handle the Escape key if textfield did not handle it. | 233 // We can handle the Escape key if textfield did not handle it. |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 AddChildView(textfield_); | 649 AddChildView(textfield_); |
| 660 return this; | 650 return this; |
| 661 } | 651 } |
| 662 | 652 |
| 663 int OmniboxViewViews::OnPerformDrop(const views::DropTargetEvent& event) { | 653 int OmniboxViewViews::OnPerformDrop(const views::DropTargetEvent& event) { |
| 664 NOTIMPLEMENTED(); | 654 NOTIMPLEMENTED(); |
| 665 return ui::DragDropTypes::DRAG_NONE; | 655 return ui::DragDropTypes::DRAG_NONE; |
| 666 } | 656 } |
| 667 | 657 |
| 668 //////////////////////////////////////////////////////////////////////////////// | 658 //////////////////////////////////////////////////////////////////////////////// |
| 669 // OmniboxViewViews, content::NotificationObserver implementation: | |
| 670 | |
| 671 void OmniboxViewViews::Observe(int type, | |
| 672 const content::NotificationSource& source, | |
| 673 const content::NotificationDetails& details) { | |
| 674 DCHECK(type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED); | |
| 675 SetBaseColor(); | |
| 676 } | |
| 677 | |
| 678 //////////////////////////////////////////////////////////////////////////////// | |
| 679 // OmniboxViewViews, views::TextfieldController implementation: | 659 // OmniboxViewViews, views::TextfieldController implementation: |
| 680 | 660 |
| 681 void OmniboxViewViews::ContentsChanged(views::Textfield* sender, | 661 void OmniboxViewViews::ContentsChanged(views::Textfield* sender, |
| 682 const string16& new_contents) { | 662 const string16& new_contents) { |
| 683 } | 663 } |
| 684 | 664 |
| 685 bool OmniboxViewViews::HandleKeyEvent(views::Textfield* textfield, | 665 bool OmniboxViewViews::HandleKeyEvent(views::Textfield* textfield, |
| 686 const views::KeyEvent& event) { | 666 const views::KeyEvent& event) { |
| 687 delete_at_end_pressed_ = false; | 667 delete_at_end_pressed_ = false; |
| 688 | 668 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller, | 833 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller, |
| 854 toolbar_model, | 834 toolbar_model, |
| 855 profile, | 835 profile, |
| 856 command_updater, | 836 command_updater, |
| 857 popup_window_mode, | 837 popup_window_mode, |
| 858 location_bar); | 838 location_bar); |
| 859 omnibox_view->Init(); | 839 omnibox_view->Init(); |
| 860 return omnibox_view; | 840 return omnibox_view; |
| 861 } | 841 } |
| 862 #endif | 842 #endif |
| OLD | NEW |