Chromium Code Reviews| 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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 | 388 |
| 389 OnChanged(); | 389 OnChanged(); |
|
Peter Kasting
2013/09/04 20:59:11
This call can be nuked since it happens at the end
npentrel
2013/09/04 21:50:18
I don't think I understand what you mean.
Peter Kasting
2013/09/04 21:52:01
Update(NULL); // This calls OnChanged() directly
npentrel
2013/09/04 22:19:55
Done.
| |
| 390 } | 390 } |
| 391 | 391 |
| 392 bool LocationBarView::IsInitialized() const { | 392 bool LocationBarView::IsInitialized() const { |
| 393 return location_entry_view_ != NULL; | 393 return location_entry_view_ != NULL; |
| 394 } | 394 } |
| 395 | 395 |
| 396 SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level, | 396 SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level, |
| 397 ColorKind kind) const { | 397 ColorKind kind) const { |
| 398 const ui::NativeTheme* native_theme = GetNativeTheme(); | 398 const ui::NativeTheme* native_theme = GetNativeTheme(); |
| 399 switch (kind) { | 399 switch (kind) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 star_enabled); | 516 star_enabled); |
| 517 if (star_view_) | 517 if (star_view_) |
| 518 star_view_->SetVisible(star_enabled); | 518 star_view_->SetVisible(star_enabled); |
| 519 | 519 |
| 520 if (contents) | 520 if (contents) |
| 521 location_entry_->OnTabChanged(contents); | 521 location_entry_->OnTabChanged(contents); |
| 522 else | 522 else |
| 523 location_entry_->Update(); | 523 location_entry_->Update(); |
| 524 | 524 |
| 525 OnChanged(); | 525 OnChanged(); |
| 526 UpdatePostLayout(); | |
| 526 } | 527 } |
| 527 | 528 |
| 528 void LocationBarView::UpdateContentSettingsIcons() { | 529 void LocationBarView::UpdateContentSettingsIcons() { |
| 529 RefreshContentSettingViews(); | 530 RefreshContentSettingViews(); |
| 530 | 531 |
| 531 Layout(); | 532 Layout(); |
| 533 UpdatePostLayout(); | |
| 532 SchedulePaint(); | 534 SchedulePaint(); |
| 533 } | 535 } |
| 534 | 536 |
| 535 void LocationBarView::UpdatePageActions() { | 537 void LocationBarView::UpdatePageActions() { |
| 536 size_t count_before = page_action_views_.size(); | 538 size_t count_before = page_action_views_.size(); |
| 537 RefreshPageActionViews(); | 539 RefreshPageActionViews(); |
| 538 RefreshScriptBubble(); | 540 RefreshScriptBubble(); |
| 539 if (page_action_views_.size() != count_before) { | 541 if (page_action_views_.size() != count_before) { |
| 540 content::NotificationService::current()->Notify( | 542 content::NotificationService::current()->Notify( |
| 541 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 543 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) ? | 1129 return (ui::GetDisplayLayout() == ui::LAYOUT_TOUCH) ? |
| 1128 GetItemPadding() / 2 : 0; | 1130 GetItemPadding() / 2 : 0; |
| 1129 } | 1131 } |
| 1130 | 1132 |
| 1131 int LocationBarView::GetHorizontalEdgeThickness() const { | 1133 int LocationBarView::GetHorizontalEdgeThickness() const { |
| 1132 // In maximized popup mode, there isn't any edge. | 1134 // In maximized popup mode, there isn't any edge. |
| 1133 return (is_popup_mode_ && browser_ && browser_->window() && | 1135 return (is_popup_mode_ && browser_ && browser_->window() && |
| 1134 browser_->window()->IsMaximized()) ? 0 : vertical_edge_thickness(); | 1136 browser_->window()->IsMaximized()) ? 0 : vertical_edge_thickness(); |
| 1135 } | 1137 } |
| 1136 | 1138 |
| 1137 void LocationBarView::RefreshContentSettingViews() { | 1139 void LocationBarView::RefreshContentSettingViews() { |
|
Peter Kasting
2013/09/04 20:59:11
Nit: Why don't e name these functions UpdateConten
npentrel
2013/09/04 21:50:18
Done.
| |
| 1138 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 1140 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
| 1139 i != content_setting_views_.end(); ++i) { | 1141 i != content_setting_views_.end(); ++i) { |
| 1140 (*i)->Update(GetToolbarModel()->input_in_progress() ? | 1142 (*i)->UpdatePreLayout(GetToolbarModel()->input_in_progress() ? |
| 1141 NULL : GetWebContents()); | 1143 NULL : GetWebContents()); |
| 1142 } | 1144 } |
| 1143 } | 1145 } |
| 1146 | |
| 1147 void LocationBarView::UpdatePostLayout() { | |
| 1148 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | |
| 1149 i != content_setting_views_.end(); ++i) { | |
| 1150 (*i)->UpdatePostLayout(GetToolbarModel()->input_in_progress() ? | |
| 1151 NULL : GetWebContents()); | |
| 1152 } | |
| 1153 } | |
| 1144 | 1154 |
| 1145 void LocationBarView::DeletePageActionViews() { | 1155 void LocationBarView::DeletePageActionViews() { |
| 1146 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 1156 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
| 1147 i != page_action_views_.end(); ++i) | 1157 i != page_action_views_.end(); ++i) |
| 1148 RemoveChildView(*i); | 1158 RemoveChildView(*i); |
| 1149 STLDeleteElements(&page_action_views_); | 1159 STLDeleteElements(&page_action_views_); |
| 1150 } | 1160 } |
| 1151 | 1161 |
| 1152 void LocationBarView::RefreshPageActionViews() { | 1162 void LocationBarView::RefreshPageActionViews() { |
| 1153 if (is_popup_mode_) | 1163 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) { | 1563 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
| 1554 int total_height = | 1564 int total_height = |
| 1555 use_preferred_size ? GetPreferredSize().height() : height(); | 1565 use_preferred_size ? GetPreferredSize().height() : height(); |
| 1556 return std::max(total_height - (vertical_edge_thickness() * 2), 0); | 1566 return std::max(total_height - (vertical_edge_thickness() * 2), 0); |
| 1557 } | 1567 } |
| 1558 | 1568 |
| 1559 bool LocationBarView::HasValidSuggestText() const { | 1569 bool LocationBarView::HasValidSuggestText() const { |
| 1560 return suggested_text_view_->visible() && | 1570 return suggested_text_view_->visible() && |
| 1561 !suggested_text_view_->size().IsEmpty(); | 1571 !suggested_text_view_->size().IsEmpty(); |
| 1562 } | 1572 } |
| OLD | NEW |