| 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 location_entry_view_(NULL), | 179 location_entry_view_(NULL), |
| 180 selected_keyword_view_(NULL), | 180 selected_keyword_view_(NULL), |
| 181 suggested_text_view_(NULL), | 181 suggested_text_view_(NULL), |
| 182 keyword_hint_view_(NULL), | 182 keyword_hint_view_(NULL), |
| 183 search_token_view_(NULL), | 183 search_token_view_(NULL), |
| 184 search_token_separator_view_(NULL), | 184 search_token_separator_view_(NULL), |
| 185 zoom_view_(NULL), | 185 zoom_view_(NULL), |
| 186 open_pdf_in_reader_view_(NULL), | 186 open_pdf_in_reader_view_(NULL), |
| 187 script_bubble_icon_view_(NULL), | 187 script_bubble_icon_view_(NULL), |
| 188 star_view_(NULL), | 188 star_view_(NULL), |
| 189 #if defined(ENABLE_WEB_INTENTS) |
| 189 web_intents_button_view_(NULL), | 190 web_intents_button_view_(NULL), |
| 191 #endif |
| 190 action_box_button_view_(NULL), | 192 action_box_button_view_(NULL), |
| 191 mode_(mode), | 193 mode_(mode), |
| 192 show_focus_rect_(false), | 194 show_focus_rect_(false), |
| 193 template_url_service_(NULL), | 195 template_url_service_(NULL), |
| 194 animation_offset_(0) { | 196 animation_offset_(0) { |
| 195 set_id(VIEW_ID_LOCATION_BAR); | 197 set_id(VIEW_ID_LOCATION_BAR); |
| 196 | 198 |
| 197 if (mode_ == NORMAL) { | 199 if (mode_ == NORMAL) { |
| 198 background_painter_.reset( | 200 background_painter_.reset( |
| 199 views::Painter::CreateImagePainter( | 201 views::Painter::CreateImagePainter( |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 GetColor(ToolbarModel::NONE, TEXT)); | 281 GetColor(ToolbarModel::NONE, TEXT)); |
| 280 content_setting_views_.push_back(content_blocked_view); | 282 content_setting_views_.push_back(content_blocked_view); |
| 281 content_blocked_view->SetVisible(false); | 283 content_blocked_view->SetVisible(false); |
| 282 AddChildView(content_blocked_view); | 284 AddChildView(content_blocked_view); |
| 283 } | 285 } |
| 284 | 286 |
| 285 zoom_view_ = new ZoomView(model_, delegate_); | 287 zoom_view_ = new ZoomView(model_, delegate_); |
| 286 zoom_view_->set_id(VIEW_ID_ZOOM_BUTTON); | 288 zoom_view_->set_id(VIEW_ID_ZOOM_BUTTON); |
| 287 AddChildView(zoom_view_); | 289 AddChildView(zoom_view_); |
| 288 | 290 |
| 291 #if defined(ENABLE_WEB_INTENTS) |
| 289 web_intents_button_view_ = | 292 web_intents_button_view_ = |
| 290 new WebIntentsButtonView(this, kWIBubbleBackgroundImages, font_, | 293 new WebIntentsButtonView(this, kWIBubbleBackgroundImages, font_, |
| 291 GetColor(ToolbarModel::NONE, TEXT)); | 294 GetColor(ToolbarModel::NONE, TEXT)); |
| 292 AddChildView(web_intents_button_view_); | 295 AddChildView(web_intents_button_view_); |
| 296 #endif |
| 293 | 297 |
| 294 open_pdf_in_reader_view_ = new OpenPDFInReaderView(this); | 298 open_pdf_in_reader_view_ = new OpenPDFInReaderView(this); |
| 295 AddChildView(open_pdf_in_reader_view_); | 299 AddChildView(open_pdf_in_reader_view_); |
| 296 | 300 |
| 297 script_bubble_icon_view_ = new ScriptBubbleIconView(delegate()); | 301 script_bubble_icon_view_ = new ScriptBubbleIconView(delegate()); |
| 298 script_bubble_icon_view_->SetVisible(false); | 302 script_bubble_icon_view_->SetVisible(false); |
| 299 AddChildView(script_bubble_icon_view_); | 303 AddChildView(script_bubble_icon_view_); |
| 300 | 304 |
| 301 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { | 305 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { |
| 302 // Note: condition above means that the star icon is hidden in popups and in | 306 // Note: condition above means that the star icon is hidden in popups and in |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 void LocationBarView::SetAnimationOffset(int offset) { | 415 void LocationBarView::SetAnimationOffset(int offset) { |
| 412 animation_offset_ = offset; | 416 animation_offset_ = offset; |
| 413 } | 417 } |
| 414 | 418 |
| 415 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { | 419 void LocationBarView::Update(const WebContents* tab_for_state_restoring) { |
| 416 RefreshContentSettingViews(); | 420 RefreshContentSettingViews(); |
| 417 ZoomBubbleView::CloseBubble(); | 421 ZoomBubbleView::CloseBubble(); |
| 418 RefreshZoomView(); | 422 RefreshZoomView(); |
| 419 RefreshPageActionViews(); | 423 RefreshPageActionViews(); |
| 420 RefreshScriptBubble(); | 424 RefreshScriptBubble(); |
| 425 #if defined(ENABLE_WEB_INTENTS) |
| 421 web_intents_button_view_->Update(GetWebContents()); | 426 web_intents_button_view_->Update(GetWebContents()); |
| 427 #endif |
| 422 open_pdf_in_reader_view_->Update( | 428 open_pdf_in_reader_view_->Update( |
| 423 model_->GetInputInProgress() ? NULL : GetWebContents()); | 429 model_->GetInputInProgress() ? NULL : GetWebContents()); |
| 424 | 430 |
| 425 bool star_enabled = star_view_ && !model_->GetInputInProgress() && | 431 bool star_enabled = star_view_ && !model_->GetInputInProgress() && |
| 426 edit_bookmarks_enabled_.GetValue(); | 432 edit_bookmarks_enabled_.GetValue(); |
| 427 | 433 |
| 428 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); | 434 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE, star_enabled); |
| 429 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE_FROM_STAR, | 435 command_updater_->UpdateCommandEnabled(IDC_BOOKMARK_PAGE_FROM_STAR, |
| 430 star_enabled); | 436 star_enabled); |
| 431 if (star_view_ && !extensions::FeatureSwitch::action_box()->IsEnabled()) | 437 if (star_view_ && !extensions::FeatureSwitch::action_box()->IsEnabled()) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 size_t count_before = page_action_views_.size(); | 494 size_t count_before = page_action_views_.size(); |
| 489 DeletePageActionViews(); | 495 DeletePageActionViews(); |
| 490 if (page_action_views_.size() != count_before) { | 496 if (page_action_views_.size() != count_before) { |
| 491 content::NotificationService::current()->Notify( | 497 content::NotificationService::current()->Notify( |
| 492 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, | 498 chrome::NOTIFICATION_EXTENSION_PAGE_ACTION_COUNT_CHANGED, |
| 493 content::Source<LocationBar>(this), | 499 content::Source<LocationBar>(this), |
| 494 content::NotificationService::NoDetails()); | 500 content::NotificationService::NoDetails()); |
| 495 } | 501 } |
| 496 } | 502 } |
| 497 | 503 |
| 504 #if defined(ENABLE_WEB_INTENTS) |
| 498 void LocationBarView::UpdateWebIntentsButton() { | 505 void LocationBarView::UpdateWebIntentsButton() { |
| 499 web_intents_button_view_->Update(GetWebContents()); | 506 web_intents_button_view_->Update(GetWebContents()); |
| 500 | 507 |
| 501 Layout(); | 508 Layout(); |
| 502 SchedulePaint(); | 509 SchedulePaint(); |
| 503 } | 510 } |
| 511 #endif |
| 504 | 512 |
| 505 void LocationBarView::UpdateOpenPDFInReaderPrompt() { | 513 void LocationBarView::UpdateOpenPDFInReaderPrompt() { |
| 506 open_pdf_in_reader_view_->Update( | 514 open_pdf_in_reader_view_->Update( |
| 507 model_->GetInputInProgress() ? NULL : GetWebContents()); | 515 model_->GetInputInProgress() ? NULL : GetWebContents()); |
| 508 Layout(); | 516 Layout(); |
| 509 SchedulePaint(); | 517 SchedulePaint(); |
| 510 } | 518 } |
| 511 | 519 |
| 512 void LocationBarView::OnFocus() { | 520 void LocationBarView::OnFocus() { |
| 513 // Focus the view widget first which implements accessibility for | 521 // Focus the view widget first which implements accessibility for |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 right_decorations.AddDecoration(location_height, 0, zoom_view_); | 786 right_decorations.AddDecoration(location_height, 0, zoom_view_); |
| 779 for (ContentSettingViews::const_reverse_iterator | 787 for (ContentSettingViews::const_reverse_iterator |
| 780 i(content_setting_views_.rbegin()); i != content_setting_views_.rend(); | 788 i(content_setting_views_.rbegin()); i != content_setting_views_.rend(); |
| 781 ++i) { | 789 ++i) { |
| 782 if ((*i)->visible()) { | 790 if ((*i)->visible()) { |
| 783 right_decorations.AddDecoration( | 791 right_decorations.AddDecoration( |
| 784 kBubbleLocationY, 0, false, 0, GetEdgeItemPadding(), GetItemPadding(), | 792 kBubbleLocationY, 0, false, 0, GetEdgeItemPadding(), GetItemPadding(), |
| 785 (*i)->GetBuiltInHorizontalPadding(), (*i)); | 793 (*i)->GetBuiltInHorizontalPadding(), (*i)); |
| 786 } | 794 } |
| 787 } | 795 } |
| 796 #if defined(ENABLE_WEB_INTENTS) |
| 788 if (web_intents_button_view_->visible()) { | 797 if (web_intents_button_view_->visible()) { |
| 789 right_decorations.AddDecoration( | 798 right_decorations.AddDecoration( |
| 790 kBubbleLocationY, 0, false, 0, GetEdgeItemPadding(), GetItemPadding(), | 799 kBubbleLocationY, 0, false, 0, GetEdgeItemPadding(), GetItemPadding(), |
| 791 web_intents_button_view_->GetBuiltInHorizontalPadding(), | 800 web_intents_button_view_->GetBuiltInHorizontalPadding(), |
| 792 web_intents_button_view_); | 801 web_intents_button_view_); |
| 793 } | 802 } |
| 803 #endif |
| 794 if (show_keyword_hint) { | 804 if (show_keyword_hint) { |
| 795 right_decorations.AddDecoration( | 805 right_decorations.AddDecoration( |
| 796 kVerticalEdgeThickness, 0, true, 0, GetEdgeItemPadding(), | 806 kVerticalEdgeThickness, 0, true, 0, GetEdgeItemPadding(), |
| 797 GetItemPadding(), 0, keyword_hint_view_); | 807 GetItemPadding(), 0, keyword_hint_view_); |
| 798 if (keyword_hint_view_->keyword() != keyword) | 808 if (keyword_hint_view_->keyword() != keyword) |
| 799 keyword_hint_view_->SetKeyword(keyword); | 809 keyword_hint_view_->SetKeyword(keyword); |
| 800 } | 810 } |
| 801 if (show_search_token) { | 811 if (show_search_token) { |
| 802 right_decorations.AddSeparator(kVerticalEdgeThickness, location_height, | 812 right_decorations.AddSeparator(kVerticalEdgeThickness, location_height, |
| 803 GetItemPadding(), search_token_separator_view_); | 813 GetItemPadding(), search_token_separator_view_); |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1479 int LocationBarView::GetInternalHeight(bool use_preferred_size) { | 1489 int LocationBarView::GetInternalHeight(bool use_preferred_size) { |
| 1480 int total_height = | 1490 int total_height = |
| 1481 use_preferred_size ? GetPreferredSize().height() : height(); | 1491 use_preferred_size ? GetPreferredSize().height() : height(); |
| 1482 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); | 1492 return std::max(total_height - (kVerticalEdgeThickness * 2), 0); |
| 1483 } | 1493 } |
| 1484 | 1494 |
| 1485 bool LocationBarView::HasValidSuggestText() const { | 1495 bool LocationBarView::HasValidSuggestText() const { |
| 1486 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1496 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
| 1487 !suggested_text_view_->text().empty(); | 1497 !suggested_text_view_->text().empty(); |
| 1488 } | 1498 } |
| OLD | NEW |