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 24 matching lines...) Expand all Loading... | |
35 #include "chrome/browser/ui/views/location_bar/chrome_to_mobile_view.h" | 35 #include "chrome/browser/ui/views/location_bar/chrome_to_mobile_view.h" |
36 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 36 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
37 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" | 37 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" |
38 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 38 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" |
39 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 39 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
40 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 40 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
41 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" | 41 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
42 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" | 42 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" |
43 #include "chrome/browser/ui/views/location_bar/star_view.h" | 43 #include "chrome/browser/ui/views/location_bar/star_view.h" |
44 #include "chrome/browser/ui/views/location_bar/suggested_text_view.h" | 44 #include "chrome/browser/ui/views/location_bar/suggested_text_view.h" |
45 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" | |
46 #include "chrome/browser/ui/views/location_bar/zoom_view.h" | |
45 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 47 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
46 #include "chrome/browser/ui/views/omnibox/omnibox_views.h" | 48 #include "chrome/browser/ui/views/omnibox/omnibox_views.h" |
47 #include "chrome/common/chrome_notification_types.h" | 49 #include "chrome/common/chrome_notification_types.h" |
48 #include "chrome/common/chrome_switches.h" | 50 #include "chrome/common/chrome_switches.h" |
49 #include "chrome/common/extensions/extension_switch_utils.h" | 51 #include "chrome/common/extensions/extension_switch_utils.h" |
50 #include "chrome/common/pref_names.h" | 52 #include "chrome/common/pref_names.h" |
51 #include "content/public/browser/notification_service.h" | 53 #include "content/public/browser/notification_service.h" |
52 #include "content/public/browser/render_widget_host_view.h" | 54 #include "content/public/browser/render_widget_host_view.h" |
53 #include "content/public/browser/web_contents.h" | 55 #include "content/public/browser/web_contents.h" |
54 #include "grit/generated_resources.h" | 56 #include "grit/generated_resources.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 disposition_(CURRENT_TAB), | 137 disposition_(CURRENT_TAB), |
136 transition_(content::PageTransitionFromInt( | 138 transition_(content::PageTransitionFromInt( |
137 content::PAGE_TRANSITION_TYPED | | 139 content::PAGE_TRANSITION_TYPED | |
138 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), | 140 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), |
139 location_icon_view_(NULL), | 141 location_icon_view_(NULL), |
140 ev_bubble_view_(NULL), | 142 ev_bubble_view_(NULL), |
141 location_entry_view_(NULL), | 143 location_entry_view_(NULL), |
142 selected_keyword_view_(NULL), | 144 selected_keyword_view_(NULL), |
143 suggested_text_view_(NULL), | 145 suggested_text_view_(NULL), |
144 keyword_hint_view_(NULL), | 146 keyword_hint_view_(NULL), |
147 zoom_view_(NULL), | |
145 star_view_(NULL), | 148 star_view_(NULL), |
146 action_box_button_view_(NULL), | 149 action_box_button_view_(NULL), |
147 chrome_to_mobile_view_(NULL), | 150 chrome_to_mobile_view_(NULL), |
148 mode_(mode), | 151 mode_(mode), |
149 show_focus_rect_(false), | 152 show_focus_rect_(false), |
150 template_url_service_(NULL), | 153 template_url_service_(NULL), |
151 animation_offset_(0), | 154 animation_offset_(0), |
152 ALLOW_THIS_IN_INITIALIZER_LIST(view_to_focus_(this)) { | 155 ALLOW_THIS_IN_INITIALIZER_LIST(view_to_focus_(this)) { |
153 set_id(VIEW_ID_LOCATION_BAR); | 156 set_id(VIEW_ID_LOCATION_BAR); |
154 | 157 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
243 ChromeToMobileService::IsChromeToMobileEnabled()) { | 246 ChromeToMobileService::IsChromeToMobileEnabled()) { |
244 chrome_to_mobile_view_ = new ChromeToMobileView(this, command_updater_); | 247 chrome_to_mobile_view_ = new ChromeToMobileView(this, command_updater_); |
245 AddChildView(chrome_to_mobile_view_); | 248 AddChildView(chrome_to_mobile_view_); |
246 ChromeToMobileService* service = | 249 ChromeToMobileService* service = |
247 ChromeToMobileServiceFactory::GetForProfile(profile_); | 250 ChromeToMobileServiceFactory::GetForProfile(profile_); |
248 service->RequestMobileListUpdate(); | 251 service->RequestMobileListUpdate(); |
249 chrome_to_mobile_view_->SetVisible(service->HasDevices()); | 252 chrome_to_mobile_view_->SetVisible(service->HasDevices()); |
250 } | 253 } |
251 } | 254 } |
252 | 255 |
256 zoom_view_ = new ZoomView(model_); | |
Peter Kasting
2012/06/26 23:23:39
Nit: Move this to just below the content settings
Kyle Horimoto
2012/06/30 00:22:50
Done.
| |
257 AddChildView(zoom_view_); | |
258 | |
253 registrar_.Add(this, | 259 registrar_.Add(this, |
254 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, | 260 chrome::NOTIFICATION_EXTENSION_LOCATION_BAR_UPDATED, |
255 content::Source<Profile>(profile_)); | 261 content::Source<Profile>(profile_)); |
256 | 262 |
257 // Initialize the location entry. We do this to avoid a black flash which is | 263 // Initialize the location entry. We do this to avoid a black flash which is |
258 // visible when the location entry has just been initialized. | 264 // visible when the location entry has just been initialized. |
259 Update(NULL); | 265 Update(NULL); |
260 | 266 |
261 OnChanged(); | 267 OnChanged(); |
262 } | 268 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 animation_offset_ = offset; | 341 animation_offset_ = offset; |
336 } | 342 } |
337 | 343 |
338 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { | 344 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { |
339 bool star_enabled = star_view_ && !model_->input_in_progress() && | 345 bool star_enabled = star_view_ && !model_->input_in_progress() && |
340 edit_bookmarks_enabled_.GetValue(); | 346 edit_bookmarks_enabled_.GetValue(); |
341 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 347 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
342 if (star_view_) | 348 if (star_view_) |
343 star_view_->SetVisible(star_enabled); | 349 star_view_->SetVisible(star_enabled); |
344 | 350 |
351 zoom_view_->Update(); | |
Peter Kasting
2012/06/26 23:23:39
Nit: Move the RefreshXXX() calls below to the top
Kyle Horimoto
2012/06/30 00:22:50
Done.
| |
352 | |
345 bool enabled = chrome_to_mobile_view_ && !model_->input_in_progress() && | 353 bool enabled = chrome_to_mobile_view_ && !model_->input_in_progress() && |
346 ChromeToMobileServiceFactory::GetForProfile(profile_)->HasDevices(); | 354 ChromeToMobileServiceFactory::GetForProfile(profile_)->HasDevices(); |
347 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, enabled); | 355 command_updater_->UpdateCommandEnabled(IDC_CHROME_TO_MOBILE_PAGE, enabled); |
348 | 356 |
349 RefreshContentSettingViews(); | 357 RefreshContentSettingViews(); |
350 RefreshPageActionViews(); | 358 RefreshPageActionViews(); |
351 // Don't Update in app launcher mode so that the location entry does not show | 359 // Don't Update in app launcher mode so that the location entry does not show |
352 // a URL or security background. | 360 // a URL or security background. |
353 if (mode_ != APP_LAUNCHER) | 361 if (mode_ != APP_LAUNCHER) |
354 location_entry_->Update(tab_for_state_restoring); | 362 location_entry_->Update(tab_for_state_restoring); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 void LocationBarView::SetStarToggled(bool on) { | 443 void LocationBarView::SetStarToggled(bool on) { |
436 if (star_view_) | 444 if (star_view_) |
437 star_view_->SetToggled(on); | 445 star_view_->SetToggled(on); |
438 } | 446 } |
439 | 447 |
440 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { | 448 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { |
441 browser::ShowBookmarkBubbleView(star_view_, profile_, url, | 449 browser::ShowBookmarkBubbleView(star_view_, profile_, url, |
442 newly_bookmarked); | 450 newly_bookmarked); |
443 } | 451 } |
444 | 452 |
453 void LocationBarView::SetZoomIconTooltipPercent(int zoom_percent) { | |
454 zoom_view_->SetZoomIconTooltipPercent(zoom_percent); | |
455 } | |
456 | |
457 void LocationBarView::SetZoomIconState( | |
458 ZoomController::ZoomIconState zoom_icon_state) { | |
459 zoom_view_->SetZoomIconState(zoom_icon_state); | |
460 } | |
461 | |
462 void LocationBarView::ShowZoomBubble(int zoom_percent) { | |
463 ZoomBubbleView::ShowBubble(zoom_view_, zoom_percent, true); | |
464 } | |
465 | |
445 void LocationBarView::ShowChromeToMobileBubble() { | 466 void LocationBarView::ShowChromeToMobileBubble() { |
446 browser::ShowChromeToMobileBubbleView(chrome_to_mobile_view_, profile_); | 467 browser::ShowChromeToMobileBubbleView(chrome_to_mobile_view_, profile_); |
447 } | 468 } |
448 | 469 |
449 gfx::Point LocationBarView::GetLocationEntryOrigin() const { | 470 gfx::Point LocationBarView::GetLocationEntryOrigin() const { |
450 gfx::Point origin(location_entry_view_->bounds().origin()); | 471 gfx::Point origin(location_entry_view_->bounds().origin()); |
451 // If the UI layout is RTL, the coordinate system is not transformed and | 472 // If the UI layout is RTL, the coordinate system is not transformed and |
452 // therefore we need to adjust the X coordinate so that bubble appears on the | 473 // therefore we need to adjust the X coordinate so that bubble appears on the |
453 // right hand side of the location bar. | 474 // right hand side of the location bar. |
454 if (base::i18n::IsRTL()) | 475 if (base::i18n::IsRTL()) |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
556 // We'll adjust this width and take it out of |entry_width| below. | 577 // We'll adjust this width and take it out of |entry_width| below. |
557 } else { | 578 } else { |
558 location_icon_view_->SetVisible(true); | 579 location_icon_view_->SetVisible(true); |
559 location_icon_width = location_icon_view_->GetPreferredSize().width(); | 580 location_icon_width = location_icon_view_->GetPreferredSize().width(); |
560 entry_width -= (kEdgeThickness + GetEdgeItemPadding() + | 581 entry_width -= (kEdgeThickness + GetEdgeItemPadding() + |
561 location_icon_width + kItemEditPadding); | 582 location_icon_width + kItemEditPadding); |
562 } | 583 } |
563 | 584 |
564 if (star_view_ && star_view_->visible()) | 585 if (star_view_ && star_view_->visible()) |
565 entry_width -= star_view_->GetPreferredSize().width() + GetItemPadding(); | 586 entry_width -= star_view_->GetPreferredSize().width() + GetItemPadding(); |
566 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) | 587 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) { |
567 entry_width -= chrome_to_mobile_view_->GetPreferredSize().width() + | 588 entry_width -= chrome_to_mobile_view_->GetPreferredSize().width() + |
568 GetItemPadding(); | 589 GetItemPadding(); |
590 } | |
591 entry_width -= zoom_view_->GetPreferredSize().width() + GetItemPadding(); | |
Peter Kasting
2012/06/26 23:23:39
Nit: Move this to just above the content settings
Kyle Horimoto
2012/06/30 00:22:50
Done.
| |
569 int action_box_button_width = location_height; | 592 int action_box_button_width = location_height; |
570 if (action_box_button_view_) | 593 if (action_box_button_view_) |
571 entry_width -= action_box_button_width + GetItemPadding(); | 594 entry_width -= action_box_button_width + GetItemPadding(); |
572 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 595 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
573 i != page_action_views_.end(); ++i) { | 596 i != page_action_views_.end(); ++i) { |
574 if ((*i)->visible()) | 597 if ((*i)->visible()) |
575 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); | 598 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); |
576 } | 599 } |
577 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 600 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
578 i != content_setting_views_.end(); ++i) { | 601 i != content_setting_views_.end(); ++i) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
651 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) { | 674 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) { |
652 offset += chrome_to_mobile_view_->GetBuiltInHorizontalPadding(); | 675 offset += chrome_to_mobile_view_->GetBuiltInHorizontalPadding(); |
653 int icon_width = chrome_to_mobile_view_->GetPreferredSize().width(); | 676 int icon_width = chrome_to_mobile_view_->GetPreferredSize().width(); |
654 offset -= icon_width; | 677 offset -= icon_width; |
655 chrome_to_mobile_view_->SetBounds(offset, location_y, | 678 chrome_to_mobile_view_->SetBounds(offset, location_y, |
656 icon_width, location_height); | 679 icon_width, location_height); |
657 offset -= GetItemPadding() - | 680 offset -= GetItemPadding() - |
658 chrome_to_mobile_view_->GetBuiltInHorizontalPadding(); | 681 chrome_to_mobile_view_->GetBuiltInHorizontalPadding(); |
659 } | 682 } |
660 | 683 |
684 int zoom_width = zoom_view_->GetPreferredSize().width(); | |
Peter Kasting
2012/06/26 23:23:39
Nit: Move this to just above the content settings
Kyle Horimoto
2012/06/30 00:22:50
Done.
| |
685 offset -= zoom_width; | |
686 zoom_view_->SetBounds(offset, location_y, zoom_width, location_height); | |
687 offset -= GetItemPadding(); | |
688 | |
661 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 689 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
662 i != page_action_views_.end(); ++i) { | 690 i != page_action_views_.end(); ++i) { |
663 if ((*i)->visible()) { | 691 if ((*i)->visible()) { |
664 offset += (*i)->GetBuiltInHorizontalPadding(); | 692 offset += (*i)->GetBuiltInHorizontalPadding(); |
665 int page_action_width = (*i)->GetPreferredSize().width(); | 693 int page_action_width = (*i)->GetPreferredSize().width(); |
666 offset -= page_action_width; | 694 offset -= page_action_width; |
667 (*i)->SetBounds(offset, location_y, page_action_width, location_height); | 695 (*i)->SetBounds(offset, location_y, page_action_width, location_height); |
668 offset -= GetItemPadding() - (*i)->GetBuiltInHorizontalPadding(); | 696 offset -= GetItemPadding() - (*i)->GetBuiltInHorizontalPadding(); |
669 } | 697 } |
670 } | 698 } |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1345 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1373 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
1346 int total_height = | 1374 int total_height = |
1347 use_preferred_size ? GetPreferredSize().height() : height(); | 1375 use_preferred_size ? GetPreferredSize().height() : height(); |
1348 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); | 1376 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); |
1349 } | 1377 } |
1350 | 1378 |
1351 bool LocationBarView::HasValidSuggestText() const { | 1379 bool LocationBarView::HasValidSuggestText() const { |
1352 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1380 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
1353 !suggested_text_view_->text().empty(); | 1381 !suggested_text_view_->text().empty(); |
1354 } | 1382 } |
OLD | NEW |