| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <set> | 6 #include <set> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 SimulateOnPageTranslated( | 128 SimulateOnPageTranslated( |
| 129 0, source_lang, target_lang, translate::TranslateErrors::NONE); | 129 0, source_lang, target_lang, translate::TranslateErrors::NONE); |
| 130 } | 130 } |
| 131 | 131 |
| 132 bool GetTranslateMessage(std::string* original_lang, | 132 bool GetTranslateMessage(std::string* original_lang, |
| 133 std::string* target_lang) { | 133 std::string* target_lang) { |
| 134 const IPC::Message* message = process()->sink().GetFirstMessageMatching( | 134 const IPC::Message* message = process()->sink().GetFirstMessageMatching( |
| 135 ChromeViewMsg_TranslatePage::ID); | 135 ChromeViewMsg_TranslatePage::ID); |
| 136 if (!message) | 136 if (!message) |
| 137 return false; | 137 return false; |
| 138 Tuple4<int, std::string, std::string, std::string> translate_param; | 138 Tuple<int, std::string, std::string, std::string> translate_param; |
| 139 ChromeViewMsg_TranslatePage::Read(message, &translate_param); | 139 ChromeViewMsg_TranslatePage::Read(message, &translate_param); |
| 140 // Ignore translate_param.a which is the page seq no. | 140 // Ignore get<0>(translate_param) which is the page seq no. |
| 141 // Ignore translate_param.b which is the script injected in the page. | 141 // Ignore get<1>(translate_param) which is the script injected in the page. |
| 142 if (original_lang) | 142 if (original_lang) |
| 143 *original_lang = translate_param.c; | 143 *original_lang = get<2>(translate_param); |
| 144 if (target_lang) | 144 if (target_lang) |
| 145 *target_lang = translate_param.d; | 145 *target_lang = get<3>(translate_param); |
| 146 return true; | 146 return true; |
| 147 } | 147 } |
| 148 | 148 |
| 149 InfoBarService* infobar_service() { | 149 InfoBarService* infobar_service() { |
| 150 return InfoBarService::FromWebContents(web_contents()); | 150 return InfoBarService::FromWebContents(web_contents()); |
| 151 } | 151 } |
| 152 | 152 |
| 153 // Returns the translate infobar if there is 1 infobar and it is a translate | 153 // Returns the translate infobar if there is 1 infobar and it is a translate |
| 154 // infobar. | 154 // infobar. |
| 155 translate::TranslateInfoBarDelegate* GetTranslateInfoBar() { | 155 translate::TranslateInfoBarDelegate* GetTranslateInfoBar() { |
| (...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1669 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE, 0); | 1669 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE, 0); |
| 1670 | 1670 |
| 1671 // Check the bubble exists instead of the infobar. | 1671 // Check the bubble exists instead of the infobar. |
| 1672 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 1672 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
| 1673 ASSERT_TRUE(infobar == NULL); | 1673 ASSERT_TRUE(infobar == NULL); |
| 1674 TranslateBubbleModel* bubble = factory->model(); | 1674 TranslateBubbleModel* bubble = factory->model(); |
| 1675 ASSERT_TRUE(bubble != NULL); | 1675 ASSERT_TRUE(bubble != NULL); |
| 1676 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, | 1676 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, |
| 1677 bubble->GetViewState()); | 1677 bubble->GetViewState()); |
| 1678 } | 1678 } |
| OLD | NEW |