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

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

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

Powered by Google App Engine
This is Rietveld 408576698