OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 suggested_text_view_(NULL), | 117 suggested_text_view_(NULL), |
118 #endif | 118 #endif |
119 keyword_hint_view_(NULL), | 119 keyword_hint_view_(NULL), |
120 star_view_(NULL), | 120 star_view_(NULL), |
121 mode_(mode), | 121 mode_(mode), |
122 show_focus_rect_(false), | 122 show_focus_rect_(false), |
123 bubble_type_(FirstRun::MINIMAL_BUBBLE), | 123 bubble_type_(FirstRun::MINIMAL_BUBBLE), |
124 template_url_model_(NULL), | 124 template_url_model_(NULL), |
125 animation_offset_(0) { | 125 animation_offset_(0) { |
126 DCHECK(profile_); | 126 DCHECK(profile_); |
127 SetID(VIEW_ID_LOCATION_BAR); | 127 set_id(VIEW_ID_LOCATION_BAR); |
128 SetFocusable(true); | 128 set_focusable(true); |
129 | 129 |
130 if (mode_ == NORMAL) | 130 if (mode_ == NORMAL) |
131 painter_.reset(new views::HorizontalPainter(kNormalModeBackgroundImages)); | 131 painter_.reset(new views::HorizontalPainter(kNormalModeBackgroundImages)); |
132 | 132 |
133 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, | 133 edit_bookmarks_enabled_.Init(prefs::kEditBookmarksEnabled, |
134 profile_->GetPrefs(), this); | 134 profile_->GetPrefs(), this); |
135 } | 135 } |
136 | 136 |
137 LocationBarView::~LocationBarView() { | 137 LocationBarView::~LocationBarView() { |
138 if (template_url_model_) | 138 if (template_url_model_) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 #if defined(OS_WIN) | 172 #if defined(OS_WIN) |
173 location_entry_.reset(new OmniboxViewWin(font_, this, model_, this, | 173 location_entry_.reset(new OmniboxViewWin(font_, this, model_, this, |
174 GetWidget()->GetNativeView(), profile_, browser_->command_updater(), | 174 GetWidget()->GetNativeView(), profile_, browser_->command_updater(), |
175 mode_ == POPUP, this)); | 175 mode_ == POPUP, this)); |
176 #else | 176 #else |
177 location_entry_.reset(OmniboxViewGtk::Create(this, model_, profile_, | 177 location_entry_.reset(OmniboxViewGtk::Create(this, model_, profile_, |
178 browser_->command_updater(), mode_ == POPUP, this)); | 178 browser_->command_updater(), mode_ == POPUP, this)); |
179 #endif | 179 #endif |
180 | 180 |
181 location_entry_view_ = location_entry_->AddToView(this); | 181 location_entry_view_ = location_entry_->AddToView(this); |
182 location_entry_view_->SetID(VIEW_ID_AUTOCOMPLETE); | 182 location_entry_view_->set_id(VIEW_ID_AUTOCOMPLETE); |
183 | 183 |
184 selected_keyword_view_ = new SelectedKeywordView( | 184 selected_keyword_view_ = new SelectedKeywordView( |
185 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, | 185 kSelectedKeywordBackgroundImages, IDR_KEYWORD_SEARCH_MAGNIFIER, |
186 GetColor(ToolbarModel::NONE, TEXT), profile_), | 186 GetColor(ToolbarModel::NONE, TEXT), profile_), |
187 AddChildView(selected_keyword_view_); | 187 AddChildView(selected_keyword_view_); |
188 selected_keyword_view_->SetFont(font_); | 188 selected_keyword_view_->SetFont(font_); |
189 selected_keyword_view_->SetVisible(false); | 189 selected_keyword_view_->SetVisible(false); |
190 | 190 |
191 SkColor dimmed_text = GetColor(ToolbarModel::NONE, DEEMPHASIZED_TEXT); | 191 SkColor dimmed_text = GetColor(ToolbarModel::NONE, DEEMPHASIZED_TEXT); |
192 | 192 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 ev_bubble_view_->SetLabel(model_->GetEVCertName()); | 495 ev_bubble_view_->SetLabel(model_->GetEVCertName()); |
496 ev_bubble_width = ev_bubble_view_->GetPreferredSize().width(); | 496 ev_bubble_width = ev_bubble_view_->GetPreferredSize().width(); |
497 // We'll adjust this width and take it out of |entry_width| below. | 497 // We'll adjust this width and take it out of |entry_width| below. |
498 } else { | 498 } else { |
499 location_icon_view_->SetVisible(true); | 499 location_icon_view_->SetVisible(true); |
500 location_icon_width = location_icon_view_->GetPreferredSize().width(); | 500 location_icon_width = location_icon_view_->GetPreferredSize().width(); |
501 entry_width -= (kEdgeThickness + kEdgeItemPadding + location_icon_width + | 501 entry_width -= (kEdgeThickness + kEdgeItemPadding + location_icon_width + |
502 kItemEditPadding); | 502 kItemEditPadding); |
503 } | 503 } |
504 | 504 |
505 if (star_view_ && star_view_->IsVisible()) | 505 if (star_view_ && star_view_->visible()) |
506 entry_width -= star_view_->GetPreferredSize().width() + kItemPadding; | 506 entry_width -= star_view_->GetPreferredSize().width() + kItemPadding; |
507 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 507 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
508 i != page_action_views_.end(); ++i) { | 508 i != page_action_views_.end(); ++i) { |
509 if ((*i)->IsVisible()) | 509 if ((*i)->visible()) |
510 entry_width -= ((*i)->GetPreferredSize().width() + kItemPadding); | 510 entry_width -= ((*i)->GetPreferredSize().width() + kItemPadding); |
511 } | 511 } |
512 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 512 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
513 i != content_setting_views_.end(); ++i) { | 513 i != content_setting_views_.end(); ++i) { |
514 if ((*i)->IsVisible()) | 514 if ((*i)->visible()) |
515 entry_width -= ((*i)->GetPreferredSize().width() + kItemPadding); | 515 entry_width -= ((*i)->GetPreferredSize().width() + kItemPadding); |
516 } | 516 } |
517 // The gap between the edit and whatever is to its right is shortened. | 517 // The gap between the edit and whatever is to its right is shortened. |
518 entry_width += kEditInternalSpace; | 518 entry_width += kEditInternalSpace; |
519 | 519 |
520 // Size the EV bubble. We do this after taking the star/page actions/content | 520 // Size the EV bubble. We do this after taking the star/page actions/content |
521 // settings out of |entry_width| so we won't take too much space. | 521 // settings out of |entry_width| so we won't take too much space. |
522 if (ev_bubble_width) { | 522 if (ev_bubble_width) { |
523 // Try to elide the bubble to be no larger than half the total available | 523 // Try to elide the bubble to be no larger than half the total available |
524 // space, but never elide it any smaller than 150 px. | 524 // space, but never elide it any smaller than 150 px. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 selected_keyword_view_->set_is_extension_icon(false); | 565 selected_keyword_view_->set_is_extension_icon(false); |
566 } | 566 } |
567 } | 567 } |
568 } else if (show_keyword_hint) { | 568 } else if (show_keyword_hint) { |
569 if (keyword_hint_view_->keyword() != keyword) | 569 if (keyword_hint_view_->keyword() != keyword) |
570 keyword_hint_view_->SetKeyword(keyword); | 570 keyword_hint_view_->SetKeyword(keyword); |
571 } | 571 } |
572 | 572 |
573 // Lay out items to the right of the edit field. | 573 // Lay out items to the right of the edit field. |
574 int offset = width() - kEdgeThickness - kEdgeItemPadding; | 574 int offset = width() - kEdgeThickness - kEdgeItemPadding; |
575 if (star_view_ && star_view_->IsVisible()) { | 575 if (star_view_ && star_view_->visible()) { |
576 int star_width = star_view_->GetPreferredSize().width(); | 576 int star_width = star_view_->GetPreferredSize().width(); |
577 offset -= star_width; | 577 offset -= star_width; |
578 star_view_->SetBounds(offset, location_y, star_width, location_height); | 578 star_view_->SetBounds(offset, location_y, star_width, location_height); |
579 offset -= kItemPadding; | 579 offset -= kItemPadding; |
580 } | 580 } |
581 | 581 |
582 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 582 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
583 i != page_action_views_.end(); ++i) { | 583 i != page_action_views_.end(); ++i) { |
584 if ((*i)->IsVisible()) { | 584 if ((*i)->visible()) { |
585 int page_action_width = (*i)->GetPreferredSize().width(); | 585 int page_action_width = (*i)->GetPreferredSize().width(); |
586 offset -= page_action_width; | 586 offset -= page_action_width; |
587 (*i)->SetBounds(offset, location_y, page_action_width, location_height); | 587 (*i)->SetBounds(offset, location_y, page_action_width, location_height); |
588 offset -= kItemPadding; | 588 offset -= kItemPadding; |
589 } | 589 } |
590 } | 590 } |
591 // We use a reverse_iterator here because we're laying out the views from | 591 // We use a reverse_iterator here because we're laying out the views from |
592 // right to left but in the vector they're ordered left to right. | 592 // right to left but in the vector they're ordered left to right. |
593 for (ContentSettingViews::const_reverse_iterator | 593 for (ContentSettingViews::const_reverse_iterator |
594 i(content_setting_views_.rbegin()); i != content_setting_views_.rend(); | 594 i(content_setting_views_.rbegin()); i != content_setting_views_.rend(); |
595 ++i) { | 595 ++i) { |
596 if ((*i)->IsVisible()) { | 596 if ((*i)->visible()) { |
597 int content_blocked_width = (*i)->GetPreferredSize().width(); | 597 int content_blocked_width = (*i)->GetPreferredSize().width(); |
598 offset -= content_blocked_width; | 598 offset -= content_blocked_width; |
599 (*i)->SetBounds(offset, location_y, content_blocked_width, | 599 (*i)->SetBounds(offset, location_y, content_blocked_width, |
600 location_height); | 600 location_height); |
601 offset -= kItemPadding; | 601 offset -= kItemPadding; |
602 } | 602 } |
603 } | 603 } |
604 | 604 |
605 // Now lay out items to the left of the edit field. | 605 // Now lay out items to the left of the edit field. |
606 if (location_icon_view_->IsVisible()) { | 606 if (location_icon_view_->visible()) { |
607 location_icon_view_->SetBounds(kEdgeThickness + kEdgeItemPadding, | 607 location_icon_view_->SetBounds(kEdgeThickness + kEdgeItemPadding, |
608 location_y, location_icon_width, location_height); | 608 location_y, location_icon_width, location_height); |
609 offset = location_icon_view_->bounds().right() + kItemEditPadding; | 609 offset = location_icon_view_->bounds().right() + kItemEditPadding; |
610 } else if (ev_bubble_view_->IsVisible()) { | 610 } else if (ev_bubble_view_->visible()) { |
611 ev_bubble_view_->SetBounds(kEdgeThickness + kBubbleHorizontalPadding, | 611 ev_bubble_view_->SetBounds(kEdgeThickness + kBubbleHorizontalPadding, |
612 location_y + kBubbleVerticalPadding, ev_bubble_width, | 612 location_y + kBubbleVerticalPadding, ev_bubble_width, |
613 ev_bubble_view_->GetPreferredSize().height()); | 613 ev_bubble_view_->GetPreferredSize().height()); |
614 offset = ev_bubble_view_->bounds().right() + kItemEditPadding; | 614 offset = ev_bubble_view_->bounds().right() + kItemEditPadding; |
615 } else { | 615 } else { |
616 offset = kEdgeThickness + | 616 offset = kEdgeThickness + |
617 (show_selected_keyword ? kBubbleHorizontalPadding : kEdgeEditPadding); | 617 (show_selected_keyword ? kBubbleHorizontalPadding : kEdgeEditPadding); |
618 } | 618 } |
619 | 619 |
620 // Now lay out the edit field and views that autocollapse to give it more | 620 // Now lay out the edit field and views that autocollapse to give it more |
621 // room. | 621 // room. |
622 gfx::Rect location_bounds(offset, location_y, entry_width, location_height); | 622 gfx::Rect location_bounds(offset, location_y, entry_width, location_height); |
623 if (show_selected_keyword) { | 623 if (show_selected_keyword) { |
624 selected_keyword_view_->SetBounds(0, location_y + kBubbleVerticalPadding, | 624 selected_keyword_view_->SetBounds(0, location_y + kBubbleVerticalPadding, |
625 0, selected_keyword_view_->GetPreferredSize().height()); | 625 0, selected_keyword_view_->GetPreferredSize().height()); |
626 LayoutView(selected_keyword_view_, kItemEditPadding, available_width, | 626 LayoutView(selected_keyword_view_, kItemEditPadding, available_width, |
627 true, &location_bounds); | 627 true, &location_bounds); |
628 location_bounds.set_x(selected_keyword_view_->IsVisible() ? | 628 location_bounds.set_x(selected_keyword_view_->visible() ? |
629 (offset + selected_keyword_view_->width() + kItemEditPadding) : | 629 (offset + selected_keyword_view_->width() + kItemEditPadding) : |
630 (kEdgeThickness + kEdgeEditPadding)); | 630 (kEdgeThickness + kEdgeEditPadding)); |
631 } else if (show_keyword_hint) { | 631 } else if (show_keyword_hint) { |
632 keyword_hint_view_->SetBounds(0, location_y, 0, location_height); | 632 keyword_hint_view_->SetBounds(0, location_y, 0, location_height); |
633 // Tricky: |entry_width| has already been enlarged by |kEditInternalSpace|. | 633 // Tricky: |entry_width| has already been enlarged by |kEditInternalSpace|. |
634 // But if we add a trailing view, it needs to have that enlargement be to | 634 // But if we add a trailing view, it needs to have that enlargement be to |
635 // its left. So we undo the enlargement, then include it in the padding for | 635 // its left. So we undo the enlargement, then include it in the padding for |
636 // the added view. | 636 // the added view. |
637 location_bounds.Inset(0, 0, kEditInternalSpace, 0); | 637 location_bounds.Inset(0, 0, kEditInternalSpace, 0); |
638 LayoutView(keyword_hint_view_, kItemEditPadding, available_width, false, | 638 LayoutView(keyword_hint_view_, kItemEditPadding, available_width, false, |
639 &location_bounds); | 639 &location_bounds); |
640 if (!keyword_hint_view_->IsVisible()) { | 640 if (!keyword_hint_view_->visible()) { |
641 // Put back the enlargement that we undid above. | 641 // Put back the enlargement that we undid above. |
642 location_bounds.Inset(0, 0, -kEditInternalSpace, 0); | 642 location_bounds.Inset(0, 0, -kEditInternalSpace, 0); |
643 } | 643 } |
644 } | 644 } |
645 | 645 |
646 #if defined(OS_WIN) | 646 #if defined(OS_WIN) |
647 // Layout out the suggested text view right aligned to the location | 647 // Layout out the suggested text view right aligned to the location |
648 // entry. Only show the suggested text if we can fit the text from one | 648 // entry. Only show the suggested text if we can fit the text from one |
649 // character before the end of the selection to the end of the text and the | 649 // character before the end of the selection to the end of the text and the |
650 // suggested text. If we can't it means either the suggested text is too big, | 650 // suggested text. If we can't it means either the suggested text is too big, |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 int padding, | 874 int padding, |
875 int available_width, | 875 int available_width, |
876 bool leading, | 876 bool leading, |
877 gfx::Rect* bounds) { | 877 gfx::Rect* bounds) { |
878 DCHECK(view && bounds); | 878 DCHECK(view && bounds); |
879 gfx::Size view_size = view->GetPreferredSize(); | 879 gfx::Size view_size = view->GetPreferredSize(); |
880 if ((view_size.width() + padding) > available_width) | 880 if ((view_size.width() + padding) > available_width) |
881 view_size = view->GetMinimumSize(); | 881 view_size = view->GetMinimumSize(); |
882 int desired_width = view_size.width() + padding; | 882 int desired_width = view_size.width() + padding; |
883 view->SetVisible(desired_width < bounds->width()); | 883 view->SetVisible(desired_width < bounds->width()); |
884 if (view->IsVisible()) { | 884 if (view->visible()) { |
885 view->SetBounds( | 885 view->SetBounds( |
886 leading ? bounds->x() : (bounds->right() - view_size.width()), | 886 leading ? bounds->x() : (bounds->right() - view_size.width()), |
887 view->y(), view_size.width(), view->height()); | 887 view->y(), view_size.width(), view->height()); |
888 bounds->set_width(bounds->width() - desired_width); | 888 bounds->set_width(bounds->width() - desired_width); |
889 } | 889 } |
890 } | 890 } |
891 | 891 |
892 void LocationBarView::RefreshContentSettingViews() { | 892 void LocationBarView::RefreshContentSettingViews() { |
893 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 893 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
894 i != content_setting_views_.end(); ++i) { | 894 i != content_setting_views_.end(); ++i) { |
(...skipping 13 matching lines...) Expand all Loading... |
908 if (mode_ != NORMAL) | 908 if (mode_ != NORMAL) |
909 return; | 909 return; |
910 | 910 |
911 ExtensionService* service = profile_->GetExtensionService(); | 911 ExtensionService* service = profile_->GetExtensionService(); |
912 if (!service) | 912 if (!service) |
913 return; | 913 return; |
914 | 914 |
915 std::map<ExtensionAction*, bool> old_visibility; | 915 std::map<ExtensionAction*, bool> old_visibility; |
916 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 916 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
917 i != page_action_views_.end(); ++i) | 917 i != page_action_views_.end(); ++i) |
918 old_visibility[(*i)->image_view()->page_action()] = (*i)->IsVisible(); | 918 old_visibility[(*i)->image_view()->page_action()] = (*i)->visible(); |
919 | 919 |
920 // Remember the previous visibility of the page actions so that we can | 920 // Remember the previous visibility of the page actions so that we can |
921 // notify when this changes. | 921 // notify when this changes. |
922 std::vector<ExtensionAction*> page_actions; | 922 std::vector<ExtensionAction*> page_actions; |
923 for (size_t i = 0; i < service->extensions()->size(); ++i) { | 923 for (size_t i = 0; i < service->extensions()->size(); ++i) { |
924 if (service->extensions()->at(i)->page_action()) | 924 if (service->extensions()->at(i)->page_action()) |
925 page_actions.push_back(service->extensions()->at(i)->page_action()); | 925 page_actions.push_back(service->extensions()->at(i)->page_action()); |
926 } | 926 } |
927 | 927 |
928 // On startup we sometimes haven't loaded any extensions. This makes sure | 928 // On startup we sometimes haven't loaded any extensions. This makes sure |
(...skipping 18 matching lines...) Expand all Loading... |
947 GURL url = GURL(WideToUTF8(model_->GetText())); | 947 GURL url = GURL(WideToUTF8(model_->GetText())); |
948 | 948 |
949 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 949 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
950 i != page_action_views_.end(); ++i) { | 950 i != page_action_views_.end(); ++i) { |
951 (*i)->UpdateVisibility(model_->input_in_progress() ? NULL : contents, | 951 (*i)->UpdateVisibility(model_->input_in_progress() ? NULL : contents, |
952 url); | 952 url); |
953 | 953 |
954 // Check if the visibility of the action changed and notify if it did. | 954 // Check if the visibility of the action changed and notify if it did. |
955 ExtensionAction* action = (*i)->image_view()->page_action(); | 955 ExtensionAction* action = (*i)->image_view()->page_action(); |
956 if (old_visibility.find(action) == old_visibility.end() || | 956 if (old_visibility.find(action) == old_visibility.end() || |
957 old_visibility[action] != (*i)->IsVisible()) { | 957 old_visibility[action] != (*i)->visible()) { |
958 NotificationService::current()->Notify( | 958 NotificationService::current()->Notify( |
959 NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, | 959 NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, |
960 Source<ExtensionAction>(action), | 960 Source<ExtensionAction>(action), |
961 Details<TabContents>(contents)); | 961 Details<TabContents>(contents)); |
962 } | 962 } |
963 } | 963 } |
964 } | 964 } |
965 } | 965 } |
966 | 966 |
967 #if defined(OS_WIN) | 967 #if defined(OS_WIN) |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 } | 999 } |
1000 | 1000 |
1001 bool LocationBarView::SkipDefaultKeyEventProcessing( | 1001 bool LocationBarView::SkipDefaultKeyEventProcessing( |
1002 const views::KeyEvent& event) { | 1002 const views::KeyEvent& event) { |
1003 #if defined(OS_WIN) | 1003 #if defined(OS_WIN) |
1004 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { | 1004 if (views::FocusManager::IsTabTraversalKeyEvent(event)) { |
1005 if (HasValidSuggestText()) { | 1005 if (HasValidSuggestText()) { |
1006 // Return true so that the edit sees the tab and commits the suggestion. | 1006 // Return true so that the edit sees the tab and commits the suggestion. |
1007 return true; | 1007 return true; |
1008 } | 1008 } |
1009 if (keyword_hint_view_->IsVisible() && !event.IsShiftDown()) { | 1009 if (keyword_hint_view_->visible() && !event.IsShiftDown()) { |
1010 // Return true so the edit gets the tab event and enters keyword mode. | 1010 // Return true so the edit gets the tab event and enters keyword mode. |
1011 return true; | 1011 return true; |
1012 } | 1012 } |
1013 | 1013 |
1014 // If the caret is not at the end, then tab moves the caret to the end. | 1014 // If the caret is not at the end, then tab moves the caret to the end. |
1015 if (!location_entry_->IsCaretAtEnd()) | 1015 if (!location_entry_->IsCaretAtEnd()) |
1016 return true; | 1016 return true; |
1017 | 1017 |
1018 // Tab while showing instant commits instant immediately. | 1018 // Tab while showing instant commits instant immediately. |
1019 // Return true so that focus traversal isn't attempted. The edit ends | 1019 // Return true so that focus traversal isn't attempted. The edit ends |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 return this; | 1140 return this; |
1141 } | 1141 } |
1142 | 1142 |
1143 int LocationBarView::PageActionCount() { | 1143 int LocationBarView::PageActionCount() { |
1144 return page_action_views_.size(); | 1144 return page_action_views_.size(); |
1145 } | 1145 } |
1146 | 1146 |
1147 int LocationBarView::PageActionVisibleCount() { | 1147 int LocationBarView::PageActionVisibleCount() { |
1148 int result = 0; | 1148 int result = 0; |
1149 for (size_t i = 0; i < page_action_views_.size(); i++) { | 1149 for (size_t i = 0; i < page_action_views_.size(); i++) { |
1150 if (page_action_views_[i]->IsVisible()) | 1150 if (page_action_views_[i]->visible()) |
1151 ++result; | 1151 ++result; |
1152 } | 1152 } |
1153 return result; | 1153 return result; |
1154 } | 1154 } |
1155 | 1155 |
1156 ExtensionAction* LocationBarView::GetPageAction(size_t index) { | 1156 ExtensionAction* LocationBarView::GetPageAction(size_t index) { |
1157 if (index < page_action_views_.size()) | 1157 if (index < page_action_views_.size()) |
1158 return page_action_views_[index]->image_view()->page_action(); | 1158 return page_action_views_[index]->image_view()->page_action(); |
1159 | 1159 |
1160 NOTREACHED(); | 1160 NOTREACHED(); |
1161 return NULL; | 1161 return NULL; |
1162 } | 1162 } |
1163 | 1163 |
1164 ExtensionAction* LocationBarView::GetVisiblePageAction(size_t index) { | 1164 ExtensionAction* LocationBarView::GetVisiblePageAction(size_t index) { |
1165 size_t current = 0; | 1165 size_t current = 0; |
1166 for (size_t i = 0; i < page_action_views_.size(); ++i) { | 1166 for (size_t i = 0; i < page_action_views_.size(); ++i) { |
1167 if (page_action_views_[i]->IsVisible()) { | 1167 if (page_action_views_[i]->visible()) { |
1168 if (current == index) | 1168 if (current == index) |
1169 return page_action_views_[i]->image_view()->page_action(); | 1169 return page_action_views_[i]->image_view()->page_action(); |
1170 | 1170 |
1171 ++current; | 1171 ++current; |
1172 } | 1172 } |
1173 } | 1173 } |
1174 | 1174 |
1175 NOTREACHED(); | 1175 NOTREACHED(); |
1176 return NULL; | 1176 return NULL; |
1177 } | 1177 } |
1178 | 1178 |
1179 void LocationBarView::TestPageActionPressed(size_t index) { | 1179 void LocationBarView::TestPageActionPressed(size_t index) { |
1180 size_t current = 0; | 1180 size_t current = 0; |
1181 for (size_t i = 0; i < page_action_views_.size(); ++i) { | 1181 for (size_t i = 0; i < page_action_views_.size(); ++i) { |
1182 if (page_action_views_[i]->IsVisible()) { | 1182 if (page_action_views_[i]->visible()) { |
1183 if (current == index) { | 1183 if (current == index) { |
1184 const int kLeftMouseButton = 1; | 1184 const int kLeftMouseButton = 1; |
1185 page_action_views_[i]->image_view()->ExecuteAction(kLeftMouseButton, | 1185 page_action_views_[i]->image_view()->ExecuteAction(kLeftMouseButton, |
1186 false); // inspect_with_devtools | 1186 false); // inspect_with_devtools |
1187 return; | 1187 return; |
1188 } | 1188 } |
1189 ++current; | 1189 ++current; |
1190 } | 1190 } |
1191 } | 1191 } |
1192 | 1192 |
(...skipping 18 matching lines...) Expand all Loading... |
1211 Update(NULL); | 1211 Update(NULL); |
1212 } | 1212 } |
1213 } | 1213 } |
1214 | 1214 |
1215 #if defined(OS_WIN) | 1215 #if defined(OS_WIN) |
1216 bool LocationBarView::HasValidSuggestText() const { | 1216 bool LocationBarView::HasValidSuggestText() const { |
1217 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1217 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
1218 !suggested_text_view_->GetText().empty(); | 1218 !suggested_text_view_->GetText().empty(); |
1219 } | 1219 } |
1220 #endif | 1220 #endif |
OLD | NEW |