| 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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 const int padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING); | 508 const int padding = GetLayoutConstant(LOCATION_BAR_HORIZONTAL_PADDING); |
| 509 | 509 |
| 510 // Compute width of omnibox-leading content. | 510 // Compute width of omnibox-leading content. |
| 511 const int edge_thickness = GetHorizontalEdgeThickness(); | 511 const int edge_thickness = GetHorizontalEdgeThickness(); |
| 512 int leading_width = edge_thickness; | 512 int leading_width = edge_thickness; |
| 513 if (ShouldShowKeywordBubble()) { | 513 if (ShouldShowKeywordBubble()) { |
| 514 // The selected keyword view can collapse completely. | 514 // The selected keyword view can collapse completely. |
| 515 } else if (ShouldShowSecurityChip()) { | 515 } else if (ShouldShowSecurityChip()) { |
| 516 base::string16 security_text = GetSecurityText(); | 516 base::string16 security_text = GetSecurityText(); |
| 517 leading_width += | 517 leading_width += |
| 518 GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING) + |
| 518 location_icon_view_->GetMinimumSizeForLabelText(security_text).width(); | 519 location_icon_view_->GetMinimumSizeForLabelText(security_text).width(); |
| 519 } else { | 520 } else { |
| 520 leading_width += padding + location_icon_view_->GetMinimumSize().width(); | 521 leading_width += padding + location_icon_view_->GetMinimumSize().width(); |
| 521 } | 522 } |
| 522 | 523 |
| 523 // Compute width of omnibox-trailing content. | 524 // Compute width of omnibox-trailing content. |
| 524 int trailing_width = edge_thickness; | 525 int trailing_width = edge_thickness; |
| 525 trailing_width += IncrementalMinimumWidth(star_view_) + | 526 trailing_width += IncrementalMinimumWidth(star_view_) + |
| 526 IncrementalMinimumWidth(translate_icon_view_) + | 527 IncrementalMinimumWidth(translate_icon_view_) + |
| 527 IncrementalMinimumWidth(open_pdf_in_reader_view_) + | 528 IncrementalMinimumWidth(open_pdf_in_reader_view_) + |
| (...skipping 29 matching lines...) Expand all Loading... |
| 557 item_padding - omnibox_view_->GetInsets().left()); | 558 item_padding - omnibox_view_->GetInsets().left()); |
| 558 LocationBarLayout trailing_decorations( | 559 LocationBarLayout trailing_decorations( |
| 559 LocationBarLayout::RIGHT_EDGE, item_padding, | 560 LocationBarLayout::RIGHT_EDGE, item_padding, |
| 560 item_padding - omnibox_view_->GetInsets().right()); | 561 item_padding - omnibox_view_->GetInsets().right()); |
| 561 | 562 |
| 562 const base::string16 keyword(omnibox_view_->model()->keyword()); | 563 const base::string16 keyword(omnibox_view_->model()->keyword()); |
| 563 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want | 564 // In some cases (e.g. fullscreen mode) we may have 0 height. We still want |
| 564 // to position our child views in this case, because other things may be | 565 // to position our child views in this case, because other things may be |
| 565 // positioned relative to them (e.g. the "bookmark added" bubble if the user | 566 // positioned relative to them (e.g. the "bookmark added" bubble if the user |
| 566 // hits ctrl-d). | 567 // hits ctrl-d). |
| 568 const int bubble_horizontal_padding = |
| 569 GetLayoutConstant(LOCATION_BAR_BUBBLE_HORIZONTAL_PADDING); |
| 567 const int vertical_padding = GetTotalVerticalPadding(); | 570 const int vertical_padding = GetTotalVerticalPadding(); |
| 568 const int location_height = std::max(height() - (vertical_padding * 2), 0); | 571 const int location_height = std::max(height() - (vertical_padding * 2), 0); |
| 569 | 572 |
| 570 location_icon_view_->SetLabel(base::string16()); | 573 location_icon_view_->SetLabel(base::string16()); |
| 571 if (ShouldShowKeywordBubble()) { | 574 if (ShouldShowKeywordBubble()) { |
| 572 leading_decorations.AddDecoration(vertical_padding, location_height, true, | 575 leading_decorations.AddDecoration(vertical_padding, location_height, true, |
| 573 0, 0, item_padding, | 576 0, bubble_horizontal_padding, |
| 574 selected_keyword_view_); | 577 item_padding, selected_keyword_view_); |
| 575 if (selected_keyword_view_->keyword() != keyword) { | 578 if (selected_keyword_view_->keyword() != keyword) { |
| 576 selected_keyword_view_->SetKeyword(keyword); | 579 selected_keyword_view_->SetKeyword(keyword); |
| 577 const TemplateURL* template_url = | 580 const TemplateURL* template_url = |
| 578 TemplateURLServiceFactory::GetForProfile(profile())-> | 581 TemplateURLServiceFactory::GetForProfile(profile())-> |
| 579 GetTemplateURLForKeyword(keyword); | 582 GetTemplateURLForKeyword(keyword); |
| 580 if (template_url && | 583 if (template_url && |
| 581 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) { | 584 (template_url->type() == TemplateURL::OMNIBOX_API_EXTENSION)) { |
| 582 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> | 585 gfx::Image image = extensions::OmniboxAPI::Get(profile())-> |
| 583 GetOmniboxIcon(template_url->GetExtensionId()); | 586 GetOmniboxIcon(template_url->GetExtensionId()); |
| 584 selected_keyword_view_->SetImage(image.AsImageSkia()); | 587 selected_keyword_view_->SetImage(image.AsImageSkia()); |
| 585 } else { | 588 } else { |
| 586 selected_keyword_view_->ResetImage(); | 589 selected_keyword_view_->ResetImage(); |
| 587 } | 590 } |
| 588 } | 591 } |
| 589 } else if (ShouldShowSecurityChip()) { | 592 } else if (ShouldShowSecurityChip()) { |
| 590 location_icon_view_->SetLabel(GetSecurityText()); | 593 location_icon_view_->SetLabel(GetSecurityText()); |
| 591 // The largest fraction of the omnibox that can be taken by the EV bubble. | 594 // The largest fraction of the omnibox that can be taken by the EV bubble. |
| 592 const double kMaxBubbleFraction = 0.5; | 595 const double kMaxBubbleFraction = 0.5; |
| 593 leading_decorations.AddDecoration(vertical_padding, location_height, false, | 596 leading_decorations.AddDecoration( |
| 594 kMaxBubbleFraction, 0, item_padding, | 597 vertical_padding, location_height, false, kMaxBubbleFraction, |
| 595 location_icon_view_); | 598 bubble_horizontal_padding, item_padding, location_icon_view_); |
| 596 } else { | 599 } else { |
| 597 leading_decorations.AddDecoration(vertical_padding, location_height, | 600 leading_decorations.AddDecoration(vertical_padding, location_height, |
| 598 location_icon_view_); | 601 location_icon_view_); |
| 599 } | 602 } |
| 600 | 603 |
| 601 if (star_view_->visible()) { | 604 if (star_view_->visible()) { |
| 602 trailing_decorations.AddDecoration(vertical_padding, location_height, | 605 trailing_decorations.AddDecoration(vertical_padding, location_height, |
| 603 star_view_); | 606 star_view_); |
| 604 } | 607 } |
| 605 if (translate_icon_view_->visible()) { | 608 if (translate_icon_view_->visible()) { |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1340 // LocationBarView, private TemplateURLServiceObserver implementation: | 1343 // LocationBarView, private TemplateURLServiceObserver implementation: |
| 1341 | 1344 |
| 1342 void LocationBarView::OnTemplateURLServiceChanged() { | 1345 void LocationBarView::OnTemplateURLServiceChanged() { |
| 1343 template_url_service_->RemoveObserver(this); | 1346 template_url_service_->RemoveObserver(this); |
| 1344 template_url_service_ = nullptr; | 1347 template_url_service_ = nullptr; |
| 1345 // If the browser is no longer active, let's not show the info bubble, as this | 1348 // If the browser is no longer active, let's not show the info bubble, as this |
| 1346 // would make the browser the active window again. | 1349 // would make the browser the active window again. |
| 1347 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1350 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
| 1348 ShowFirstRunBubble(); | 1351 ShowFirstRunBubble(); |
| 1349 } | 1352 } |
| OLD | NEW |