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

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

Issue 2850007: Coverity: fix wrong assignment in swap in TranslateInfoBarDelegate2::GetAfterTranslateStrings. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: Created 10 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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>
6
5 #include "chrome/browser/translate/translate_infobar_delegate2.h" 7 #include "chrome/browser/translate/translate_infobar_delegate2.h"
6 8
7 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
9 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profile.h" 12 #include "chrome/browser/profile.h"
11 #include "chrome/browser/tab_contents/tab_contents.h" 13 #include "chrome/browser/tab_contents/tab_contents.h"
12 #include "chrome/browser/translate/translate_infobar_view.h" 14 #include "chrome/browser/translate/translate_infobar_view.h"
13 #include "chrome/browser/translate/translate_manager2.h" 15 #include "chrome/browser/translate/translate_manager2.h"
14 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 DCHECK(swap_languages); 278 DCHECK(swap_languages);
277 279
278 std::vector<size_t> offsets; 280 std::vector<size_t> offsets;
279 string16 text = 281 string16 text =
280 l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_AFTER_MESSAGE, 282 l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_AFTER_MESSAGE,
281 string16(), string16(), &offsets); 283 string16(), string16(), &offsets);
282 DCHECK(offsets.size() == 2U); 284 DCHECK(offsets.size() == 2U);
283 285
284 if (offsets[0] > offsets[1]) { 286 if (offsets[0] > offsets[1]) {
285 // Target language comes before source. 287 // Target language comes before source.
286 int tmp = offsets[0]; 288 std::swap(offsets[0], offsets[1]);
287 offsets[0] = offsets[0];
288 offsets[1] = tmp;
289 *swap_languages = true; 289 *swap_languages = true;
290 } else { 290 } else {
291 *swap_languages = false; 291 *swap_languages = false;
292 } 292 }
293 293
294 strings->push_back(text.substr(0, offsets[0])); 294 strings->push_back(text.substr(0, offsets[0]));
295 strings->push_back(text.substr(offsets[0], offsets[1])); 295 strings->push_back(text.substr(offsets[0], offsets[1]));
296 strings->push_back(text.substr(offsets[1])); 296 strings->push_back(text.substr(offsets[1]));
297 } 297 }
298 298
299 #if !defined(OS_WIN) && !defined(OS_CHROMEOS) 299 #if !defined(OS_WIN) && !defined(OS_CHROMEOS)
300 // Necessary so we link OK on Mac and Linux while the new translate infobars 300 // Necessary so we link OK on Mac and Linux while the new translate infobars
301 // are being ported to these platforms. 301 // are being ported to these platforms.
302 InfoBar* TranslateInfoBarDelegate2::CreateInfoBar() { 302 InfoBar* TranslateInfoBarDelegate2::CreateInfoBar() {
303 return NULL; 303 return NULL;
304 } 304 }
305 #endif 305 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698