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/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 | 379 |
380 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { | 380 void LocationBarView::ZoomChangedForActiveTab(bool can_show_bubble) { |
381 DCHECK(zoom_view_); | 381 DCHECK(zoom_view_); |
382 if (RefreshZoomView()) { | 382 if (RefreshZoomView()) { |
383 Layout(); | 383 Layout(); |
384 SchedulePaint(); | 384 SchedulePaint(); |
385 } | 385 } |
386 | 386 |
387 WebContents* web_contents = GetWebContents(); | 387 WebContents* web_contents = GetWebContents(); |
388 if (can_show_bubble && zoom_view_->visible() && web_contents) | 388 if (can_show_bubble && zoom_view_->visible() && web_contents) |
389 ZoomBubbleView::ShowBubble(web_contents, true); | 389 ZoomBubbleView::ShowBubble(web_contents, ZoomBubbleView::AUTOMATIC); |
390 } | 390 } |
391 | 391 |
392 void LocationBarView::SetPreviewEnabledPageAction(ExtensionAction* page_action, | 392 void LocationBarView::SetPreviewEnabledPageAction(ExtensionAction* page_action, |
393 bool preview_enabled) { | 393 bool preview_enabled) { |
394 if (is_popup_mode_) | 394 if (is_popup_mode_) |
395 return; | 395 return; |
396 | 396 |
397 DCHECK(page_action); | 397 DCHECK(page_action); |
398 WebContents* web_contents = GetWebContents(); | 398 WebContents* web_contents = GetWebContents(); |
399 | 399 |
(...skipping 19 matching lines...) Expand all Loading... |
419 return *i; | 419 return *i; |
420 } | 420 } |
421 return NULL; | 421 return NULL; |
422 } | 422 } |
423 | 423 |
424 void LocationBarView::SetStarToggled(bool on) { | 424 void LocationBarView::SetStarToggled(bool on) { |
425 if (star_view_) | 425 if (star_view_) |
426 star_view_->SetToggled(on); | 426 star_view_->SetToggled(on); |
427 } | 427 } |
428 | 428 |
429 void LocationBarView::SetTranslateIconToggled(bool on) { | |
430 translate_icon_view_->SetToggled(on); | |
431 } | |
432 | |
433 gfx::Point LocationBarView::GetOmniboxViewOrigin() const { | 429 gfx::Point LocationBarView::GetOmniboxViewOrigin() const { |
434 gfx::Point origin(omnibox_view_->bounds().origin()); | 430 gfx::Point origin(omnibox_view_->bounds().origin()); |
435 origin.set_x(GetMirroredXInView(origin.x())); | 431 origin.set_x(GetMirroredXInView(origin.x())); |
436 views::View::ConvertPointToScreen(this, &origin); | 432 views::View::ConvertPointToScreen(this, &origin); |
437 return origin; | 433 return origin; |
438 } | 434 } |
439 | 435 |
440 void LocationBarView::SetImeInlineAutocompletion(const base::string16& text) { | 436 void LocationBarView::SetImeInlineAutocompletion(const base::string16& text) { |
441 ime_inline_autocomplete_view_->SetText(text); | 437 ime_inline_autocomplete_view_->SetText(text); |
442 ime_inline_autocomplete_view_->SetVisible(!text.empty()); | 438 ime_inline_autocomplete_view_->SetVisible(!text.empty()); |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 return false; | 975 return false; |
980 | 976 |
981 const bool was_visible = save_credit_card_icon_view_->visible(); | 977 const bool was_visible = save_credit_card_icon_view_->visible(); |
982 // |controller| may be nullptr due to lazy initialization. | 978 // |controller| may be nullptr due to lazy initialization. |
983 autofill::SaveCardBubbleControllerImpl* controller = | 979 autofill::SaveCardBubbleControllerImpl* controller = |
984 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents); | 980 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents); |
985 bool enabled = controller && controller->IsIconVisible(); | 981 bool enabled = controller && controller->IsIconVisible(); |
986 command_updater()->UpdateCommandEnabled(IDC_SAVE_CREDIT_CARD_FOR_PAGE, | 982 command_updater()->UpdateCommandEnabled(IDC_SAVE_CREDIT_CARD_FOR_PAGE, |
987 enabled); | 983 enabled); |
988 save_credit_card_icon_view_->SetVisible(enabled); | 984 save_credit_card_icon_view_->SetVisible(enabled); |
989 if (enabled) | |
990 save_credit_card_icon_view_->SetToggled(controller->IsIconToggled()); | |
991 | 985 |
992 return was_visible != save_credit_card_icon_view_->visible(); | 986 return was_visible != save_credit_card_icon_view_->visible(); |
993 } | 987 } |
994 | 988 |
995 void LocationBarView::RefreshTranslateIcon() { | 989 void LocationBarView::RefreshTranslateIcon() { |
996 WebContents* web_contents = GetWebContents(); | 990 WebContents* web_contents = GetWebContents(); |
997 if (!web_contents) | 991 if (!web_contents) |
998 return; | 992 return; |
999 translate::LanguageState& language_state = | 993 translate::LanguageState& language_state = |
1000 ChromeTranslateClient::FromWebContents(web_contents)->GetLanguageState(); | 994 ChromeTranslateClient::FromWebContents(web_contents)->GetLanguageState(); |
1001 bool enabled = language_state.translate_enabled(); | 995 bool enabled = language_state.translate_enabled(); |
1002 command_updater()->UpdateCommandEnabled(IDC_TRANSLATE_PAGE, enabled); | 996 command_updater()->UpdateCommandEnabled(IDC_TRANSLATE_PAGE, enabled); |
1003 translate_icon_view_->SetVisible(enabled); | 997 translate_icon_view_->SetVisible(enabled); |
1004 translate_icon_view_->SetToggled(language_state.IsPageTranslated()); | |
1005 if (!enabled) | 998 if (!enabled) |
1006 TranslateBubbleView::CloseBubble(); | 999 TranslateBubbleView::CloseBubble(); |
1007 } | 1000 } |
1008 | 1001 |
1009 bool LocationBarView::RefreshManagePasswordsIconView() { | 1002 bool LocationBarView::RefreshManagePasswordsIconView() { |
1010 DCHECK(manage_passwords_icon_view_); | 1003 DCHECK(manage_passwords_icon_view_); |
1011 WebContents* web_contents = GetWebContents(); | 1004 WebContents* web_contents = GetWebContents(); |
1012 if (!web_contents) | 1005 if (!web_contents) |
1013 return false; | 1006 return false; |
1014 const bool was_visible = manage_passwords_icon_view_->visible(); | 1007 const bool was_visible = manage_passwords_icon_view_->visible(); |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 // LocationBarView, private TemplateURLServiceObserver implementation: | 1386 // LocationBarView, private TemplateURLServiceObserver implementation: |
1394 | 1387 |
1395 void LocationBarView::OnTemplateURLServiceChanged() { | 1388 void LocationBarView::OnTemplateURLServiceChanged() { |
1396 template_url_service_->RemoveObserver(this); | 1389 template_url_service_->RemoveObserver(this); |
1397 template_url_service_ = NULL; | 1390 template_url_service_ = NULL; |
1398 // If the browser is no longer active, let's not show the info bubble, as this | 1391 // If the browser is no longer active, let's not show the info bubble, as this |
1399 // would make the browser the active window again. | 1392 // would make the browser the active window again. |
1400 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) | 1393 if (omnibox_view_ && omnibox_view_->GetWidget()->IsActive()) |
1401 ShowFirstRunBubble(); | 1394 ShowFirstRunBubble(); |
1402 } | 1395 } |
OLD | NEW |