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

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

Issue 1632953002: Change the TranslateDeclined() to only count decline if the explicit_closed is set to true (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 if (model_->GetViewState() == TranslateBubbleModel::VIEW_STATE_ERROR) 160 if (model_->GetViewState() == TranslateBubbleModel::VIEW_STATE_ERROR)
161 model_->ShowError(error_type_); 161 model_->ShowError(error_type_);
162 } 162 }
163 163
164 void TranslateBubbleView::ButtonPressed(views::Button* sender, 164 void TranslateBubbleView::ButtonPressed(views::Button* sender,
165 const ui::Event& event) { 165 const ui::Event& event) {
166 HandleButtonPressed(static_cast<ButtonID>(sender->id())); 166 HandleButtonPressed(static_cast<ButtonID>(sender->id()));
167 } 167 }
168 168
169 void TranslateBubbleView::WindowClosing() { 169 void TranslateBubbleView::WindowClosing() {
groby-ooo-7-16 2016/01/26 01:07:22 This means we would lose all metrics that are due
ftang 2016/01/26 01:30:35 The function called "TranslationDeclined()" so no
170 // The operations for |model_| are valid only when a WebContents is alive.
171 // TODO(hajimehoshi): TranslateBubbleViewModel(Impl) should not hold a
172 // WebContents as a member variable because the WebContents might be destroyed
173 // while the TranslateBubbleViewModel(Impl) is still alive. Instead,
174 // TranslateBubbleViewModel should take a reference of a WebContents at each
175 // method. (crbug/320497)
176 if (!translate_executed_ && web_contents())
177 model_->TranslationDeclined(denial_button_clicked_);
178
179 // We have to reset |translate_bubble_view_| here, not in our destructor, 170 // We have to reset |translate_bubble_view_| here, not in our destructor,
180 // because we'll be destroyed asynchronously and the shown state will be 171 // because we'll be destroyed asynchronously and the shown state will be
181 // checked before then. 172 // checked before then.
182 DCHECK_EQ(translate_bubble_view_, this); 173 DCHECK_EQ(translate_bubble_view_, this);
183 translate_bubble_view_ = NULL; 174 translate_bubble_view_ = NULL;
184 } 175 }
185 176
186 bool TranslateBubbleView::AcceleratorPressed( 177 bool TranslateBubbleView::AcceleratorPressed(
187 const ui::Accelerator& accelerator) { 178 const ui::Accelerator& accelerator) {
188 switch (model_->GetViewState()) { 179 switch (model_->GetViewState()) {
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 model_->SetNeverTranslateLanguage(true); 365 model_->SetNeverTranslateLanguage(true);
375 break; 366 break;
376 case DenialComboboxIndex::NEVER_TRANSLATE_SITE: 367 case DenialComboboxIndex::NEVER_TRANSLATE_SITE:
377 model_->SetNeverTranslateSite(true); 368 model_->SetNeverTranslateSite(true);
378 break; 369 break;
379 default: 370 default:
380 NOTREACHED(); 371 NOTREACHED();
381 break; 372 break;
382 } 373 }
383 GetWidget()->Close(); 374 GetWidget()->Close();
375 // The operations for |model_| are valid only when a WebContents is alive.
376 // TODO(hajimehoshi): TranslateBubbleViewModel(Impl) should not hold a
377 // WebContents as a member variable because the WebContents might be
378 // destroyed while the TranslateBubbleViewModel(Impl) is still alive.
379 // Instead,
380 // TranslateBubbleViewModel should take a reference of a WebContents at
381 // each method. (crbug/320497)
382 if (!translate_executed_ && web_contents())
383 model_->TranslationDeclined(denial_button_clicked_);
384 break; 384 break;
385 } 385 }
386 case COMBOBOX_ID_SOURCE_LANGUAGE: { 386 case COMBOBOX_ID_SOURCE_LANGUAGE: {
387 if (model_->GetOriginalLanguageIndex() == 387 if (model_->GetOriginalLanguageIndex() ==
388 source_language_combobox_->selected_index()) { 388 source_language_combobox_->selected_index()) {
389 break; 389 break;
390 } 390 }
391 model_->UpdateOriginalLanguageIndex( 391 model_->UpdateOriginalLanguageIndex(
392 source_language_combobox_->selected_index()); 392 source_language_combobox_->selected_index());
393 UpdateAdvancedView(); 393 UpdateAdvancedView();
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 base::string16 label; 755 base::string16 label;
756 if (model_->IsPageTranslatedInCurrentLanguages()) 756 if (model_->IsPageTranslatedInCurrentLanguages())
757 label = l10n_util::GetStringUTF16(IDS_DONE); 757 label = l10n_util::GetStringUTF16(IDS_DONE);
758 else 758 else
759 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); 759 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT);
760 advanced_done_button_->SetText(label); 760 advanced_done_button_->SetText(label);
761 advanced_done_button_->SizeToPreferredSize(); 761 advanced_done_button_->SizeToPreferredSize();
762 if (advanced_view_) 762 if (advanced_view_)
763 advanced_view_->Layout(); 763 advanced_view_->Layout();
764 } 764 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698