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 30 matching lines...) Expand all Loading... |
41 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 41 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" |
42 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" | 42 #include "chrome/browser/ui/views/location_bar/location_bar_layout.h" |
43 #include "chrome/browser/ui/views/location_bar/location_bar_separator_view.h" | 43 #include "chrome/browser/ui/views/location_bar/location_bar_separator_view.h" |
44 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 44 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
45 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" | 45 #include "chrome/browser/ui/views/location_bar/open_pdf_in_reader_view.h" |
46 #include "chrome/browser/ui/views/location_bar/page_action_image_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_with_badge_view.h" | 47 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
48 #include "chrome/browser/ui/views/location_bar/script_bubble_icon_view.h" | 48 #include "chrome/browser/ui/views/location_bar/script_bubble_icon_view.h" |
49 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" | 49 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" |
50 #include "chrome/browser/ui/views/location_bar/star_view.h" | 50 #include "chrome/browser/ui/views/location_bar/star_view.h" |
51 #include "chrome/browser/ui/views/location_bar/web_intents_button_view.h" | |
52 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" | 51 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
53 #include "chrome/browser/ui/views/location_bar/zoom_view.h" | 52 #include "chrome/browser/ui/views/location_bar/zoom_view.h" |
54 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 53 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
55 #include "chrome/browser/ui/views/omnibox/omnibox_views.h" | 54 #include "chrome/browser/ui/views/omnibox/omnibox_views.h" |
56 #include "chrome/browser/ui/zoom/zoom_controller.h" | 55 #include "chrome/browser/ui/zoom/zoom_controller.h" |
57 #include "chrome/common/chrome_notification_types.h" | 56 #include "chrome/common/chrome_notification_types.h" |
58 #include "chrome/common/extensions/feature_switch.h" | 57 #include "chrome/common/extensions/feature_switch.h" |
59 #include "chrome/common/pref_names.h" | 58 #include "chrome/common/pref_names.h" |
60 #include "content/public/browser/notification_service.h" | 59 #include "content/public/browser/notification_service.h" |
61 #include "content/public/browser/render_widget_host_view.h" | 60 #include "content/public/browser/render_widget_host_view.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 location_entry_view_(NULL), | 178 location_entry_view_(NULL), |
180 selected_keyword_view_(NULL), | 179 selected_keyword_view_(NULL), |
181 suggested_text_view_(NULL), | 180 suggested_text_view_(NULL), |
182 keyword_hint_view_(NULL), | 181 keyword_hint_view_(NULL), |
183 search_token_view_(NULL), | 182 search_token_view_(NULL), |
184 search_token_separator_view_(NULL), | 183 search_token_separator_view_(NULL), |
185 zoom_view_(NULL), | 184 zoom_view_(NULL), |
186 open_pdf_in_reader_view_(NULL), | 185 open_pdf_in_reader_view_(NULL), |
187 script_bubble_icon_view_(NULL), | 186 script_bubble_icon_view_(NULL), |
188 star_view_(NULL), | 187 star_view_(NULL), |
189 #if defined(ENABLE_WEB_INTENTS) | |
190 web_intents_button_view_(NULL), | |
191 #endif | |
192 action_box_button_view_(NULL), | 188 action_box_button_view_(NULL), |
193 mode_(mode), | 189 mode_(mode), |
194 show_focus_rect_(false), | 190 show_focus_rect_(false), |
195 template_url_service_(NULL), | 191 template_url_service_(NULL), |
196 animation_offset_(0) { | 192 animation_offset_(0) { |
197 set_id(VIEW_ID_LOCATION_BAR); | 193 set_id(VIEW_ID_LOCATION_BAR); |
198 | 194 |
199 if (mode_ == NORMAL) { | 195 if (mode_ == NORMAL) { |
200 background_painter_.reset( | 196 background_painter_.reset( |
201 views::Painter::CreateImagePainter( | 197 views::Painter::CreateImagePainter( |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 GetColor(ToolbarModel::NONE, TEXT)); | 277 GetColor(ToolbarModel::NONE, TEXT)); |
282 content_setting_views_.push_back(content_blocked_view); | 278 content_setting_views_.push_back(content_blocked_view); |
283 content_blocked_view->SetVisible(false); | 279 content_blocked_view->SetVisible(false); |
284 AddChildView(content_blocked_view); | 280 AddChildView(content_blocked_view); |
285 } | 281 } |
286 | 282 |
287 zoom_view_ = new ZoomView(model_, delegate_); | 283 zoom_view_ = new ZoomView(model_, delegate_); |
288 zoom_view_->set_id(VIEW_ID_ZOOM_BUTTON); | 284 zoom_view_->set_id(VIEW_ID_ZOOM_BUTTON); |
289 AddChildView(zoom_view_); | 285 AddChildView(zoom_view_); |
290 | 286 |
291 #if defined(ENABLE_WEB_INTENTS) | |
292 web_intents_button_view_ = | |
293 new WebIntentsButtonView(this, kWIBubbleBackgroundImages, font_, | |
294 GetColor(ToolbarModel::NONE, TEXT)); | |
295 AddChildView(web_intents_button_view_); | |
296 #endif | |
297 | |
298 open_pdf_in_reader_view_ = new OpenPDFInReaderView(this); | 287 open_pdf_in_reader_view_ = new OpenPDFInReaderView(this); |
299 AddChildView(open_pdf_in_reader_view_); | 288 AddChildView(open_pdf_in_reader_view_); |
300 | 289 |
301 script_bubble_icon_view_ = new ScriptBubbleIconView(delegate()); | 290 script_bubble_icon_view_ = new ScriptBubbleIconView(delegate()); |
302 script_bubble_icon_view_->SetVisible(false); | 291 script_bubble_icon_view_->SetVisible(false); |
303 AddChildView(script_bubble_icon_view_); | 292 AddChildView(script_bubble_icon_view_); |
304 | 293 |
305 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { | 294 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { |
306 // Note: condition above means that the star icon is hidden in popups and in | 295 // Note: condition above means that the star icon is hidden in popups and in |
307 // the app launcher. | 296 // the app launcher. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 void LocationBarView::SetAnimationOffset(int offset) { | 404 void LocationBarView::SetAnimationOffset(int offset) { |
416 animation_offset_ = offset; | 405 animation_offset_ = offset; |
417 } | 406 } |
418 | 407 |
419 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { | 408 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { |
420 RefreshContentSettingViews(); | 409 RefreshContentSettingViews(); |
421 ZoomBubbleView::CloseBubble(); | 410 ZoomBubbleView::CloseBubble(); |
422 RefreshZoomView(); | 411 RefreshZoomView(); |
423 RefreshPageActionViews(); | 412 RefreshPageActionViews(); |
424 RefreshScriptBubble(); | 413 RefreshScriptBubble(); |
425 #if defined(ENABLE_WEB_INTENTS) | |
426 web_intents_button_view_->Update(GetWebContents()); | |
427 #endif | |
428 open_pdf_in_reader_view_->Update( | 414 open_pdf_in_reader_view_->Update( |
429 model_->GetInputInProgress() ? NULL : GetWebContents()); | 415 model_->GetInputInProgress() ? NULL : GetWebContents()); |
430 | 416 |
431 bool star_enabled = star_view_ && !model_->GetInputInProgress() && | 417 bool star_enabled = star_view_ && !model_->GetInputInProgress() && |
432 edit_bookmarks_enabled_.GetValue(); | 418 edit_bookmarks_enabled_.GetValue(); |
433 | 419 |
434 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 420 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
435 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE_FROM_STAR, | 421 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE_FROM_STAR, |
436 star_enabled); | 422 star_enabled); |
437 if (star_view_ && !extensions::FeatureSwitch::action_box()->IsEnabled()) | 423 if (star_view_ && !extensions::FeatureSwitch::action_box()->IsEnabled()) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 size_t count_before = page_action_views_.size(); | 480 size_t count_before = page_action_views_.size(); |
495 DeletePageActionViews(); | 481 DeletePageActionViews(); |
496 if (page_action_views_.size() != count_before) { | 482 if (page_action_views_.size() != count_before) { |
497 content::NotificationService::current()->Notify( | 483 content::NotificationService::current()->Notify( |
498 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 484 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
499 content::Source<LocationBar>(this), | 485 content::Source<LocationBar>(this), |
500 content::NotificationService::NoDetails()); | 486 content::NotificationService::NoDetails()); |
501 } | 487 } |
502 } | 488 } |
503 | 489 |
504 #if defined(ENABLE_WEB_INTENTS) | |
505 void LocationBarView::UpdateWebIntentsButton() { | |
506 web_intents_button_view_->Update(GetWebContents()); | |
507 | |
508 Layout(); | |
509 SchedulePaint(); | |
510 } | |
511 #endif | |
512 | |
513 void LocationBarView::UpdateOpenPDFInReaderPrompt() { | 490 void LocationBarView::UpdateOpenPDFInReaderPrompt() { |
514 open_pdf_in_reader_view_->Update( | 491 open_pdf_in_reader_view_->Update( |
515 model_->GetInputInProgress() ? NULL : GetWebContents()); | 492 model_->GetInputInProgress() ? NULL : GetWebContents()); |
516 Layout(); | 493 Layout(); |
517 SchedulePaint(); | 494 SchedulePaint(); |
518 } | 495 } |
519 | 496 |
520 void LocationBarView::OnFocus() { | 497 void LocationBarView::OnFocus() { |
521 // Focus the view widget first which implements accessibility for | 498 // Focus the view widget first which implements accessibility for |
522 // Chrome OS. It is noop on Win. This should be removed once | 499 // Chrome OS. It is noop on Win. This should be removed once |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 right_decorations.AddDecoration(location_height, 0, zoom_view_); | 763 right_decorations.AddDecoration(location_height, 0, zoom_view_); |
787 for (ContentSettingViews::const_reverse_iterator | 764 for (ContentSettingViews::const_reverse_iterator |
788 i(content_setting_views_.rbegin()); i != content_setting_views_.rend(); | 765 i(content_setting_views_.rbegin()); i != content_setting_views_.rend(); |
789 ++i) { | 766 ++i) { |
790 if ((*i)->visible()) { | 767 if ((*i)->visible()) { |
791 right_decorations.AddDecoration( | 768 right_decorations.AddDecoration( |
792 kBubbleLocationY, 0, false, 0, GetEdgeItemPadding(), GetItemPadding(), | 769 kBubbleLocationY, 0, false, 0, GetEdgeItemPadding(), GetItemPadding(), |
793 (*i)->GetBuiltInHorizontalPadding(), (*i)); | 770 (*i)->GetBuiltInHorizontalPadding(), (*i)); |
794 } | 771 } |
795 } | 772 } |
796 #if defined(ENABLE_WEB_INTENTS) | |
797 if (web_intents_button_view_->visible()) { | |
798 right_decorations.AddDecoration( | |
799 kBubbleLocationY, 0, false, 0, GetEdgeItemPadding(), GetItemPadding(), | |
800 web_intents_button_view_->GetBuiltInHorizontalPadding(), | |
801 web_intents_button_view_); | |
802 } | |
803 #endif | |
804 if (show_keyword_hint) { | 773 if (show_keyword_hint) { |
805 right_decorations.AddDecoration( | 774 right_decorations.AddDecoration( |
806 kVerticalEdgeThickness, 0, true, 0, GetEdgeItemPadding(), | 775 kVerticalEdgeThickness, 0, true, 0, GetEdgeItemPadding(), |
807 GetItemPadding(), 0, keyword_hint_view_); | 776 GetItemPadding(), 0, keyword_hint_view_); |
808 if (keyword_hint_view_->keyword() != keyword) | 777 if (keyword_hint_view_->keyword() != keyword) |
809 keyword_hint_view_->SetKeyword(keyword); | 778 keyword_hint_view_->SetKeyword(keyword); |
810 } | 779 } |
811 if (show_search_token) { | 780 if (show_search_token) { |
812 right_decorations.AddSeparator(kVerticalEdgeThickness, location_height, | 781 right_decorations.AddSeparator(kVerticalEdgeThickness, location_height, |
813 GetItemPadding(), search_token_separator_view_); | 782 GetItemPadding(), search_token_separator_view_); |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1458 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
1490 int total_height = | 1459 int total_height = |
1491 use_preferred_size ? GetPreferredSize().height() : height(); | 1460 use_preferred_size ? GetPreferredSize().height() : height(); |
1492 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); | 1461 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); |
1493 } | 1462 } |
1494 | 1463 |
1495 bool LocationBarView::HasValidSuggestText() const { | 1464 bool LocationBarView::HasValidSuggestText() const { |
1496 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1465 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
1497 !suggested_text_view_->text().empty(); | 1466 !suggested_text_view_->text().empty(); |
1498 } | 1467 } |
OLD | NEW |