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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "chrome/browser/ui/browser_window.h" | 31 #include "chrome/browser/ui/browser_window.h" |
32 #include "chrome/browser/ui/omnibox/alternate_nav_url_fetcher.h" | 32 #include "chrome/browser/ui/omnibox/alternate_nav_url_fetcher.h" |
33 #include "chrome/browser/ui/omnibox/location_bar_util.h" | 33 #include "chrome/browser/ui/omnibox/location_bar_util.h" |
34 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 34 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
35 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" | 35 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" |
36 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 36 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
37 #include "chrome/browser/ui/view_ids.h" | 37 #include "chrome/browser/ui/view_ids.h" |
38 #include "chrome/browser/ui/views/bookmarks/bookmark_prompt_view.h" | 38 #include "chrome/browser/ui/views/bookmarks/bookmark_prompt_view.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/extensions/extension_popup.h" | 40 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
41 #include "chrome/browser/ui/views/location_bar/autofill_credit_card_view.h" | |
42 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 41 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
43 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" | 42 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" |
| 43 #include "chrome/browser/ui/views/location_bar/generated_credit_card_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_bar_layout.h" | 45 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" |
46 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 46 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
47 #include "chrome/browser/ui/views/location_bar/mic_search_view.h" | 47 #include "chrome/browser/ui/views/location_bar/mic_search_view.h" |
48 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" | 48 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" |
49 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 49 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
50 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" | 50 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
51 #include "chrome/browser/ui/views/location_bar/script_bubble_icon_view.h" | 51 #include "chrome/browser/ui/views/location_bar/script_bubble_icon_view.h" |
52 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" | 52 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" |
53 #include "chrome/browser/ui/views/location_bar/star_view.h" | 53 #include "chrome/browser/ui/views/location_bar/star_view.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), | 178 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), |
179 location_icon_view_(NULL), | 179 location_icon_view_(NULL), |
180 ev_bubble_view_(NULL), | 180 ev_bubble_view_(NULL), |
181 location_entry_view_(NULL), | 181 location_entry_view_(NULL), |
182 ime_inline_autocomplete_view_(NULL), | 182 ime_inline_autocomplete_view_(NULL), |
183 selected_keyword_view_(NULL), | 183 selected_keyword_view_(NULL), |
184 suggested_text_view_(NULL), | 184 suggested_text_view_(NULL), |
185 keyword_hint_view_(NULL), | 185 keyword_hint_view_(NULL), |
186 mic_search_view_(NULL), | 186 mic_search_view_(NULL), |
187 zoom_view_(NULL), | 187 zoom_view_(NULL), |
188 autofill_credit_card_view_(NULL), | 188 generated_credit_card_view_(NULL), |
189 open_pdf_in_reader_view_(NULL), | 189 open_pdf_in_reader_view_(NULL), |
190 script_bubble_icon_view_(NULL), | 190 script_bubble_icon_view_(NULL), |
191 star_view_(NULL), | 191 star_view_(NULL), |
192 is_popup_mode_(is_popup_mode), | 192 is_popup_mode_(is_popup_mode), |
193 show_focus_rect_(false), | 193 show_focus_rect_(false), |
194 template_url_service_(NULL), | 194 template_url_service_(NULL), |
195 animation_offset_(0) { | 195 animation_offset_(0) { |
196 if (!views::Textfield::IsViewsTextfieldEnabled()) | 196 if (!views::Textfield::IsViewsTextfieldEnabled()) |
197 set_id(VIEW_ID_OMNIBOX); | 197 set_id(VIEW_ID_OMNIBOX); |
198 | 198 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 321 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
322 ContentSettingImageView* content_blocked_view = | 322 ContentSettingImageView* content_blocked_view = |
323 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this, | 323 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this, |
324 bubble_font, bubble_font_y_offset, | 324 bubble_font, bubble_font_y_offset, |
325 text_color, background_color); | 325 text_color, background_color); |
326 content_setting_views_.push_back(content_blocked_view); | 326 content_setting_views_.push_back(content_blocked_view); |
327 content_blocked_view->SetVisible(false); | 327 content_blocked_view->SetVisible(false); |
328 AddChildView(content_blocked_view); | 328 AddChildView(content_blocked_view); |
329 } | 329 } |
330 | 330 |
331 autofill_credit_card_view_ = new AutofillCreditCardView(model_, delegate_); | 331 generated_credit_card_view_ = new GeneratedCreditCardView(model_, delegate_); |
332 AddChildView(autofill_credit_card_view_); | 332 AddChildView(generated_credit_card_view_); |
333 | 333 |
334 zoom_view_ = new ZoomView(model_, delegate_); | 334 zoom_view_ = new ZoomView(model_, delegate_); |
335 zoom_view_->set_id(VIEW_ID_ZOOM_BUTTON); | 335 zoom_view_->set_id(VIEW_ID_ZOOM_BUTTON); |
336 AddChildView(zoom_view_); | 336 AddChildView(zoom_view_); |
337 | 337 |
338 open_pdf_in_reader_view_ = new OpenPDFInReaderView(this); | 338 open_pdf_in_reader_view_ = new OpenPDFInReaderView(this); |
339 AddChildView(open_pdf_in_reader_view_); | 339 AddChildView(open_pdf_in_reader_view_); |
340 | 340 |
341 script_bubble_icon_view_ = new ScriptBubbleIconView(delegate()); | 341 script_bubble_icon_view_ = new ScriptBubbleIconView(delegate()); |
342 script_bubble_icon_view_->SetVisible(false); | 342 script_bubble_icon_view_->SetVisible(false); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 | 460 |
461 void LocationBarView::SetAnimationOffset(int offset) { | 461 void LocationBarView::SetAnimationOffset(int offset) { |
462 animation_offset_ = offset; | 462 animation_offset_ = offset; |
463 } | 463 } |
464 | 464 |
465 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { | 465 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { |
466 mic_search_view_->SetVisible( | 466 mic_search_view_->SetVisible( |
467 !model_->GetInputInProgress() && browser_ && | 467 !model_->GetInputInProgress() && browser_ && |
468 browser_->search_model()->voice_search_supported()); | 468 browser_->search_model()->voice_search_supported()); |
469 RefreshContentSettingViews(); | 469 RefreshContentSettingViews(); |
470 autofill_credit_card_view_->Update(); | 470 generated_credit_card_view_->Update(); |
471 ZoomBubbleView::CloseBubble(); | 471 ZoomBubbleView::CloseBubble(); |
472 RefreshZoomView(); | 472 RefreshZoomView(); |
473 RefreshPageActionViews(); | 473 RefreshPageActionViews(); |
474 RefreshScriptBubble(); | 474 RefreshScriptBubble(); |
475 open_pdf_in_reader_view_->Update( | 475 open_pdf_in_reader_view_->Update( |
476 model_->GetInputInProgress() ? NULL : GetWebContents()); | 476 model_->GetInputInProgress() ? NULL : GetWebContents()); |
477 | 477 |
478 bool star_enabled = | 478 bool star_enabled = |
479 browser_defaults::bookmarks_enabled && !is_popup_mode_ && star_view_ && | 479 browser_defaults::bookmarks_enabled && !is_popup_mode_ && star_view_ && |
480 !model_->GetInputInProgress() && edit_bookmarks_enabled_.GetValue(); | 480 !model_->GetInputInProgress() && edit_bookmarks_enabled_.GetValue(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 } | 523 } |
524 } | 524 } |
525 | 525 |
526 void LocationBarView::UpdateOpenPDFInReaderPrompt() { | 526 void LocationBarView::UpdateOpenPDFInReaderPrompt() { |
527 open_pdf_in_reader_view_->Update( | 527 open_pdf_in_reader_view_->Update( |
528 model_->GetInputInProgress() ? NULL : GetWebContents()); | 528 model_->GetInputInProgress() ? NULL : GetWebContents()); |
529 Layout(); | 529 Layout(); |
530 SchedulePaint(); | 530 SchedulePaint(); |
531 } | 531 } |
532 | 532 |
533 void LocationBarView::UpdateAutofillCreditCardView() { | 533 void LocationBarView::UpdateGeneratedCreditCardView() { |
534 autofill_credit_card_view_->Update(); | 534 generated_credit_card_view_->Update(); |
535 Layout(); | 535 Layout(); |
536 SchedulePaint(); | 536 SchedulePaint(); |
537 } | 537 } |
538 | 538 |
539 void LocationBarView::OnFocus() { | 539 void LocationBarView::OnFocus() { |
540 // Focus the view widget first which implements accessibility for | 540 // Focus the view widget first which implements accessibility for |
541 // Chrome OS. It is noop on Win. This should be removed once | 541 // Chrome OS. It is noop on Win. This should be removed once |
542 // Chrome OS migrates to aura, which uses Views' textfield that receives | 542 // Chrome OS migrates to aura, which uses Views' textfield that receives |
543 // focus. See crbug.com/106428. | 543 // focus. See crbug.com/106428. |
544 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_FOCUS, false); | 544 NotifyAccessibilityEvent(ui::AccessibilityTypes::EVENT_FOCUS, false); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 } | 751 } |
752 for (ContentSettingViews::const_reverse_iterator i( | 752 for (ContentSettingViews::const_reverse_iterator i( |
753 content_setting_views_.rbegin()); i != content_setting_views_.rend(); | 753 content_setting_views_.rbegin()); i != content_setting_views_.rend(); |
754 ++i) { | 754 ++i) { |
755 if ((*i)->visible()) { | 755 if ((*i)->visible()) { |
756 trailing_decorations.AddDecoration( | 756 trailing_decorations.AddDecoration( |
757 bubble_location_y, bubble_height, false, 0, item_padding, | 757 bubble_location_y, bubble_height, false, 0, item_padding, |
758 item_padding, (*i)->GetBuiltInHorizontalPadding(), (*i)); | 758 item_padding, (*i)->GetBuiltInHorizontalPadding(), (*i)); |
759 } | 759 } |
760 } | 760 } |
761 if (autofill_credit_card_view_->visible()) { | 761 if (generated_credit_card_view_->visible()) { |
762 trailing_decorations.AddDecoration(vertical_edge_thickness(), | 762 trailing_decorations.AddDecoration(vertical_edge_thickness(), |
763 location_height, 0, | 763 location_height, 0, |
764 autofill_credit_card_view_); | 764 generated_credit_card_view_); |
765 } | 765 } |
766 if (mic_search_view_->visible()) { | 766 if (mic_search_view_->visible()) { |
767 trailing_decorations.AddDecoration(vertical_edge_thickness(), | 767 trailing_decorations.AddDecoration(vertical_edge_thickness(), |
768 location_height, 0, mic_search_view_); | 768 location_height, 0, mic_search_view_); |
769 } | 769 } |
770 // Because IMEs may eat the tab key, we don't show "press tab to search" while | 770 // Because IMEs may eat the tab key, we don't show "press tab to search" while |
771 // IME composition is in progress. | 771 // IME composition is in progress. |
772 if (!keyword.empty() && is_keyword_hint && | 772 if (!keyword.empty() && is_keyword_hint && |
773 !location_entry_->IsImeComposing()) { | 773 !location_entry_->IsImeComposing()) { |
774 trailing_decorations.AddDecoration(vertical_edge_thickness(), | 774 trailing_decorations.AddDecoration(vertical_edge_thickness(), |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 OnMouseEvent(event, msg); | 986 OnMouseEvent(event, msg); |
987 } | 987 } |
988 | 988 |
989 void LocationBarView::OnMouseCaptureLost() { | 989 void LocationBarView::OnMouseCaptureLost() { |
990 OmniboxViewWin* omnibox_win = GetOmniboxViewWin(location_entry_.get()); | 990 OmniboxViewWin* omnibox_win = GetOmniboxViewWin(location_entry_.get()); |
991 if (omnibox_win) | 991 if (omnibox_win) |
992 omnibox_win->HandleExternalMsg(WM_CAPTURECHANGED, 0, CPoint()); | 992 omnibox_win->HandleExternalMsg(WM_CAPTURECHANGED, 0, CPoint()); |
993 } | 993 } |
994 #endif | 994 #endif |
995 | 995 |
996 views::View* LocationBarView::autofill_credit_card_view() { | 996 views::View* LocationBarView::generated_credit_card_view() { |
997 return autofill_credit_card_view_; | 997 return generated_credit_card_view_; |
998 } | 998 } |
999 | 999 |
1000 void LocationBarView::OnAutocompleteAccept( | 1000 void LocationBarView::OnAutocompleteAccept( |
1001 const GURL& url, | 1001 const GURL& url, |
1002 WindowOpenDisposition disposition, | 1002 WindowOpenDisposition disposition, |
1003 content::PageTransition transition, | 1003 content::PageTransition transition, |
1004 const GURL& alternate_nav_url) { | 1004 const GURL& alternate_nav_url) { |
1005 // WARNING: don't add an early return here. The calls after the if must | 1005 // WARNING: don't add an early return here. The calls after the if must |
1006 // happen. | 1006 // happen. |
1007 if (url.is_valid()) { | 1007 if (url.is_valid()) { |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1502 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1502 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
1503 int total_height = | 1503 int total_height = |
1504 use_preferred_size ? GetPreferredSize().height() : height(); | 1504 use_preferred_size ? GetPreferredSize().height() : height(); |
1505 return std::max(total_height - (vertical_edge_thickness() * 2), 0); | 1505 return std::max(total_height - (vertical_edge_thickness() * 2), 0); |
1506 } | 1506 } |
1507 | 1507 |
1508 bool LocationBarView::HasValidSuggestText() const { | 1508 bool LocationBarView::HasValidSuggestText() const { |
1509 return suggested_text_view_->visible() && | 1509 return suggested_text_view_->visible() && |
1510 !suggested_text_view_->size().IsEmpty(); | 1510 !suggested_text_view_->size().IsEmpty(); |
1511 } | 1511 } |
OLD | NEW |