OLD | NEW |
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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/i18n/string_compare.h" | 13 #include "base/i18n/string_compare.h" |
14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
15 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/translate/chrome_translate_client.h" | 19 #include "chrome/browser/translate/chrome_translate_client.h" |
20 #include "chrome/browser/translate/translate_service.h" | 20 #include "chrome/browser/translate/translate_service.h" |
| 21 #include "chrome/browser/ui/browser_dialogs.h" |
21 #include "chrome/browser/ui/chrome_pages.h" | 22 #include "chrome/browser/ui/chrome_pages.h" |
22 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" | 23 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" |
23 #include "chrome/browser/ui/translate/translate_bubble_view_state_transition.h" | 24 #include "chrome/browser/ui/translate/translate_bubble_view_state_transition.h" |
24 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
25 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
26 #include "components/prefs/pref_service.h" | 27 #include "components/prefs/pref_service.h" |
27 #include "components/strings/grit/components_strings.h" | 28 #include "components/strings/grit/components_strings.h" |
28 #include "components/translate/core/browser/translate_download_manager.h" | 29 #include "components/translate/core/browser/translate_download_manager.h" |
29 #include "components/translate/core/browser/translate_manager.h" | 30 #include "components/translate/core/browser/translate_manager.h" |
30 #include "components/translate/core/browser/translate_prefs.h" | 31 #include "components/translate/core/browser/translate_prefs.h" |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 advanced_done_button_(NULL), | 356 advanced_done_button_(NULL), |
356 denial_menu_button_(NULL), | 357 denial_menu_button_(NULL), |
357 model_(std::move(model)), | 358 model_(std::move(model)), |
358 error_type_(error_type), | 359 error_type_(error_type), |
359 is_in_incognito_window_( | 360 is_in_incognito_window_( |
360 web_contents && web_contents->GetBrowserContext()->IsOffTheRecord()), | 361 web_contents && web_contents->GetBrowserContext()->IsOffTheRecord()), |
361 should_always_translate_(false) { | 362 should_always_translate_(false) { |
362 translate_bubble_view_ = this; | 363 translate_bubble_view_ = this; |
363 if (web_contents) // web_contents can be null in unit_tests. | 364 if (web_contents) // web_contents can be null in unit_tests. |
364 mouse_handler_.reset(new WebContentMouseHandler(this, web_contents)); | 365 mouse_handler_.reset(new WebContentMouseHandler(this, web_contents)); |
| 366 RecordDialogCreation(chrome::DialogIdentifier::TRANSLATE); |
365 } | 367 } |
366 | 368 |
367 views::View* TranslateBubbleView::GetCurrentView() const { | 369 views::View* TranslateBubbleView::GetCurrentView() const { |
368 switch (model_->GetViewState()) { | 370 switch (model_->GetViewState()) { |
369 case TranslateBubbleModel::VIEW_STATE_BEFORE_TRANSLATE: | 371 case TranslateBubbleModel::VIEW_STATE_BEFORE_TRANSLATE: |
370 return before_translate_view_; | 372 return before_translate_view_; |
371 case TranslateBubbleModel::VIEW_STATE_TRANSLATING: | 373 case TranslateBubbleModel::VIEW_STATE_TRANSLATING: |
372 return translating_view_; | 374 return translating_view_; |
373 case TranslateBubbleModel::VIEW_STATE_AFTER_TRANSLATE: | 375 case TranslateBubbleModel::VIEW_STATE_AFTER_TRANSLATE: |
374 return after_translate_view_; | 376 return after_translate_view_; |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
941 base::string16 label; | 943 base::string16 label; |
942 if (model_->IsPageTranslatedInCurrentLanguages()) | 944 if (model_->IsPageTranslatedInCurrentLanguages()) |
943 label = l10n_util::GetStringUTF16(IDS_DONE); | 945 label = l10n_util::GetStringUTF16(IDS_DONE); |
944 else | 946 else |
945 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); | 947 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); |
946 advanced_done_button_->SetText(label); | 948 advanced_done_button_->SetText(label); |
947 advanced_done_button_->SizeToPreferredSize(); | 949 advanced_done_button_->SizeToPreferredSize(); |
948 if (advanced_view_) | 950 if (advanced_view_) |
949 advanced_view_->Layout(); | 951 advanced_view_->Layout(); |
950 } | 952 } |
OLD | NEW |