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

Side by Side Diff: chrome/browser/ui/views/translate/translate_bubble_view.cc

Issue 1402363013: Update location bar bubble/icon behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/translate/translate_bubble_view.h" 5 #include "chrome/browser/ui/views/translate/translate_bubble_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // removing the child views is needed. 71 // removing the child views is needed.
72 RemoveAllChildViews(true); 72 RemoveAllChildViews(true);
73 } 73 }
74 74
75 // static 75 // static
76 void TranslateBubbleView::ShowBubble( 76 void TranslateBubbleView::ShowBubble(
77 views::View* anchor_view, 77 views::View* anchor_view,
78 content::WebContents* web_contents, 78 content::WebContents* web_contents,
79 translate::TranslateStep step, 79 translate::TranslateStep step,
80 translate::TranslateErrors::Type error_type, 80 translate::TranslateErrors::Type error_type,
81 bool is_user_gesture) { 81 DisplayReason reason) {
82 if (translate_bubble_view_) { 82 if (translate_bubble_view_) {
83 // When the user reads the advanced setting panel, the bubble should not be 83 // When the user reads the advanced setting panel, the bubble should not be
84 // changed because they are focusing on the bubble. 84 // changed because they are focusing on the bubble.
85 if (translate_bubble_view_->web_contents() == web_contents && 85 if (translate_bubble_view_->web_contents() == web_contents &&
86 translate_bubble_view_->model()->GetViewState() == 86 translate_bubble_view_->model()->GetViewState() ==
87 TranslateBubbleModel::VIEW_STATE_ADVANCED) { 87 TranslateBubbleModel::VIEW_STATE_ADVANCED) {
88 return; 88 return;
89 } 89 }
90 if (step != translate::TRANSLATE_STEP_TRANSLATE_ERROR) { 90 if (step != translate::TRANSLATE_STEP_TRANSLATE_ERROR) {
91 TranslateBubbleModel::ViewState state = 91 TranslateBubbleModel::ViewState state =
92 TranslateBubbleModelImpl::TranslateStepToViewState(step); 92 TranslateBubbleModelImpl::TranslateStepToViewState(step);
93 translate_bubble_view_->SwitchView(state); 93 translate_bubble_view_->SwitchView(state);
94 } else { 94 } else {
95 translate_bubble_view_->SwitchToErrorView(error_type); 95 translate_bubble_view_->SwitchToErrorView(error_type);
96 } 96 }
97 return; 97 return;
98 } else { 98 } else {
99 if (step == translate::TRANSLATE_STEP_AFTER_TRANSLATE && 99 if (step == translate::TRANSLATE_STEP_AFTER_TRANSLATE &&
100 !is_user_gesture) { 100 reason == AUTOMATIC) {
101 return; 101 return;
102 } 102 }
103 } 103 }
104 104
105 std::string source_language; 105 std::string source_language;
106 std::string target_language; 106 std::string target_language;
107 ChromeTranslateClient::GetTranslateLanguages( 107 ChromeTranslateClient::GetTranslateLanguages(
108 web_contents, &source_language, &target_language); 108 web_contents, &source_language, &target_language);
109 109
110 scoped_ptr<translate::TranslateUIDelegate> ui_delegate( 110 scoped_ptr<translate::TranslateUIDelegate> ui_delegate(
111 new translate::TranslateUIDelegate( 111 new translate::TranslateUIDelegate(
112 ChromeTranslateClient::GetManagerFromWebContents(web_contents) 112 ChromeTranslateClient::GetManagerFromWebContents(web_contents)
113 ->GetWeakPtr(), 113 ->GetWeakPtr(),
114 source_language, 114 source_language,
115 target_language)); 115 target_language));
116 scoped_ptr<TranslateBubbleModel> model( 116 scoped_ptr<TranslateBubbleModel> model(
117 new TranslateBubbleModelImpl(step, ui_delegate.Pass())); 117 new TranslateBubbleModelImpl(step, ui_delegate.Pass()));
118 TranslateBubbleView* view = new TranslateBubbleView(anchor_view, 118 TranslateBubbleView* view = new TranslateBubbleView(anchor_view,
119 model.Pass(), 119 model.Pass(),
120 error_type, 120 error_type,
121 web_contents); 121 web_contents);
122 if (is_user_gesture) 122 views::BubbleDelegateView::CreateBubble(view);
123 views::BubbleDelegateView::CreateBubble(view)->Show(); 123 view->ShowForReason(reason);
124 else
125 views::BubbleDelegateView::CreateBubble(view)->ShowInactive();
126 } 124 }
127 125
128 // static 126 // static
129 void TranslateBubbleView::CloseBubble() { 127 void TranslateBubbleView::CloseBubble() {
130 if (!translate_bubble_view_) 128 if (!translate_bubble_view_)
131 return; 129 return;
132 130
133 translate_bubble_view_->GetWidget()->Close(); 131 translate_bubble_view_->GetWidget()->Close();
134 } 132 }
135 133
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 base::string16 label; 754 base::string16 label;
757 if (model_->IsPageTranslatedInCurrentLanguages()) 755 if (model_->IsPageTranslatedInCurrentLanguages())
758 label = l10n_util::GetStringUTF16(IDS_DONE); 756 label = l10n_util::GetStringUTF16(IDS_DONE);
759 else 757 else
760 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); 758 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT);
761 advanced_done_button_->SetText(label); 759 advanced_done_button_->SetText(label);
762 advanced_done_button_->SizeToPreferredSize(); 760 advanced_done_button_->SizeToPreferredSize();
763 if (advanced_view_) 761 if (advanced_view_)
764 advanced_view_->Layout(); 762 advanced_view_->Layout();
765 } 763 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/translate/translate_bubble_view.h ('k') | chrome/browser/ui/views/translate/translate_icon_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698