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

Side by Side Diff: chrome/browser/translate/translate_infobar_delegate.cc

Issue 15295004: Translate: enable against unknown languages with server side detection (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/translate/translate_infobar_delegate.h" 5 #include "chrome/browser/translate/translate_infobar_delegate.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/string_compare.h" 9 #include "base/i18n/string_compare.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 283
284 *swap_languages = (offsets[0] > offsets[1]); 284 *swap_languages = (offsets[0] > offsets[1]);
285 if (*swap_languages) 285 if (*swap_languages)
286 std::swap(offsets[0], offsets[1]); 286 std::swap(offsets[0], offsets[1]);
287 287
288 strings->push_back(text.substr(0, offsets[0])); 288 strings->push_back(text.substr(0, offsets[0]));
289 strings->push_back(text.substr(offsets[0], offsets[1] - offsets[0])); 289 strings->push_back(text.substr(offsets[0], offsets[1] - offsets[0]));
290 strings->push_back(text.substr(offsets[1])); 290 strings->push_back(text.substr(offsets[1]));
291 } 291 }
292 292
293 // static
294 void TranslateInfoBarDelegate::GetAfterTranslateWithAutoStrings(
295 std::vector<string16>* strings) {
296 DCHECK(strings);
297
298 size_t offset;
299 string16 text =
300 l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_AFTER_MESSAGE_WITH_AUTO,
301 string16(), &offset);
302
303 strings->push_back(text.substr(0, offset));
304 strings->push_back(text.substr(offset));
305 }
306
293 TranslateInfoBarDelegate::TranslateInfoBarDelegate( 307 TranslateInfoBarDelegate::TranslateInfoBarDelegate(
294 Type infobar_type, 308 Type infobar_type,
295 TranslateErrors::Type error_type, 309 TranslateErrors::Type error_type,
296 InfoBarService* infobar_service, 310 InfoBarService* infobar_service,
297 PrefService* prefs, 311 PrefService* prefs,
298 ShortcutConfiguration shortcut_config, 312 ShortcutConfiguration shortcut_config,
299 const std::string& original_language, 313 const std::string& original_language,
300 const std::string& target_language) 314 const std::string& target_language)
301 : InfoBarDelegate(infobar_service), 315 : InfoBarDelegate(infobar_service),
302 infobar_type_(infobar_type), 316 infobar_type_(infobar_type),
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 392
379 TranslateInfoBarDelegate* 393 TranslateInfoBarDelegate*
380 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { 394 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() {
381 return this; 395 return this;
382 } 396 }
383 397
384 std::string TranslateInfoBarDelegate::GetPageHost() { 398 std::string TranslateInfoBarDelegate::GetPageHost() {
385 NavigationEntry* entry = web_contents()->GetController().GetActiveEntry(); 399 NavigationEntry* entry = web_contents()->GetController().GetActiveEntry();
386 return entry ? entry->GetURL().HostNoBrackets() : std::string(); 400 return entry ? entry->GetURL().HostNoBrackets() : std::string();
387 } 401 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698