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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 translate_icon_view_->SetVisible(false); | 296 translate_icon_view_->SetVisible(false); |
297 AddChildView(translate_icon_view_); | 297 AddChildView(translate_icon_view_); |
298 | 298 |
299 star_view_ = new StarView(command_updater(), browser_); | 299 star_view_ = new StarView(command_updater(), browser_); |
300 star_view_->SetVisible(false); | 300 star_view_->SetVisible(false); |
301 AddChildView(star_view_); | 301 AddChildView(star_view_); |
302 | 302 |
303 // Initialize the location entry. We do this to avoid a black flash which is | 303 // Initialize the location entry. We do this to avoid a black flash which is |
304 // visible when the location entry has just been initialized. | 304 // visible when the location entry has just been initialized. |
305 Update(NULL); | 305 Update(NULL); |
| 306 |
| 307 size_animation_.reset(new gfx::SlideAnimation(this)); |
| 308 size_animation_->Reset(1); |
306 } | 309 } |
307 | 310 |
308 bool LocationBarView::IsInitialized() const { | 311 bool LocationBarView::IsInitialized() const { |
309 return omnibox_view_ != NULL; | 312 return omnibox_view_ != NULL; |
310 } | 313 } |
311 | 314 |
312 SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level, | 315 SkColor LocationBarView::GetColor(ToolbarModel::SecurityLevel security_level, |
313 ColorKind kind) const { | 316 ColorKind kind) const { |
314 const ui::NativeTheme* native_theme = GetNativeTheme(); | 317 const ui::NativeTheme* native_theme = GetNativeTheme(); |
315 switch (kind) { | 318 switch (kind) { |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 void LocationBarView::GetAccessibleState(ui::AXViewState* state) { | 522 void LocationBarView::GetAccessibleState(ui::AXViewState* state) { |
520 state->role = ui::AX_ROLE_GROUP; | 523 state->role = ui::AX_ROLE_GROUP; |
521 } | 524 } |
522 | 525 |
523 gfx::Size LocationBarView::GetPreferredSize() const { | 526 gfx::Size LocationBarView::GetPreferredSize() const { |
524 // Compute minimum height. | 527 // Compute minimum height. |
525 gfx::Size min_size(border_painter_->GetMinimumSize()); | 528 gfx::Size min_size(border_painter_->GetMinimumSize()); |
526 if (!IsInitialized()) | 529 if (!IsInitialized()) |
527 return min_size; | 530 return min_size; |
528 | 531 |
| 532 min_size.set_height(min_size.height() * size_animation_->GetCurrentValue()); |
| 533 |
529 // Compute width of omnibox-leading content. | 534 // Compute width of omnibox-leading content. |
530 const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); | 535 const int horizontal_edge_thickness = GetHorizontalEdgeThickness(); |
531 int leading_width = horizontal_edge_thickness; | 536 int leading_width = horizontal_edge_thickness; |
532 if (ShouldShowKeywordBubble()) { | 537 if (ShouldShowKeywordBubble()) { |
533 // The selected keyword view can collapse completely. | 538 // The selected keyword view can collapse completely. |
534 } else if (ShouldShowEVBubble()) { | 539 } else if (ShouldShowEVBubble()) { |
535 leading_width += kBubblePadding + | 540 leading_width += kBubblePadding + |
536 ev_bubble_view_->GetMinimumSizeForLabelText( | 541 ev_bubble_view_->GetMinimumSizeForLabelText( |
537 GetToolbarModel()->GetEVCertName()).width(); | 542 GetToolbarModel()->GetEVCertName()).width(); |
538 } else { | 543 } else { |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 void LocationBarView::UpdateBookmarkStarVisibility() { | 1062 void LocationBarView::UpdateBookmarkStarVisibility() { |
1058 if (star_view_) { | 1063 if (star_view_) { |
1059 star_view_->SetVisible( | 1064 star_view_->SetVisible( |
1060 browser_defaults::bookmarks_enabled && !is_popup_mode_ && | 1065 browser_defaults::bookmarks_enabled && !is_popup_mode_ && |
1061 !GetToolbarModel()->input_in_progress() && | 1066 !GetToolbarModel()->input_in_progress() && |
1062 edit_bookmarks_enabled_.GetValue() && | 1067 edit_bookmarks_enabled_.GetValue() && |
1063 !IsBookmarkStarHiddenByExtension()); | 1068 !IsBookmarkStarHiddenByExtension()); |
1064 } | 1069 } |
1065 } | 1070 } |
1066 | 1071 |
| 1072 void LocationBarView::UpdateLocationBarState(bool visible, bool animate) { |
| 1073 if (!animate) { |
| 1074 size_animation_->Reset(visible ? 1 : 0); |
| 1075 return; |
| 1076 } |
| 1077 |
| 1078 if (visible) |
| 1079 size_animation_->Show(); |
| 1080 else |
| 1081 size_animation_->Hide(); |
| 1082 } |
| 1083 |
1067 bool LocationBarView::ShowPageActionPopup( | 1084 bool LocationBarView::ShowPageActionPopup( |
1068 const extensions::Extension* extension, | 1085 const extensions::Extension* extension, |
1069 bool grant_tab_permissions) { | 1086 bool grant_tab_permissions) { |
1070 ExtensionAction* extension_action = | 1087 ExtensionAction* extension_action = |
1071 extensions::ExtensionActionManager::Get(profile())->GetPageAction( | 1088 extensions::ExtensionActionManager::Get(profile())->GetPageAction( |
1072 *extension); | 1089 *extension); |
1073 CHECK(extension_action); | 1090 CHECK(extension_action); |
1074 PageActionWithBadgeView* page_action_view = | 1091 PageActionWithBadgeView* page_action_view = |
1075 GetPageActionView(extension_action); | 1092 GetPageActionView(extension_action); |
1076 if (!page_action_view) { | 1093 if (!page_action_view) { |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 ui::DragDropTypes::DRAG_NONE; | 1304 ui::DragDropTypes::DRAG_NONE; |
1288 } | 1305 } |
1289 | 1306 |
1290 bool LocationBarView::CanStartDragForView(View* sender, | 1307 bool LocationBarView::CanStartDragForView(View* sender, |
1291 const gfx::Point& press_pt, | 1308 const gfx::Point& press_pt, |
1292 const gfx::Point& p) { | 1309 const gfx::Point& p) { |
1293 return true; | 1310 return true; |
1294 } | 1311 } |
1295 | 1312 |
1296 //////////////////////////////////////////////////////////////////////////////// | 1313 //////////////////////////////////////////////////////////////////////////////// |
| 1314 // LocationBarView, private gfx::AnimationDelegate implementation: |
| 1315 void LocationBarView::AnimationProgressed(const gfx::Animation* animation) { |
| 1316 browser_->window()->ToolbarSizeChanged(true); |
| 1317 } |
| 1318 |
| 1319 void LocationBarView::AnimationEnded(const gfx::Animation* animation) { |
| 1320 browser_->window()->ToolbarSizeChanged(false); |
| 1321 } |
| 1322 |
| 1323 //////////////////////////////////////////////////////////////////////////////// |
1297 // LocationBarView, private OmniboxEditController implementation: | 1324 // LocationBarView, private OmniboxEditController implementation: |
1298 | 1325 |
1299 void LocationBarView::OnChanged() { | 1326 void LocationBarView::OnChanged() { |
1300 int icon_id = omnibox_view_->GetIcon(); | 1327 int icon_id = omnibox_view_->GetIcon(); |
1301 location_icon_view_->SetImage(GetThemeProvider()->GetImageSkiaNamed(icon_id)); | 1328 location_icon_view_->SetImage(GetThemeProvider()->GetImageSkiaNamed(icon_id)); |
1302 location_icon_view_->ShowTooltip(!GetOmniboxView()->IsEditingOrEmpty()); | 1329 location_icon_view_->ShowTooltip(!GetOmniboxView()->IsEditingOrEmpty()); |
1303 | 1330 |
1304 Layout(); | 1331 Layout(); |
1305 SchedulePaint(); | 1332 SchedulePaint(); |
1306 } | 1333 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 | 1372 |
1346 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1373 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
1347 const SearchModel::State& new_state) { | 1374 const SearchModel::State& new_state) { |
1348 const bool visible = !GetToolbarModel()->input_in_progress() && | 1375 const bool visible = !GetToolbarModel()->input_in_progress() && |
1349 new_state.voice_search_supported; | 1376 new_state.voice_search_supported; |
1350 if (mic_search_view_->visible() != visible) { | 1377 if (mic_search_view_->visible() != visible) { |
1351 mic_search_view_->SetVisible(visible); | 1378 mic_search_view_->SetVisible(visible); |
1352 Layout(); | 1379 Layout(); |
1353 } | 1380 } |
1354 } | 1381 } |
OLD | NEW |