Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 1402363013: Update location bar bubble/icon behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 return *i; 438 return *i;
439 } 439 }
440 return NULL; 440 return NULL;
441 } 441 }
442 442
443 void LocationBarView::SetStarToggled(bool on) { 443 void LocationBarView::SetStarToggled(bool on) {
444 if (star_view_) 444 if (star_view_)
445 star_view_->SetToggled(on); 445 star_view_->SetToggled(on);
446 } 446 }
447 447
448 void LocationBarView::SetTranslateIconToggled(bool on) {
449 translate_icon_view_->SetToggled(on);
450 }
451
452 gfx::Point LocationBarView::GetOmniboxViewOrigin() const { 448 gfx::Point LocationBarView::GetOmniboxViewOrigin() const {
453 gfx::Point origin(omnibox_view_->bounds().origin()); 449 gfx::Point origin(omnibox_view_->bounds().origin());
454 origin.set_x(GetMirroredXInView(origin.x())); 450 origin.set_x(GetMirroredXInView(origin.x()));
455 views::View::ConvertPointToScreen(this, &origin); 451 views::View::ConvertPointToScreen(this, &origin);
456 return origin; 452 return origin;
457 } 453 }
458 454
459 void LocationBarView::SetImeInlineAutocompletion(const base::string16& text) { 455 void LocationBarView::SetImeInlineAutocompletion(const base::string16& text) {
460 ime_inline_autocomplete_view_->SetText(text); 456 ime_inline_autocomplete_view_->SetText(text);
461 ime_inline_autocomplete_view_->SetVisible(!text.empty()); 457 ime_inline_autocomplete_view_->SetVisible(!text.empty());
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 return false; 1002 return false;
1007 1003
1008 const bool was_visible = save_credit_card_icon_view_->visible(); 1004 const bool was_visible = save_credit_card_icon_view_->visible();
1009 // |controller| may be nullptr due to lazy initialization. 1005 // |controller| may be nullptr due to lazy initialization.
1010 autofill::SaveCardBubbleControllerImpl* controller = 1006 autofill::SaveCardBubbleControllerImpl* controller =
1011 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents); 1007 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents);
1012 bool enabled = controller && controller->IsIconVisible(); 1008 bool enabled = controller && controller->IsIconVisible();
1013 command_updater()->UpdateCommandEnabled(IDC_SAVE_CREDIT_CARD_FOR_PAGE, 1009 command_updater()->UpdateCommandEnabled(IDC_SAVE_CREDIT_CARD_FOR_PAGE,
1014 enabled); 1010 enabled);
1015 save_credit_card_icon_view_->SetVisible(enabled); 1011 save_credit_card_icon_view_->SetVisible(enabled);
1016 if (enabled)
1017 save_credit_card_icon_view_->SetToggled(controller->IsIconToggled());
1018 1012
1019 return was_visible != save_credit_card_icon_view_->visible(); 1013 return was_visible != save_credit_card_icon_view_->visible();
1020 } 1014 }
1021 1015
1022 void LocationBarView::RefreshTranslateIcon() { 1016 void LocationBarView::RefreshTranslateIcon() {
1023 WebContents* web_contents = GetWebContents(); 1017 WebContents* web_contents = GetWebContents();
1024 if (!web_contents) 1018 if (!web_contents)
1025 return; 1019 return;
1026 translate::LanguageState& language_state = 1020 translate::LanguageState& language_state =
1027 ChromeTranslateClient::FromWebContents(web_contents)->GetLanguageState(); 1021 ChromeTranslateClient::FromWebContents(web_contents)->GetLanguageState();
1028 bool enabled = language_state.translate_enabled(); 1022 bool enabled = language_state.translate_enabled();
1029 command_updater()->UpdateCommandEnabled(IDC_TRANSLATE_PAGE, enabled); 1023 command_updater()->UpdateCommandEnabled(IDC_TRANSLATE_PAGE, enabled);
1030 translate_icon_view_->SetVisible(enabled); 1024 translate_icon_view_->SetVisible(enabled);
1031 translate_icon_view_->SetToggled(language_state.IsPageTranslated());
1032 if (!enabled) 1025 if (!enabled)
1033 TranslateBubbleView::CloseBubble(); 1026 TranslateBubbleView::CloseBubble();
1034 } 1027 }
1035 1028
1036 bool LocationBarView::RefreshManagePasswordsIconView() { 1029 bool LocationBarView::RefreshManagePasswordsIconView() {
1037 DCHECK(manage_passwords_icon_view_); 1030 DCHECK(manage_passwords_icon_view_);
1038 WebContents* web_contents = GetWebContents(); 1031 WebContents* web_contents = GetWebContents();
1039 if (!web_contents) 1032 if (!web_contents)
1040 return false; 1033 return false;
1041 const bool was_visible = manage_passwords_icon_view_->visible(); 1034 const bool was_visible = manage_passwords_icon_view_->visible();
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 1432
1440 void LocationBarView::ModelChanged(const SearchModel::State& old_state, 1433 void LocationBarView::ModelChanged(const SearchModel::State& old_state,
1441 const SearchModel::State& new_state) { 1434 const SearchModel::State& new_state) {
1442 const bool visible = !GetToolbarModel()->input_in_progress() && 1435 const bool visible = !GetToolbarModel()->input_in_progress() &&
1443 new_state.voice_search_supported; 1436 new_state.voice_search_supported;
1444 if (mic_search_view_->visible() != visible) { 1437 if (mic_search_view_->visible() != visible) {
1445 mic_search_view_->SetVisible(visible); 1438 mic_search_view_->SetVisible(visible);
1446 Layout(); 1439 Layout();
1447 } 1440 }
1448 } 1441 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698