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/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 #include "chrome/browser/ui/search/search_ui.h" | 36 #include "chrome/browser/ui/search/search_ui.h" |
| 37 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 37 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 38 #include "chrome/browser/ui/view_ids.h" | 38 #include "chrome/browser/ui/view_ids.h" |
| 39 #include "chrome/browser/ui/views/browser_dialogs.h" | 39 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 40 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h" | 40 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h" |
| 41 #include "chrome/browser/ui/views/location_bar/chrome_to_mobile_view.h" | 41 #include "chrome/browser/ui/views/location_bar/chrome_to_mobile_view.h" |
| 42 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 42 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
| 43 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" | 43 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" |
| 44 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 44 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" |
| 45 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 45 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
| 46 #include "chrome/browser/ui/views/location_bar/metro_pin_view.h" | |
| 46 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 47 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
| 47 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" | 48 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
| 48 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" | 49 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" |
| 49 #include "chrome/browser/ui/views/location_bar/star_view.h" | 50 #include "chrome/browser/ui/views/location_bar/star_view.h" |
| 50 #include "chrome/browser/ui/views/location_bar/suggested_text_view.h" | 51 #include "chrome/browser/ui/views/location_bar/suggested_text_view.h" |
| 51 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" | 52 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
| 52 #include "chrome/browser/ui/views/location_bar/zoom_view.h" | 53 #include "chrome/browser/ui/views/location_bar/zoom_view.h" |
| 53 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 54 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
| 54 #include "chrome/browser/ui/views/omnibox/omnibox_views.h" | 55 #include "chrome/browser/ui/views/omnibox/omnibox_views.h" |
| 55 #include "chrome/browser/ui/webui/instant_ui.h" | 56 #include "chrome/browser/ui/webui/instant_ui.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 69 #include "ui/base/resource/resource_bundle.h" | 70 #include "ui/base/resource/resource_bundle.h" |
| 70 #include "ui/base/theme_provider.h" | 71 #include "ui/base/theme_provider.h" |
| 71 #include "ui/gfx/canvas.h" | 72 #include "ui/gfx/canvas.h" |
| 72 #include "ui/gfx/color_utils.h" | 73 #include "ui/gfx/color_utils.h" |
| 73 #include "ui/gfx/image/image.h" | 74 #include "ui/gfx/image/image.h" |
| 74 #include "ui/gfx/skia_util.h" | 75 #include "ui/gfx/skia_util.h" |
| 75 #include "ui/views/border.h" | 76 #include "ui/views/border.h" |
| 76 #include "ui/views/button_drag_utils.h" | 77 #include "ui/views/button_drag_utils.h" |
| 77 #include "ui/views/controls/label.h" | 78 #include "ui/views/controls/label.h" |
| 78 | 79 |
| 80 #if defined(OS_WIN) | |
| 81 #include "base/win/metro.h" | |
| 82 #endif | |
| 83 | |
| 79 #if defined(OS_WIN) && !defined(USE_AURA) | 84 #if defined(OS_WIN) && !defined(USE_AURA) |
| 80 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" | 85 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" |
| 81 #endif | 86 #endif |
| 82 | 87 |
| 83 #if !defined(OS_CHROMEOS) | 88 #if !defined(OS_CHROMEOS) |
| 84 #include "chrome/browser/ui/views/first_run_bubble.h" | 89 #include "chrome/browser/ui/views/first_run_bubble.h" |
| 85 #endif | 90 #endif |
| 86 | 91 |
| 87 #if defined(USE_AURA) | 92 #if defined(USE_AURA) |
| 88 #include "ui/compositor/layer.h" | 93 #include "ui/compositor/layer.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 content::PAGE_TRANSITION_TYPED | | 179 content::PAGE_TRANSITION_TYPED | |
| 175 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), | 180 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), |
| 176 location_icon_view_(NULL), | 181 location_icon_view_(NULL), |
| 177 ev_bubble_view_(NULL), | 182 ev_bubble_view_(NULL), |
| 178 location_entry_view_(NULL), | 183 location_entry_view_(NULL), |
| 179 selected_keyword_view_(NULL), | 184 selected_keyword_view_(NULL), |
| 180 suggested_text_view_(NULL), | 185 suggested_text_view_(NULL), |
| 181 keyword_hint_view_(NULL), | 186 keyword_hint_view_(NULL), |
| 182 zoom_view_(NULL), | 187 zoom_view_(NULL), |
| 183 star_view_(NULL), | 188 star_view_(NULL), |
| 189 metro_pin_view_(NULL), | |
| 184 action_box_button_view_(NULL), | 190 action_box_button_view_(NULL), |
| 185 chrome_to_mobile_view_(NULL), | 191 chrome_to_mobile_view_(NULL), |
| 186 mode_(mode), | 192 mode_(mode), |
| 187 show_focus_rect_(false), | 193 show_focus_rect_(false), |
| 188 template_url_service_(NULL), | 194 template_url_service_(NULL), |
| 189 animation_offset_(0), | 195 animation_offset_(0), |
| 190 ALLOW_THIS_IN_INITIALIZER_LIST(view_to_focus_(this)) { | 196 ALLOW_THIS_IN_INITIALIZER_LIST(view_to_focus_(this)) { |
| 191 set_id(VIEW_ID_LOCATION_BAR); | 197 set_id(VIEW_ID_LOCATION_BAR); |
| 192 | 198 |
| 193 if (mode_ == NORMAL) { | 199 if (mode_ == NORMAL) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 action_box_button_view_ = new ActionBoxButtonView( | 283 action_box_button_view_ = new ActionBoxButtonView( |
| 278 extensions::ExtensionSystem::Get(profile_)->extension_service()); | 284 extensions::ExtensionSystem::Get(profile_)->extension_service()); |
| 279 AddChildView(action_box_button_view_); | 285 AddChildView(action_box_button_view_); |
| 280 } else if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { | 286 } else if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { |
| 281 // Note: condition above means that the star and ChromeToMobile icons are | 287 // Note: condition above means that the star and ChromeToMobile icons are |
| 282 // hidden in popups and in the app launcher. | 288 // hidden in popups and in the app launcher. |
| 283 star_view_ = new StarView(command_updater_); | 289 star_view_ = new StarView(command_updater_); |
| 284 AddChildView(star_view_); | 290 AddChildView(star_view_); |
| 285 star_view_->SetVisible(true); | 291 star_view_->SetVisible(true); |
| 286 | 292 |
| 293 // Add the metro pin view, if this is windows and we are running in Metro | |
| 294 // mode. | |
| 295 #if defined(OS_WIN) | |
| 296 if (base::win::IsMetroProcess()) { | |
| 297 metro_pin_view_ = new MetroPinView(command_updater_); | |
| 298 AddChildView(metro_pin_view_); | |
| 299 metro_pin_view_->SetVisible(true); | |
|
sky
2012/07/20 16:46:41
Default visibility is true.
benwells
2012/07/23 08:03:43
Done. I updated some others as well.
| |
| 300 } | |
| 301 #endif | |
| 302 | |
| 287 // Also disable Chrome To Mobile for off-the-record and non-synced profiles, | 303 // Also disable Chrome To Mobile for off-the-record and non-synced profiles, |
| 288 // or if the feature is disabled by a command line flag or chrome://flags. | 304 // or if the feature is disabled by a command line flag or chrome://flags. |
| 289 if (!profile_->IsOffTheRecord() && profile_->IsSyncAccessible() && | 305 if (!profile_->IsOffTheRecord() && profile_->IsSyncAccessible() && |
| 290 ChromeToMobileService::IsChromeToMobileEnabled()) { | 306 ChromeToMobileService::IsChromeToMobileEnabled()) { |
| 291 chrome_to_mobile_view_ = new ChromeToMobileView(this, command_updater_); | 307 chrome_to_mobile_view_ = new ChromeToMobileView(this, command_updater_); |
| 292 AddChildView(chrome_to_mobile_view_); | 308 AddChildView(chrome_to_mobile_view_); |
| 293 ChromeToMobileService* service = | 309 ChromeToMobileService* service = |
| 294 ChromeToMobileServiceFactory::GetForProfile(profile_); | 310 ChromeToMobileServiceFactory::GetForProfile(profile_); |
| 295 service->RequestMobileListUpdate(); | 311 service->RequestMobileListUpdate(); |
| 296 chrome_to_mobile_view_->SetVisible(service->HasDevices()); | 312 chrome_to_mobile_view_->SetVisible(service->HasDevices()); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 | 511 |
| 496 void LocationBarView::SetStarToggled(bool on) { | 512 void LocationBarView::SetStarToggled(bool on) { |
| 497 if (star_view_) | 513 if (star_view_) |
| 498 star_view_->SetToggled(on); | 514 star_view_->SetToggled(on); |
| 499 } | 515 } |
| 500 | 516 |
| 501 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { | 517 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { |
| 502 chrome::ShowBookmarkBubbleView(star_view_, profile_, url, newly_bookmarked); | 518 chrome::ShowBookmarkBubbleView(star_view_, profile_, url, newly_bookmarked); |
| 503 } | 519 } |
| 504 | 520 |
| 521 void LocationBarView::SetMetroPinnedState(bool is_pinned) { | |
| 522 if (metro_pin_view_) | |
| 523 metro_pin_view_->SetIsPinned(is_pinned); | |
| 524 } | |
| 525 | |
| 505 void LocationBarView::SetZoomIconTooltipPercent(int zoom_percent) { | 526 void LocationBarView::SetZoomIconTooltipPercent(int zoom_percent) { |
| 506 zoom_view_->SetZoomIconTooltipPercent(zoom_percent); | 527 zoom_view_->SetZoomIconTooltipPercent(zoom_percent); |
| 507 } | 528 } |
| 508 | 529 |
| 509 void LocationBarView::SetZoomIconState( | 530 void LocationBarView::SetZoomIconState( |
| 510 ZoomController::ZoomIconState zoom_icon_state) { | 531 ZoomController::ZoomIconState zoom_icon_state) { |
| 511 zoom_view_->SetZoomIconState(zoom_icon_state); | 532 zoom_view_->SetZoomIconState(zoom_icon_state); |
| 512 | 533 |
| 513 Layout(); | 534 Layout(); |
| 514 SchedulePaint(); | 535 SchedulePaint(); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 649 // We'll adjust this width and take it out of |entry_width| below. | 670 // We'll adjust this width and take it out of |entry_width| below. |
| 650 } else { | 671 } else { |
| 651 location_icon_view_->SetVisible(true); | 672 location_icon_view_->SetVisible(true); |
| 652 location_icon_width = location_icon_view_->GetPreferredSize().width(); | 673 location_icon_width = location_icon_view_->GetPreferredSize().width(); |
| 653 entry_width -= (kEdgeThickness + GetEdgeItemPadding() + | 674 entry_width -= (kEdgeThickness + GetEdgeItemPadding() + |
| 654 location_icon_width + kItemEditPadding); | 675 location_icon_width + kItemEditPadding); |
| 655 } | 676 } |
| 656 | 677 |
| 657 if (star_view_ && star_view_->visible()) | 678 if (star_view_ && star_view_->visible()) |
| 658 entry_width -= star_view_->GetPreferredSize().width() + GetItemPadding(); | 679 entry_width -= star_view_->GetPreferredSize().width() + GetItemPadding(); |
| 680 if (metro_pin_view_ && metro_pin_view_->visible()) | |
| 681 entry_width -= metro_pin_view_->GetPreferredSize().width() + | |
| 682 GetItemPadding(); | |
| 659 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) { | 683 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) { |
| 660 entry_width -= chrome_to_mobile_view_->GetPreferredSize().width() + | 684 entry_width -= chrome_to_mobile_view_->GetPreferredSize().width() + |
| 661 GetItemPadding(); | 685 GetItemPadding(); |
| 662 } | 686 } |
| 663 int action_box_button_width = location_height; | 687 int action_box_button_width = location_height; |
| 664 if (action_box_button_view_) | 688 if (action_box_button_view_) |
| 665 entry_width -= action_box_button_width + GetItemPadding(); | 689 entry_width -= action_box_button_width + GetItemPadding(); |
| 666 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 690 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
| 667 i != page_action_views_.end(); ++i) { | 691 i != page_action_views_.end(); ++i) { |
| 668 if ((*i)->visible()) | 692 if ((*i)->visible()) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 737 } | 761 } |
| 738 | 762 |
| 739 if (star_view_ && star_view_->visible()) { | 763 if (star_view_ && star_view_->visible()) { |
| 740 offset += star_view_->GetBuiltInHorizontalPadding(); | 764 offset += star_view_->GetBuiltInHorizontalPadding(); |
| 741 int star_width = star_view_->GetPreferredSize().width(); | 765 int star_width = star_view_->GetPreferredSize().width(); |
| 742 offset -= star_width; | 766 offset -= star_width; |
| 743 star_view_->SetBounds(offset, location_y, star_width, location_height); | 767 star_view_->SetBounds(offset, location_y, star_width, location_height); |
| 744 offset -= GetItemPadding() - star_view_->GetBuiltInHorizontalPadding(); | 768 offset -= GetItemPadding() - star_view_->GetBuiltInHorizontalPadding(); |
| 745 } | 769 } |
| 746 | 770 |
| 771 if (metro_pin_view_ && metro_pin_view_->visible()) { | |
| 772 offset += metro_pin_view_->GetBuiltInHorizontalPadding(); | |
| 773 int pin_width = metro_pin_view_->GetPreferredSize().width(); | |
| 774 offset -= pin_width; | |
| 775 metro_pin_view_->SetBounds(offset, location_y, pin_width, location_height); | |
| 776 offset -= GetItemPadding() - metro_pin_view_->GetBuiltInHorizontalPadding(); | |
| 777 } | |
| 778 | |
| 747 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) { | 779 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) { |
| 748 offset += chrome_to_mobile_view_->GetBuiltInHorizontalPadding(); | 780 offset += chrome_to_mobile_view_->GetBuiltInHorizontalPadding(); |
| 749 int icon_width = chrome_to_mobile_view_->GetPreferredSize().width(); | 781 int icon_width = chrome_to_mobile_view_->GetPreferredSize().width(); |
| 750 offset -= icon_width; | 782 offset -= icon_width; |
| 751 chrome_to_mobile_view_->SetBounds(offset, location_y, | 783 chrome_to_mobile_view_->SetBounds(offset, location_y, |
| 752 icon_width, location_height); | 784 icon_width, location_height); |
| 753 offset -= GetItemPadding() - | 785 offset -= GetItemPadding() - |
| 754 chrome_to_mobile_view_->GetBuiltInHorizontalPadding(); | 786 chrome_to_mobile_view_->GetBuiltInHorizontalPadding(); |
| 755 } | 787 } |
| 756 | 788 |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1119 new_page_actions = controller->GetCurrentActions(); | 1151 new_page_actions = controller->GetCurrentActions(); |
| 1120 } | 1152 } |
| 1121 | 1153 |
| 1122 // On startup we sometimes haven't loaded any extensions. This makes sure | 1154 // On startup we sometimes haven't loaded any extensions. This makes sure |
| 1123 // we catch up when the extensions (and any page actions) load. | 1155 // we catch up when the extensions (and any page actions) load. |
| 1124 if (page_actions_ != new_page_actions) { | 1156 if (page_actions_ != new_page_actions) { |
| 1125 page_actions_.swap(new_page_actions); | 1157 page_actions_.swap(new_page_actions); |
| 1126 DeletePageActionViews(); // Delete the old views (if any). | 1158 DeletePageActionViews(); // Delete the old views (if any). |
| 1127 | 1159 |
| 1128 page_action_views_.resize(page_actions_.size()); | 1160 page_action_views_.resize(page_actions_.size()); |
| 1129 View* right_anchor = chrome_to_mobile_view_; | 1161 View* right_anchor = chrome_to_mobile_view_; |
|
sky
2012/07/20 16:46:41
1161-1168 shouldn't be in this if block.
benwells
2012/07/23 08:03:43
Sorry, I don't understand. My understanding is thi
sky
2012/07/23 16:02:17
You're right, my mistake.
| |
| 1130 if (!right_anchor) | 1162 if (!right_anchor) |
| 1163 right_anchor = metro_pin_view_; | |
| 1164 if (!right_anchor) | |
| 1131 right_anchor = star_view_; | 1165 right_anchor = star_view_; |
| 1132 if (!right_anchor) | 1166 if (!right_anchor) |
| 1133 right_anchor = action_box_button_view_; | 1167 right_anchor = action_box_button_view_; |
| 1134 DCHECK(right_anchor); | 1168 DCHECK(right_anchor); |
| 1135 | 1169 |
| 1136 // Add the page actions in reverse order, so that the child views are | 1170 // Add the page actions in reverse order, so that the child views are |
| 1137 // inserted in left-to-right order for accessibility. | 1171 // inserted in left-to-right order for accessibility. |
| 1138 for (int i = page_actions_.size() - 1; i >= 0; --i) { | 1172 for (int i = page_actions_.size() - 1; i >= 0; --i) { |
| 1139 page_action_views_[i] = new PageActionWithBadgeView( | 1173 page_action_views_[i] = new PageActionWithBadgeView( |
| 1140 delegate_->CreatePageActionImageView(this, page_actions_[i])); | 1174 delegate_->CreatePageActionImageView(this, page_actions_[i])); |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1495 } | 1529 } |
| 1496 | 1530 |
| 1497 void LocationBarView::CleanupFadeAnimation() { | 1531 void LocationBarView::CleanupFadeAnimation() { |
| 1498 // Since we're no longer animating we don't need our layer. | 1532 // Since we're no longer animating we don't need our layer. |
| 1499 SetPaintToLayer(false); | 1533 SetPaintToLayer(false); |
| 1500 // Bubble labels don't need a transparent background anymore. | 1534 // Bubble labels don't need a transparent background anymore. |
| 1501 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); | 1535 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); |
| 1502 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); | 1536 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); |
| 1503 } | 1537 } |
| 1504 #endif // USE_AURA | 1538 #endif // USE_AURA |
| OLD | NEW |