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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 star_view_->SetVisible(false); | 378 star_view_->SetVisible(false); |
379 AddChildView(star_view_); | 379 AddChildView(star_view_); |
380 | 380 |
381 registrar_.Add(this, | 381 registrar_.Add(this, |
382 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, | 382 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, |
383 content::Source<Profile>(profile_)); | 383 content::Source<Profile>(profile_)); |
384 | 384 |
385 // Initialize the location entry. We do this to avoid a black flash which is | 385 // Initialize the location entry. We do this to avoid a black flash which is |
386 // visible when the location entry has just been initialized. | 386 // visible when the location entry has just been initialized. |
387 Update(NULL); | 387 Update(NULL); |
388 | |
389 OnChanged(); | |
390 } | 388 } |
391 | 389 |
392 bool LocationBarView::IsInitialized() const { | 390 bool LocationBarView::IsInitialized() const { |
393 return location_entry_view_ != NULL; | 391 return location_entry_view_ != NULL; |
394 } | 392 } |
395 | 393 |
396 SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level, | 394 SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level, |
397 ColorKind kind) const { | 395 ColorKind kind) const { |
398 const ui::NativeTheme* native_theme = GetNativeTheme(); | 396 const ui::NativeTheme* native_theme = GetNativeTheme(); |
399 switch (kind) { | 397 switch (kind) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 } | 489 } |
492 | 490 |
493 void LocationBarView::SetAnimationOffset(int offset) { | 491 void LocationBarView::SetAnimationOffset(int offset) { |
494 animation_offset_ = offset; | 492 animation_offset_ = offset; |
495 } | 493 } |
496 | 494 |
497 void LocationBarView::Update(const WebContents* contents) { | 495 void LocationBarView::Update(const WebContents* contents) { |
498 mic_search_view_->SetVisible( | 496 mic_search_view_->SetVisible( |
499 !GetToolbarModel()->input_in_progress() && browser_ && | 497 !GetToolbarModel()->input_in_progress() && browser_ && |
500 browser_->search_model()->voice_search_supported()); | 498 browser_->search_model()->voice_search_supported()); |
501 RefreshContentSettingViews(); | 499 UpdateContentSettingViewsPreLayout(); |
502 generated_credit_card_view_->Update(); | 500 generated_credit_card_view_->Update(); |
503 ZoomBubbleView::CloseBubble(); | 501 ZoomBubbleView::CloseBubble(); |
504 RefreshZoomView(); | 502 RefreshZoomView(); |
505 RefreshPageActionViews(); | 503 RefreshPageActionViews(); |
506 RefreshScriptBubble(); | 504 RefreshScriptBubble(); |
507 open_pdf_in_reader_view_->Update( | 505 open_pdf_in_reader_view_->Update( |
508 GetToolbarModel()->input_in_progress() ? NULL : GetWebContents()); | 506 GetToolbarModel()->input_in_progress() ? NULL : GetWebContents()); |
509 | 507 |
510 bool star_enabled = browser_defaults::bookmarks_enabled && !is_popup_mode_ && | 508 bool star_enabled = browser_defaults::bookmarks_enabled && !is_popup_mode_ && |
511 star_view_ && !GetToolbarModel()->input_in_progress() && | 509 star_view_ && !GetToolbarModel()->input_in_progress() && |
512 edit_bookmarks_enabled_.GetValue(); | 510 edit_bookmarks_enabled_.GetValue(); |
513 | 511 |
514 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 512 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
515 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE_FROM_STAR, | 513 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE_FROM_STAR, |
516 star_enabled); | 514 star_enabled); |
517 if (star_view_) | 515 if (star_view_) |
518 star_view_->SetVisible(star_enabled); | 516 star_view_->SetVisible(star_enabled); |
519 | 517 |
520 if (contents) | 518 if (contents) |
521 location_entry_->OnTabChanged(contents); | 519 location_entry_->OnTabChanged(contents); |
522 else | 520 else |
523 location_entry_->Update(); | 521 location_entry_->Update(); |
524 | 522 |
525 OnChanged(); | 523 OnChanged(); |
Peter Kasting
2013/09/05 06:55:19
Nit: Add EOL comment: // NOTE: Calls Layout().
npentrel
2013/09/05 08:28:09
Done.
| |
524 UpdateContentSettingViewsPostLayout(); | |
526 } | 525 } |
527 | 526 |
528 void LocationBarView::UpdateContentSettingsIcons() { | 527 void LocationBarView::UpdateContentSettingsIcons() { |
529 RefreshContentSettingViews(); | 528 UpdateContentSettingViewsPreLayout(); |
530 | 529 |
Peter Kasting
2013/09/05 06:55:19
Nit: Remove blank line
npentrel
2013/09/05 08:28:09
Done.
| |
531 Layout(); | 530 Layout(); |
531 UpdateContentSettingViewsPostLayout(); | |
532 SchedulePaint(); | 532 SchedulePaint(); |
533 } | 533 } |
534 | 534 |
535 void LocationBarView::UpdatePageActions() { | 535 void LocationBarView::UpdatePageActions() { |
536 size_t count_before = page_action_views_.size(); | 536 size_t count_before = page_action_views_.size(); |
537 RefreshPageActionViews(); | 537 RefreshPageActionViews(); |
538 RefreshScriptBubble(); | 538 RefreshScriptBubble(); |
539 if (page_action_views_.size() != count_before) { | 539 if (page_action_views_.size() != count_before) { |
540 content::NotificationService::current()->Notify( | 540 content::NotificationService::current()->Notify( |
541 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 541 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1127 return (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) ? | 1127 return (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) ? |
1128 GetItemPadding() / 2 : 0; | 1128 GetItemPadding() / 2 : 0; |
1129 } | 1129 } |
1130 | 1130 |
1131 int LocationBarView::GetHorizontalEdgeThickness() const { | 1131 int LocationBarView::GetHorizontalEdgeThickness() const { |
1132 // In maximized popup mode, there isn't any edge. | 1132 // In maximized popup mode, there isn't any edge. |
1133 return (is_popup_mode_ && browser_ && browser_->window() && | 1133 return (is_popup_mode_ && browser_ && browser_->window() && |
1134 browser_->window()->IsMaximized()) ? 0 : vertical_edge_thickness(); | 1134 browser_->window()->IsMaximized()) ? 0 : vertical_edge_thickness(); |
1135 } | 1135 } |
1136 | 1136 |
1137 void LocationBarView::RefreshContentSettingViews() { | 1137 void LocationBarView::UpdateContentSettingViewsPreLayout() { |
1138 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 1138 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
1139 i != content_setting_views_.end(); ++i) { | 1139 i != content_setting_views_.end(); ++i) { |
1140 (*i)->Update(GetToolbarModel()->input_in_progress() ? | 1140 (*i)->UpdatePreLayout(GetToolbarModel()->input_in_progress() ? |
1141 NULL : GetWebContents()); | 1141 NULL : GetWebContents()); |
1142 } | 1142 } |
1143 } | 1143 } |
1144 | |
1145 void LocationBarView::UpdateContentSettingViewsPostLayout() { | |
1146 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | |
1147 i != content_setting_views_.end(); ++i) { | |
1148 (*i)->UpdatePostLayout(GetToolbarModel()->input_in_progress() ? | |
1149 NULL : GetWebContents()); | |
1150 } | |
1151 } | |
1144 | 1152 |
1145 void LocationBarView::DeletePageActionViews() { | 1153 void LocationBarView::DeletePageActionViews() { |
1146 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 1154 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
1147 i != page_action_views_.end(); ++i) | 1155 i != page_action_views_.end(); ++i) |
1148 RemoveChildView(*i); | 1156 RemoveChildView(*i); |
1149 STLDeleteElements(&page_action_views_); | 1157 STLDeleteElements(&page_action_views_); |
1150 } | 1158 } |
1151 | 1159 |
1152 void LocationBarView::RefreshPageActionViews() { | 1160 void LocationBarView::RefreshPageActionViews() { |
1153 if (is_popup_mode_) | 1161 if (is_popup_mode_) |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1553 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1561 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
1554 int total_height = | 1562 int total_height = |
1555 use_preferred_size ? GetPreferredSize().height() : height(); | 1563 use_preferred_size ? GetPreferredSize().height() : height(); |
1556 return std::max(total_height - (vertical_edge_thickness() * 2), 0); | 1564 return std::max(total_height - (vertical_edge_thickness() * 2), 0); |
1557 } | 1565 } |
1558 | 1566 |
1559 bool LocationBarView::HasValidSuggestText() const { | 1567 bool LocationBarView::HasValidSuggestText() const { |
1560 return suggested_text_view_->visible() && | 1568 return suggested_text_view_->visible() && |
1561 !suggested_text_view_->size().IsEmpty(); | 1569 !suggested_text_view_->size().IsEmpty(); |
1562 } | 1570 } |
OLD | NEW |