Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Unified Diff: components/translate/core/browser/translate_manager.cc

Issue 1997573002: [Translate] Don't try to translate when offline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review fixes. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/translate/core/browser/translate_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/translate/core/browser/translate_manager.cc
diff --git a/components/translate/core/browser/translate_manager.cc b/components/translate/core/browser/translate_manager.cc
index 2524c228d532dedb9bb91dba669d801fa0dd52e7..689b70abadafdd04cda61e97e886500dfc546990 100644
--- a/components/translate/core/browser/translate_manager.cc
+++ b/components/translate/core/browser/translate_manager.cc
@@ -31,6 +31,7 @@
#include "components/translate/core/common/translate_switches.h"
#include "components/translate/core/common/translate_util.h"
#include "google_apis/google_api_keys.h"
+#include "net/base/network_change_notifier.h"
#include "net/base/url_util.h"
#include "net/http/http_status_code.h"
@@ -89,6 +90,11 @@ void TranslateManager::InitiateTranslation(const std::string& page_lang) {
return;
}
+ // Also, skip if the connection is currently offline - initiation doesn't make
+ // sense there, either.
+ if (net::NetworkChangeNotifier::IsOffline())
+ return;
+
if (!ignore_missing_key_for_testing_ &&
!::google_apis::HasKeysConfigured()) {
// Without an API key, translate won't work, so don't offer to translate
« no previous file with comments | « no previous file | components/translate/core/browser/translate_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698