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 Tuple<int, std::string, std::string, std::string> translate_param; | 138 base::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 get<0>(translate_param) which is the page seq no. | 140 // Ignore get<0>(translate_param) which is the page seq no. |
141 // Ignore get<1>(translate_param) 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 = get<2>(translate_param); | 143 *original_lang = base::get<2>(translate_param); |
144 if (target_lang) | 144 if (target_lang) |
145 *target_lang = get<3>(translate_param); | 145 *target_lang = base::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 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE, 0); | 1672 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE, 0); |
1673 | 1673 |
1674 // Check the bubble exists instead of the infobar. | 1674 // Check the bubble exists instead of the infobar. |
1675 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 1675 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
1676 ASSERT_TRUE(infobar == NULL); | 1676 ASSERT_TRUE(infobar == NULL); |
1677 TranslateBubbleModel* bubble = factory->model(); | 1677 TranslateBubbleModel* bubble = factory->model(); |
1678 ASSERT_TRUE(bubble != NULL); | 1678 ASSERT_TRUE(bubble != NULL); |
1679 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, | 1679 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, |
1680 bubble->GetViewState()); | 1680 bubble->GetViewState()); |
1681 } | 1681 } |
OLD | NEW |