| 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE, | 479 LocationBarLayout trailing_decorations(LocationBarLayout::RIGHT_EDGE, |
| 480 item_padding, item_padding); | 480 item_padding, item_padding); |
| 481 | 481 |
| 482 const base::string16 keyword(omnibox_view_->model()->keyword()); | 482 const base::string16 keyword(omnibox_view_->model()->keyword()); |
| 483 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want | 483 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want |
| 484 // to position our child views in this case, because other things may be | 484 // to position our child views in this case, because other things may be |
| 485 // positioned relative to them (e.g. the "bookmark added" bubble if the user | 485 // positioned relative to them (e.g. the "bookmark added" bubble if the user |
| 486 // hits ctrl-d). | 486 // hits ctrl-d). |
| 487 const int vertical_padding = GetTotalVerticalPadding(); | 487 const int vertical_padding = GetTotalVerticalPadding(); |
| 488 const int location_height = std::max(height() - (vertical_padding * 2), 0); | 488 const int location_height = std::max(height() - (vertical_padding * 2), 0); |
| 489 // The largest fraction of the omnibox that can be taken by the EV or search |
| 490 // label/chip. |
| 491 const double kLeadingDecorationMaxFraction = 0.5; |
| 489 | 492 |
| 490 location_icon_view_->SetLabel(base::string16()); | 493 location_icon_view_->SetLabel(base::string16()); |
| 491 if (ShouldShowKeywordBubble()) { | 494 if (ShouldShowKeywordBubble()) { |
| 492 leading_decorations.AddDecoration(vertical_padding, location_height, true, | 495 leading_decorations.AddDecoration( |
| 493 0, item_padding, item_padding, | 496 vertical_padding, location_height, false, kLeadingDecorationMaxFraction, |
| 494 selected_keyword_view_); | 497 item_padding, item_padding, selected_keyword_view_); |
| 495 if (selected_keyword_view_->keyword() != keyword) { | 498 if (selected_keyword_view_->keyword() != keyword) { |
| 496 selected_keyword_view_->SetKeyword(keyword); | 499 selected_keyword_view_->SetKeyword(keyword); |
| 497 const TemplateURL* template_url = | 500 const TemplateURL* template_url = |
| 498 TemplateURLServiceFactory::GetForProfile(profile())-> | 501 TemplateURLServiceFactory::GetForProfile(profile())-> |
| 499 GetTemplateURLForKeyword(keyword); | 502 GetTemplateURLForKeyword(keyword); |
| 500 if (template_url && | 503 if (template_url && |
| 501 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) { | 504 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) { |
| 502 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> | 505 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> |
| 503 GetOmniboxIcon(template_url->GetExtensionId()); | 506 GetOmniboxIcon(template_url->GetExtensionId()); |
| 504 selected_keyword_view_->SetImage(image.AsImageSkia()); | 507 selected_keyword_view_->SetImage(image.AsImageSkia()); |
| 505 } else { | 508 } else { |
| 506 selected_keyword_view_->ResetImage(); | 509 selected_keyword_view_->ResetImage(); |
| 507 } | 510 } |
| 508 } | 511 } |
| 509 } else if (ShouldShowLocationIconText()) { | 512 } else if (ShouldShowLocationIconText()) { |
| 510 location_icon_view_->SetLabel(GetLocationIconText()); | 513 location_icon_view_->SetLabel(GetLocationIconText()); |
| 511 // The largest fraction of the omnibox that can be taken by the EV bubble. | 514 leading_decorations.AddDecoration( |
| 512 const double kMaxBubbleFraction = 0.5; | 515 vertical_padding, location_height, false, kLeadingDecorationMaxFraction, |
| 513 leading_decorations.AddDecoration(vertical_padding, location_height, false, | 516 item_padding, item_padding, location_icon_view_); |
| 514 kMaxBubbleFraction, item_padding, | |
| 515 item_padding, location_icon_view_); | |
| 516 } else { | 517 } else { |
| 517 leading_decorations.AddDecoration(vertical_padding, location_height, | 518 leading_decorations.AddDecoration(vertical_padding, location_height, |
| 518 location_icon_view_); | 519 location_icon_view_); |
| 519 } | 520 } |
| 520 | 521 |
| 521 if (star_view_->visible()) { | 522 if (star_view_->visible()) { |
| 522 trailing_decorations.AddDecoration(vertical_padding, location_height, | 523 trailing_decorations.AddDecoration(vertical_padding, location_height, |
| 523 star_view_); | 524 star_view_); |
| 524 } | 525 } |
| 525 if (translate_icon_view_->visible()) { | 526 if (translate_icon_view_->visible()) { |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 // LocationBarView, private TemplateURLServiceObserver implementation: | 1208 // LocationBarView, private TemplateURLServiceObserver implementation: |
| 1208 | 1209 |
| 1209 void LocationBarView::OnTemplateURLServiceChanged() { | 1210 void LocationBarView::OnTemplateURLServiceChanged() { |
| 1210 template_url_service_->RemoveObserver(this); | 1211 template_url_service_->RemoveObserver(this); |
| 1211 template_url_service_ = nullptr; | 1212 template_url_service_ = nullptr; |
| 1212 // If the browser is no longer active, let's not show the info bubble, as this | 1213 // If the browser is no longer active, let's not show the info bubble, as this |
| 1213 // would make the browser the active window again. | 1214 // would make the browser the active window again. |
| 1214 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1215 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
| 1215 ShowFirstRunBubble(); | 1216 ShowFirstRunBubble(); |
| 1216 } | 1217 } |
| OLD | NEW |