| 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> |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 reason == AUTOMATIC) { | 103 reason == AUTOMATIC) { |
| 104 return nullptr; | 104 return nullptr; |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 std::string source_language; | 108 std::string source_language; |
| 109 std::string target_language; | 109 std::string target_language; |
| 110 ChromeTranslateClient::GetTranslateLanguages( | 110 ChromeTranslateClient::GetTranslateLanguages( |
| 111 web_contents, &source_language, &target_language); | 111 web_contents, &source_language, &target_language); |
| 112 | 112 |
| 113 scoped_ptr<translate::TranslateUIDelegate> ui_delegate( | 113 std::unique_ptr<translate::TranslateUIDelegate> ui_delegate( |
| 114 new translate::TranslateUIDelegate( | 114 new translate::TranslateUIDelegate( |
| 115 ChromeTranslateClient::GetManagerFromWebContents(web_contents) | 115 ChromeTranslateClient::GetManagerFromWebContents(web_contents) |
| 116 ->GetWeakPtr(), | 116 ->GetWeakPtr(), |
| 117 source_language, | 117 source_language, target_language)); |
| 118 target_language)); | 118 std::unique_ptr<TranslateBubbleModel> model( |
| 119 scoped_ptr<TranslateBubbleModel> model( | |
| 120 new TranslateBubbleModelImpl(step, std::move(ui_delegate))); | 119 new TranslateBubbleModelImpl(step, std::move(ui_delegate))); |
| 121 TranslateBubbleView* view = new TranslateBubbleView( | 120 TranslateBubbleView* view = new TranslateBubbleView( |
| 122 anchor_view, std::move(model), error_type, web_contents); | 121 anchor_view, std::move(model), error_type, web_contents); |
| 123 views::Widget* bubble_widget = | 122 views::Widget* bubble_widget = |
| 124 views::BubbleDialogDelegateView::CreateBubble(view); | 123 views::BubbleDialogDelegateView::CreateBubble(view); |
| 125 view->ShowForReason(reason); | 124 view->ShowForReason(reason); |
| 126 return bubble_widget; | 125 return bubble_widget; |
| 127 } | 126 } |
| 128 | 127 |
| 129 // static | 128 // static |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 void TranslateBubbleView::WebContentsDestroyed() { | 235 void TranslateBubbleView::WebContentsDestroyed() { |
| 237 GetWidget()->CloseNow(); | 236 GetWidget()->CloseNow(); |
| 238 } | 237 } |
| 239 | 238 |
| 240 TranslateBubbleModel::ViewState TranslateBubbleView::GetViewState() const { | 239 TranslateBubbleModel::ViewState TranslateBubbleView::GetViewState() const { |
| 241 return model_->GetViewState(); | 240 return model_->GetViewState(); |
| 242 } | 241 } |
| 243 | 242 |
| 244 TranslateBubbleView::TranslateBubbleView( | 243 TranslateBubbleView::TranslateBubbleView( |
| 245 views::View* anchor_view, | 244 views::View* anchor_view, |
| 246 scoped_ptr<TranslateBubbleModel> model, | 245 std::unique_ptr<TranslateBubbleModel> model, |
| 247 translate::TranslateErrors::Type error_type, | 246 translate::TranslateErrors::Type error_type, |
| 248 content::WebContents* web_contents) | 247 content::WebContents* web_contents) |
| 249 : LocationBarBubbleDelegateView(anchor_view, web_contents), | 248 : LocationBarBubbleDelegateView(anchor_view, web_contents), |
| 250 WebContentsObserver(web_contents), | 249 WebContentsObserver(web_contents), |
| 251 before_translate_view_(NULL), | 250 before_translate_view_(NULL), |
| 252 translating_view_(NULL), | 251 translating_view_(NULL), |
| 253 after_translate_view_(NULL), | 252 after_translate_view_(NULL), |
| 254 error_view_(NULL), | 253 error_view_(NULL), |
| 255 advanced_view_(NULL), | 254 advanced_view_(NULL), |
| 256 denial_combobox_(NULL), | 255 denial_combobox_(NULL), |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 base::string16 label; | 740 base::string16 label; |
| 742 if (model_->IsPageTranslatedInCurrentLanguages()) | 741 if (model_->IsPageTranslatedInCurrentLanguages()) |
| 743 label = l10n_util::GetStringUTF16(IDS_DONE); | 742 label = l10n_util::GetStringUTF16(IDS_DONE); |
| 744 else | 743 else |
| 745 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); | 744 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); |
| 746 advanced_done_button_->SetText(label); | 745 advanced_done_button_->SetText(label); |
| 747 advanced_done_button_->SizeToPreferredSize(); | 746 advanced_done_button_->SizeToPreferredSize(); |
| 748 if (advanced_view_) | 747 if (advanced_view_) |
| 749 advanced_view_->Layout(); | 748 advanced_view_->Layout(); |
| 750 } | 749 } |
| OLD | NEW |