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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 2914163004: Omnibox UI Experiments: Make suggestions dropdown match omnibox width. (Closed)
Patch Set: fix Created 3 years, 6 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
« no previous file with comments | « chrome/browser/flag_descriptions.cc ('k') | components/omnibox/browser/omnibox_field_trial.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/browser/command_updater.h" 16 #include "chrome/browser/command_updater.h"
16 #include "chrome/browser/defaults.h" 17 #include "chrome/browser/defaults.h"
17 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h" 18 #include "chrome/browser/extensions/api/omnibox/omnibox_api.h"
18 #include "chrome/browser/extensions/tab_helper.h" 19 #include "chrome/browser/extensions/tab_helper.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
(...skipping 22 matching lines...) Expand all
42 #include "chrome/browser/ui/views/location_bar/star_view.h" 43 #include "chrome/browser/ui/views/location_bar/star_view.h"
43 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" 44 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
44 #include "chrome/browser/ui/views/location_bar/zoom_view.h" 45 #include "chrome/browser/ui/views/location_bar/zoom_view.h"
45 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h" 46 #include "chrome/browser/ui/views/passwords/manage_passwords_bubble_view.h"
46 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h" 47 #include "chrome/browser/ui/views/passwords/manage_passwords_icon_views.h"
47 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" 48 #include "chrome/browser/ui/views/translate/translate_bubble_view.h"
48 #include "chrome/browser/ui/views/translate/translate_icon_view.h" 49 #include "chrome/browser/ui/views/translate/translate_icon_view.h"
49 #include "chrome/grit/chromium_strings.h" 50 #include "chrome/grit/chromium_strings.h"
50 #include "components/bookmarks/common/bookmark_pref_names.h" 51 #include "components/bookmarks/common/bookmark_pref_names.h"
51 #include "components/favicon/content/content_favicon_driver.h" 52 #include "components/favicon/content/content_favicon_driver.h"
53 #include "components/omnibox/browser/omnibox_field_trial.h"
52 #include "components/omnibox/browser/omnibox_popup_model.h" 54 #include "components/omnibox/browser/omnibox_popup_model.h"
53 #include "components/omnibox/browser/omnibox_popup_view.h" 55 #include "components/omnibox/browser/omnibox_popup_view.h"
54 #include "components/prefs/pref_service.h" 56 #include "components/prefs/pref_service.h"
55 #include "components/search_engines/template_url.h" 57 #include "components/search_engines/template_url.h"
56 #include "components/search_engines/template_url_service.h" 58 #include "components/search_engines/template_url_service.h"
57 #include "components/toolbar/toolbar_model.h" 59 #include "components/toolbar/toolbar_model.h"
58 #include "components/translate/core/browser/language_state.h" 60 #include "components/translate/core/browser/language_state.h"
59 #include "components/variations/variations_associated_data.h" 61 #include "components/variations/variations_associated_data.h"
60 #include "components/zoom/zoom_controller.h" 62 #include "components/zoom/zoom_controller.h"
61 #include "components/zoom/zoom_event_manager.h" 63 #include "components/zoom/zoom_event_manager.h"
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 return this; 364 return this;
363 return location_icon_view()->GetImageView(); 365 return location_icon_view()->GetImageView();
364 } 366 }
365 367
366 void LocationBarView::GetOmniboxPopupPositioningInfo( 368 void LocationBarView::GetOmniboxPopupPositioningInfo(
367 gfx::Point* top_left_screen_coord, 369 gfx::Point* top_left_screen_coord,
368 int* popup_width, 370 int* popup_width,
369 int* left_margin, 371 int* left_margin,
370 int* right_margin, 372 int* right_margin,
371 int top_edge_overlap) { 373 int top_edge_overlap) {
372 *top_left_screen_coord = gfx::Point(0, parent()->height() - top_edge_overlap); 374 bool narrow_popup =
375 base::FeatureList::IsEnabled(omnibox::kUIExperimentNarrowDropdown);
376
377 *top_left_screen_coord =
378 gfx::Point(narrow_popup ? x() : 0, parent()->height() - top_edge_overlap);
373 views::View::ConvertPointToScreen(parent(), top_left_screen_coord); 379 views::View::ConvertPointToScreen(parent(), top_left_screen_coord);
374 380
375 *popup_width = parent()->width(); 381 *popup_width = narrow_popup ? width() : parent()->width();
376 *left_margin = x(); 382 *left_margin = narrow_popup ? 0 : x();
377 *right_margin = *popup_width - bounds().right(); 383 *right_margin = narrow_popup ? 0 : *popup_width - bounds().right();
Peter Kasting 2017/06/09 02:17:53 Nit: Reading this, it felt a bit cryptic and error
tommycli 2017/06/09 16:26:51 Done.
378 } 384 }
379 385
380 //////////////////////////////////////////////////////////////////////////////// 386 ////////////////////////////////////////////////////////////////////////////////
381 // LocationBarView, public LocationBar implementation: 387 // LocationBarView, public LocationBar implementation:
382 388
383 void LocationBarView::FocusLocation(bool select_all) { 389 void LocationBarView::FocusLocation(bool select_all) {
384 omnibox_view_->SetFocus(); 390 omnibox_view_->SetFocus();
385 if (select_all) 391 if (select_all)
386 omnibox_view_->SelectAll(true); 392 omnibox_view_->SelectAll(true);
387 } 393 }
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 // LocationBarView, private TemplateURLServiceObserver implementation: 1049 // LocationBarView, private TemplateURLServiceObserver implementation:
1044 1050
1045 void LocationBarView::OnTemplateURLServiceChanged() { 1051 void LocationBarView::OnTemplateURLServiceChanged() {
1046 template_url_service_->RemoveObserver(this); 1052 template_url_service_->RemoveObserver(this);
1047 template_url_service_ = nullptr; 1053 template_url_service_ = nullptr;
1048 // If the browser is no longer active, let's not show the info bubble, as this 1054 // If the browser is no longer active, let's not show the info bubble, as this
1049 // would make the browser the active window again. 1055 // would make the browser the active window again.
1050 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) 1056 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive())
1051 ShowFirstRunBubble(); 1057 ShowFirstRunBubble();
1052 } 1058 }
OLDNEW
« no previous file with comments | « chrome/browser/flag_descriptions.cc ('k') | components/omnibox/browser/omnibox_field_trial.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698