| 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/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE, | 466 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE, |
| 467 item_padding, item_padding); | 467 item_padding, item_padding); |
| 468 | 468 |
| 469 const base::string16 keyword(omnibox_view_->model()->keyword()); | 469 const base::string16 keyword(omnibox_view_->model()->keyword()); |
| 470 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want | 470 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want |
| 471 // to position our child views in this case, because other things may be | 471 // to position our child views in this case, because other things may be |
| 472 // positioned relative to them (e.g. the "bookmark added" bubble if the user | 472 // positioned relative to them (e.g. the "bookmark added" bubble if the user |
| 473 // hits ctrl-d). | 473 // hits ctrl-d). |
| 474 const int vertical_padding = GetTotalVerticalPadding(); | 474 const int vertical_padding = GetTotalVerticalPadding(); |
| 475 const int location_height = std::max(height() - (vertical_padding * 2), 0); | 475 const int location_height = std::max(height() - (vertical_padding * 2), 0); |
| 476 // The largest fraction of the omnibox that can be taken by the EV or search |
| 477 // label/chip. |
| 478 const double kLeadingDecorationMaxFraction = 0.5; |
| 476 | 479 |
| 477 location_icon_view_->SetLabel(base::string16()); | 480 location_icon_view_->SetLabel(base::string16()); |
| 478 if (ShouldShowKeywordBubble()) { | 481 if (ShouldShowKeywordBubble()) { |
| 479 leading_decorations.AddDecoration(vertical_padding, location_height, true, | 482 leading_decorations.AddDecoration( |
| 480 0, item_padding, item_padding, | 483 vertical_padding, location_height, false, kLeadingDecorationMaxFraction, |
| 481 selected_keyword_view_); | 484 item_padding, item_padding, selected_keyword_view_); |
| 482 if (selected_keyword_view_->keyword() != keyword) { | 485 if (selected_keyword_view_->keyword() != keyword) { |
| 483 selected_keyword_view_->SetKeyword(keyword); | 486 selected_keyword_view_->SetKeyword(keyword); |
| 484 const TemplateURL* template_url = | 487 const TemplateURL* template_url = |
| 485 TemplateURLServiceFactory::GetForProfile(profile())-> | 488 TemplateURLServiceFactory::GetForProfile(profile())-> |
| 486 GetTemplateURLForKeyword(keyword); | 489 GetTemplateURLForKeyword(keyword); |
| 487 if (template_url && | 490 if (template_url && |
| 488 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) { | 491 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) { |
| 489 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> | 492 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> |
| 490 GetOmniboxIcon(template_url->GetExtensionId()); | 493 GetOmniboxIcon(template_url->GetExtensionId()); |
| 491 selected_keyword_view_->SetImage(image.AsImageSkia()); | 494 selected_keyword_view_->SetImage(image.AsImageSkia()); |
| 492 } else { | 495 } else { |
| 493 selected_keyword_view_->ResetImage(); | 496 selected_keyword_view_->ResetImage(); |
| 494 } | 497 } |
| 495 } | 498 } |
| 496 } else if (ShouldShowLocationIconText()) { | 499 } else if (ShouldShowLocationIconText()) { |
| 497 location_icon_view_->SetLabel(GetLocationIconText()); | 500 location_icon_view_->SetLabel(GetLocationIconText()); |
| 498 // The largest fraction of the omnibox that can be taken by the EV bubble. | 501 leading_decorations.AddDecoration( |
| 499 const double kMaxBubbleFraction = 0.5; | 502 vertical_padding, location_height, false, kLeadingDecorationMaxFraction, |
| 500 leading_decorations.AddDecoration(vertical_padding, location_height, false, | 503 item_padding, item_padding, location_icon_view_); |
| 501 kMaxBubbleFraction, item_padding, | |
| 502 item_padding, location_icon_view_); | |
| 503 } else { | 504 } else { |
| 504 leading_decorations.AddDecoration(vertical_padding, location_height, | 505 leading_decorations.AddDecoration(vertical_padding, location_height, |
| 505 location_icon_view_); | 506 location_icon_view_); |
| 506 } | 507 } |
| 507 | 508 |
| 508 if (star_view_->visible()) { | 509 if (star_view_->visible()) { |
| 509 trailing_decorations.AddDecoration(vertical_padding, location_height, | 510 trailing_decorations.AddDecoration(vertical_padding, location_height, |
| 510 star_view_); | 511 star_view_); |
| 511 } | 512 } |
| 512 if (translate_icon_view_->visible()) { | 513 if (translate_icon_view_->visible()) { |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 // LocationBarView, private TemplateURLServiceObserver implementation: | 1067 // LocationBarView, private TemplateURLServiceObserver implementation: |
| 1067 | 1068 |
| 1068 void LocationBarView::OnTemplateURLServiceChanged() { | 1069 void LocationBarView::OnTemplateURLServiceChanged() { |
| 1069 template_url_service_->RemoveObserver(this); | 1070 template_url_service_->RemoveObserver(this); |
| 1070 template_url_service_ = nullptr; | 1071 template_url_service_ = nullptr; |
| 1071 // If the browser is no longer active, let's not show the info bubble, as this | 1072 // If the browser is no longer active, let's not show the info bubble, as this |
| 1072 // would make the browser the active window again. | 1073 // would make the browser the active window again. |
| 1073 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1074 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
| 1074 ShowFirstRunBubble(); | 1075 ShowFirstRunBubble(); |
| 1075 } | 1076 } |
| OLD | NEW |