| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 selected_keyword_view_(NULL), | 134 selected_keyword_view_(NULL), |
| 135 suggested_text_view_(NULL), | 135 suggested_text_view_(NULL), |
| 136 keyword_hint_view_(NULL), | 136 keyword_hint_view_(NULL), |
| 137 mic_search_view_(NULL), | 137 mic_search_view_(NULL), |
| 138 zoom_view_(NULL), | 138 zoom_view_(NULL), |
| 139 generated_credit_card_view_(NULL), | 139 generated_credit_card_view_(NULL), |
| 140 open_pdf_in_reader_view_(NULL), | 140 open_pdf_in_reader_view_(NULL), |
| 141 manage_passwords_icon_view_(NULL), | 141 manage_passwords_icon_view_(NULL), |
| 142 translate_icon_view_(NULL), | 142 translate_icon_view_(NULL), |
| 143 star_view_(NULL), | 143 star_view_(NULL), |
| 144 size_animation_(this), |
| 144 is_popup_mode_(is_popup_mode), | 145 is_popup_mode_(is_popup_mode), |
| 145 show_focus_rect_(false), | 146 show_focus_rect_(false), |
| 146 template_url_service_(NULL), | 147 template_url_service_(NULL), |
| 147 dropdown_animation_offset_(0), | 148 dropdown_animation_offset_(0), |
| 148 web_contents_null_at_last_refresh_(true) { | 149 web_contents_null_at_last_refresh_(true) { |
| 149 edit_bookmarks_enabled_.Init( | 150 edit_bookmarks_enabled_.Init( |
| 150 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), | 151 bookmarks::prefs::kEditBookmarksEnabled, profile->GetPrefs(), |
| 151 base::Bind(&LocationBarView::Update, base::Unretained(this), | 152 base::Bind(&LocationBarView::Update, base::Unretained(this), |
| 152 static_cast<content::WebContents*>(NULL))); | 153 static_cast<content::WebContents*>(NULL))); |
| 153 | 154 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 translate_icon_view_->SetVisible(false); | 297 translate_icon_view_->SetVisible(false); |
| 297 AddChildView(translate_icon_view_); | 298 AddChildView(translate_icon_view_); |
| 298 | 299 |
| 299 star_view_ = new StarView(command_updater(), browser_); | 300 star_view_ = new StarView(command_updater(), browser_); |
| 300 star_view_->SetVisible(false); | 301 star_view_->SetVisible(false); |
| 301 AddChildView(star_view_); | 302 AddChildView(star_view_); |
| 302 | 303 |
| 303 // Initialize the location entry. We do this to avoid a black flash which is | 304 // Initialize the location entry. We do this to avoid a black flash which is |
| 304 // visible when the location entry has just been initialized. | 305 // visible when the location entry has just been initialized. |
| 305 Update(NULL); | 306 Update(NULL); |
| 307 |
| 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::UpdateLocationBarVisibility(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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 ui::DragDropTypes::DRAG_NONE; | 1307 ui::DragDropTypes::DRAG_NONE; |
| 1291 } | 1308 } |
| 1292 | 1309 |
| 1293 bool LocationBarView::CanStartDragForView(View* sender, | 1310 bool LocationBarView::CanStartDragForView(View* sender, |
| 1294 const gfx::Point& press_pt, | 1311 const gfx::Point& press_pt, |
| 1295 const gfx::Point& p) { | 1312 const gfx::Point& p) { |
| 1296 return true; | 1313 return true; |
| 1297 } | 1314 } |
| 1298 | 1315 |
| 1299 //////////////////////////////////////////////////////////////////////////////// | 1316 //////////////////////////////////////////////////////////////////////////////// |
| 1317 // LocationBarView, private gfx::AnimationDelegate implementation: |
| 1318 void LocationBarView::AnimationProgressed(const gfx::Animation* animation) { |
| 1319 browser_->window()->ToolbarSizeChanged(true); |
| 1320 } |
| 1321 |
| 1322 void LocationBarView::AnimationEnded(const gfx::Animation* animation) { |
| 1323 browser_->window()->ToolbarSizeChanged(false); |
| 1324 } |
| 1325 |
| 1326 //////////////////////////////////////////////////////////////////////////////// |
| 1300 // LocationBarView, private OmniboxEditController implementation: | 1327 // LocationBarView, private OmniboxEditController implementation: |
| 1301 | 1328 |
| 1302 void LocationBarView::OnChanged() { | 1329 void LocationBarView::OnChanged() { |
| 1303 int icon_id = omnibox_view_->GetIcon(); | 1330 int icon_id = omnibox_view_->GetIcon(); |
| 1304 location_icon_view_->SetImage(GetThemeProvider()->GetImageSkiaNamed(icon_id)); | 1331 location_icon_view_->SetImage(GetThemeProvider()->GetImageSkiaNamed(icon_id)); |
| 1305 location_icon_view_->ShowTooltip(!GetOmniboxView()->IsEditingOrEmpty()); | 1332 location_icon_view_->ShowTooltip(!GetOmniboxView()->IsEditingOrEmpty()); |
| 1306 | 1333 |
| 1307 Layout(); | 1334 Layout(); |
| 1308 SchedulePaint(); | 1335 SchedulePaint(); |
| 1309 } | 1336 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 | 1375 |
| 1349 void LocationBarView::ModelChanged(const SearchModel::State& old_state, | 1376 void LocationBarView::ModelChanged(const SearchModel::State& old_state, |
| 1350 const SearchModel::State& new_state) { | 1377 const SearchModel::State& new_state) { |
| 1351 const bool visible = !GetToolbarModel()->input_in_progress() && | 1378 const bool visible = !GetToolbarModel()->input_in_progress() && |
| 1352 new_state.voice_search_supported; | 1379 new_state.voice_search_supported; |
| 1353 if (mic_search_view_->visible() != visible) { | 1380 if (mic_search_view_->visible() != visible) { |
| 1354 mic_search_view_->SetVisible(visible); | 1381 mic_search_view_->SetVisible(visible); |
| 1355 Layout(); | 1382 Layout(); |
| 1356 } | 1383 } |
| 1357 } | 1384 } |
| OLD | NEW |