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

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

Issue 2074913002: Enable the translate bubble to be dismissed when user ignores it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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 | « chrome/browser/ui/views/translate/translate_bubble_view.h ('k') | 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 void TranslateBubbleView::CloseCurrentBubble() { 164 void TranslateBubbleView::CloseCurrentBubble() {
165 if (translate_bubble_view_) 165 if (translate_bubble_view_)
166 translate_bubble_view_->CloseBubble(); 166 translate_bubble_view_->CloseBubble();
167 } 167 }
168 168
169 // static 169 // static
170 TranslateBubbleView* TranslateBubbleView::GetCurrentBubble() { 170 TranslateBubbleView* TranslateBubbleView::GetCurrentBubble() {
171 return translate_bubble_view_; 171 return translate_bubble_view_;
172 } 172 }
173 173
174 void TranslateBubbleView::CloseBubble() {
175 mouse_handler_.reset();
176 LocationBarBubbleDelegateView::CloseBubble();
177 }
178
174 void TranslateBubbleView::Init() { 179 void TranslateBubbleView::Init() {
175 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 180 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
176 181
177 before_translate_view_ = CreateViewBeforeTranslate(); 182 before_translate_view_ = CreateViewBeforeTranslate();
178 translating_view_ = CreateViewTranslating(); 183 translating_view_ = CreateViewTranslating();
179 after_translate_view_ = CreateViewAfterTranslate(); 184 after_translate_view_ = CreateViewAfterTranslate();
180 error_view_ = CreateViewError(); 185 error_view_ = CreateViewError();
181 advanced_view_ = CreateViewAdvanced(); 186 advanced_view_ = CreateViewAdvanced();
182 187
183 AddChildView(before_translate_view_); 188 AddChildView(before_translate_view_);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 target_language_combobox_(NULL), 373 target_language_combobox_(NULL),
369 always_translate_checkbox_(NULL), 374 always_translate_checkbox_(NULL),
370 advanced_cancel_button_(NULL), 375 advanced_cancel_button_(NULL),
371 advanced_done_button_(NULL), 376 advanced_done_button_(NULL),
372 denial_menu_button_(NULL), 377 denial_menu_button_(NULL),
373 model_(std::move(model)), 378 model_(std::move(model)),
374 error_type_(error_type), 379 error_type_(error_type),
375 is_in_incognito_window_( 380 is_in_incognito_window_(
376 web_contents && web_contents->GetBrowserContext()->IsOffTheRecord()) { 381 web_contents && web_contents->GetBrowserContext()->IsOffTheRecord()) {
377 translate_bubble_view_ = this; 382 translate_bubble_view_ = this;
383 if (web_contents) // web_contents can be null in unit_tests.
384 mouse_handler_.reset(new WebContentMouseHandler(this, web_contents));
378 } 385 }
379 386
380 views::View* TranslateBubbleView::GetCurrentView() const { 387 views::View* TranslateBubbleView::GetCurrentView() const {
381 switch (model_->GetViewState()) { 388 switch (model_->GetViewState()) {
382 case TranslateBubbleModel::VIEW_STATE_BEFORE_TRANSLATE: 389 case TranslateBubbleModel::VIEW_STATE_BEFORE_TRANSLATE:
383 return before_translate_view_; 390 return before_translate_view_;
384 case TranslateBubbleModel::VIEW_STATE_TRANSLATING: 391 case TranslateBubbleModel::VIEW_STATE_TRANSLATING:
385 return translating_view_; 392 return translating_view_;
386 case TranslateBubbleModel::VIEW_STATE_AFTER_TRANSLATE: 393 case TranslateBubbleModel::VIEW_STATE_AFTER_TRANSLATE:
387 return after_translate_view_; 394 return after_translate_view_;
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 base::string16 label; 945 base::string16 label;
939 if (model_->IsPageTranslatedInCurrentLanguages()) 946 if (model_->IsPageTranslatedInCurrentLanguages())
940 label = l10n_util::GetStringUTF16(IDS_DONE); 947 label = l10n_util::GetStringUTF16(IDS_DONE);
941 else 948 else
942 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); 949 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT);
943 advanced_done_button_->SetText(label); 950 advanced_done_button_->SetText(label);
944 advanced_done_button_->SizeToPreferredSize(); 951 advanced_done_button_->SizeToPreferredSize();
945 if (advanced_view_) 952 if (advanced_view_)
946 advanced_view_->Layout(); 953 advanced_view_->Layout();
947 } 954 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/translate/translate_bubble_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698