| 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 "components/translate/content/browser/content_translate_driver.h" | 5 #include "components/translate/content/browser/content_translate_driver.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 return; | 182 return; |
| 183 } | 183 } |
| 184 | 184 |
| 185 // If not a reload, return. | 185 // If not a reload, return. |
| 186 if (!ui::PageTransitionCoreTypeIs(entry->GetTransitionType(), | 186 if (!ui::PageTransitionCoreTypeIs(entry->GetTransitionType(), |
| 187 ui::PAGE_TRANSITION_RELOAD) && | 187 ui::PAGE_TRANSITION_RELOAD) && |
| 188 load_details.type != content::NAVIGATION_TYPE_SAME_PAGE) { | 188 load_details.type != content::NAVIGATION_TYPE_SAME_PAGE) { |
| 189 return; | 189 return; |
| 190 } | 190 } |
| 191 | 191 |
| 192 if (entry->GetTransitionType() & ui::PAGE_TRANSITION_FORWARD_BACK) { |
| 193 // Workaround for http://crbug.com/653051: back navigation sometimes have |
| 194 // the reload core type. Once http://crbug.com/669008 got resolved, we |
| 195 // could revisit here for a thorough solution. |
| 196 return; |
| 197 } |
| 198 |
| 192 if (!translate_manager_->GetLanguageState().page_needs_translation()) | 199 if (!translate_manager_->GetLanguageState().page_needs_translation()) |
| 193 return; | 200 return; |
| 194 | 201 |
| 195 // Note that we delay it as the ordering of the processing of this callback | 202 // Note that we delay it as the ordering of the processing of this callback |
| 196 // by WebContentsObservers is undefined and might result in the current | 203 // by WebContentsObservers is undefined and might result in the current |
| 197 // infobars being removed. Since the translation initiation process might add | 204 // infobars being removed. Since the translation initiation process might add |
| 198 // an infobar, it must be done after that. | 205 // an infobar, it must be done after that. |
| 199 base::ThreadTaskRunnerHandle::Get()->PostTask( | 206 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 200 FROM_HERE, | 207 FROM_HERE, |
| 201 base::Bind(&ContentTranslateDriver::InitiateTranslation, | 208 base::Bind(&ContentTranslateDriver::InitiateTranslation, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 if (cancelled) | 257 if (cancelled) |
| 251 return; | 258 return; |
| 252 | 259 |
| 253 translate_manager_->PageTranslated( | 260 translate_manager_->PageTranslated( |
| 254 original_lang, translated_lang, error_type); | 261 original_lang, translated_lang, error_type); |
| 255 for (auto& observer : observer_list_) | 262 for (auto& observer : observer_list_) |
| 256 observer.OnPageTranslated(original_lang, translated_lang, error_type); | 263 observer.OnPageTranslated(original_lang, translated_lang, error_type); |
| 257 } | 264 } |
| 258 | 265 |
| 259 } // namespace translate | 266 } // namespace translate |
| OLD | NEW |