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/location_bar/location_bar_view.h" | 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
| 10 #include "base/feature_list.h" |
10 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
11 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
14 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
15 #include "chrome/app/vector_icons/vector_icons.h" | 16 #include "chrome/app/vector_icons/vector_icons.h" |
16 #include "chrome/browser/command_updater.h" | 17 #include "chrome/browser/command_updater.h" |
17 #include "chrome/browser/defaults.h" | 18 #include "chrome/browser/defaults.h" |
18 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" | 19 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" |
19 #include "chrome/browser/extensions/tab_helper.h" | 20 #include "chrome/browser/extensions/tab_helper.h" |
(...skipping 24 matching lines...) Expand all Loading... |
44 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" | 45 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
45 #include "chrome/browser/ui/views/location_bar/zoom_view.h" | 46 #include "chrome/browser/ui/views/location_bar/zoom_view.h" |
46 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" | 47 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" |
47 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" | 48 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" |
48 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" | 49 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" |
49 #include "chrome/browser/ui/views/translate/translate_icon_view.h" | 50 #include "chrome/browser/ui/views/translate/translate_icon_view.h" |
50 #include "chrome/grit/chromium_strings.h" | 51 #include "chrome/grit/chromium_strings.h" |
51 #include "chrome/grit/generated_resources.h" | 52 #include "chrome/grit/generated_resources.h" |
52 #include "components/bookmarks/common/bookmark_pref_names.h" | 53 #include "components/bookmarks/common/bookmark_pref_names.h" |
53 #include "components/favicon/content/content_favicon_driver.h" | 54 #include "components/favicon/content/content_favicon_driver.h" |
| 55 #include "components/omnibox/browser/omnibox_field_trial.h" |
54 #include "components/omnibox/browser/omnibox_popup_model.h" | 56 #include "components/omnibox/browser/omnibox_popup_model.h" |
55 #include "components/omnibox/browser/omnibox_popup_view.h" | 57 #include "components/omnibox/browser/omnibox_popup_view.h" |
56 #include "components/prefs/pref_service.h" | 58 #include "components/prefs/pref_service.h" |
57 #include "components/search_engines/template_url.h" | 59 #include "components/search_engines/template_url.h" |
58 #include "components/search_engines/template_url_service.h" | 60 #include "components/search_engines/template_url_service.h" |
59 #include "components/toolbar/toolbar_model.h" | 61 #include "components/toolbar/toolbar_model.h" |
60 #include "components/translate/core/browser/language_state.h" | 62 #include "components/translate/core/browser/language_state.h" |
61 #include "components/variations/variations_associated_data.h" | 63 #include "components/variations/variations_associated_data.h" |
62 #include "components/zoom/zoom_controller.h" | 64 #include "components/zoom/zoom_controller.h" |
63 #include "components/zoom/zoom_event_manager.h" | 65 #include "components/zoom/zoom_event_manager.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 return this; | 365 return this; |
364 return location_icon_view()->GetImageView(); | 366 return location_icon_view()->GetImageView(); |
365 } | 367 } |
366 | 368 |
367 void LocationBarView::GetOmniboxPopupPositioningInfo( | 369 void LocationBarView::GetOmniboxPopupPositioningInfo( |
368 gfx::Point* top_left_screen_coord, | 370 gfx::Point* top_left_screen_coord, |
369 int* popup_width, | 371 int* popup_width, |
370 int* left_margin, | 372 int* left_margin, |
371 int* right_margin, | 373 int* right_margin, |
372 int top_edge_overlap) { | 374 int top_edge_overlap) { |
373 *top_left_screen_coord = gfx::Point(0, parent()->height() - top_edge_overlap); | 375 // The popup contents are always sized matching the location bar size. |
| 376 const int popup_contents_left = x(); |
| 377 const int popup_contents_right = bounds().right(); |
| 378 |
| 379 // The popup itself may either be the same width as the contents, or as wide |
| 380 // as the toolbar. |
| 381 bool narrow_popup = |
| 382 base::FeatureList::IsEnabled(omnibox::kUIExperimentNarrowDropdown); |
| 383 const int popup_left = narrow_popup ? popup_contents_left : 0; |
| 384 const int popup_right = |
| 385 narrow_popup ? popup_contents_right : parent()->width(); |
| 386 |
| 387 *top_left_screen_coord = |
| 388 gfx::Point(popup_left, parent()->height() - top_edge_overlap); |
374 views::View::ConvertPointToScreen(parent(), top_left_screen_coord); | 389 views::View::ConvertPointToScreen(parent(), top_left_screen_coord); |
375 | 390 |
376 *popup_width = parent()->width(); | 391 *popup_width = popup_right - popup_left; |
377 *left_margin = x(); | 392 *left_margin = popup_contents_left - popup_left; |
378 *right_margin = *popup_width - bounds().right(); | 393 *right_margin = popup_right - popup_contents_right; |
379 } | 394 } |
380 | 395 |
381 //////////////////////////////////////////////////////////////////////////////// | 396 //////////////////////////////////////////////////////////////////////////////// |
382 // LocationBarView, public LocationBar implementation: | 397 // LocationBarView, public LocationBar implementation: |
383 | 398 |
384 void LocationBarView::FocusLocation(bool select_all) { | 399 void LocationBarView::FocusLocation(bool select_all) { |
385 omnibox_view_->SetFocus(); | 400 omnibox_view_->SetFocus(); |
386 if (select_all) | 401 if (select_all) |
387 omnibox_view_->SelectAll(true); | 402 omnibox_view_->SelectAll(true); |
388 } | 403 } |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 // LocationBarView, private TemplateURLServiceObserver implementation: | 1087 // LocationBarView, private TemplateURLServiceObserver implementation: |
1073 | 1088 |
1074 void LocationBarView::OnTemplateURLServiceChanged() { | 1089 void LocationBarView::OnTemplateURLServiceChanged() { |
1075 template_url_service_->RemoveObserver(this); | 1090 template_url_service_->RemoveObserver(this); |
1076 template_url_service_ = nullptr; | 1091 template_url_service_ = nullptr; |
1077 // If the browser is no longer active, let's not show the info bubble, as this | 1092 // If the browser is no longer active, let's not show the info bubble, as this |
1078 // would make the browser the active window again. | 1093 // would make the browser the active window again. |
1079 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1094 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
1080 ShowFirstRunBubble(); | 1095 ShowFirstRunBubble(); |
1081 } | 1096 } |
OLD | NEW |