| OLD | NEW | 
|     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  |     5  | 
|     6 #include <algorithm> |     6 #include <algorithm> | 
|     7 #include <set> |     7 #include <set> | 
|     8 #include <vector> |     8 #include <vector> | 
|     9  |     9  | 
|    10 #include "base/json/json_writer.h" |    10 #include "base/json/json_writer.h" | 
|    11 #include "base/memory/scoped_ptr.h" |    11 #include "base/memory/scoped_ptr.h" | 
|    12 #include "base/stringprintf.h" |    12 #include "base/stringprintf.h" | 
|    13 #include "base/utf_string_conversions.h" |    13 #include "base/utf_string_conversions.h" | 
|    14 #include "base/values.h" |    14 #include "base/values.h" | 
|    15 #include "chrome/app/chrome_command_ids.h" |    15 #include "chrome/app/chrome_command_ids.h" | 
 |    16 #include "chrome/browser/extensions/extension_system_factory.h" | 
 |    17 #include "chrome/browser/extensions/test_extension_system.h" | 
|    16 #include "chrome/browser/infobars/infobar.h" |    18 #include "chrome/browser/infobars/infobar.h" | 
|    17 #include "chrome/browser/infobars/infobar_tab_helper.h" |    19 #include "chrome/browser/infobars/infobar_tab_helper.h" | 
|    18 #include "chrome/browser/prefs/pref_change_registrar.h" |    20 #include "chrome/browser/prefs/pref_change_registrar.h" | 
|    19 #include "chrome/browser/prefs/pref_service.h" |    21 #include "chrome/browser/prefs/pref_service.h" | 
|    20 #include "chrome/browser/tab_contents/render_view_context_menu.h" |    22 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 
|    21 #include "chrome/browser/translate/translate_infobar_delegate.h" |    23 #include "chrome/browser/translate/translate_infobar_delegate.h" | 
|    22 #include "chrome/browser/translate/translate_manager.h" |    24 #include "chrome/browser/translate/translate_manager.h" | 
|    23 #include "chrome/browser/translate/translate_prefs.h" |    25 #include "chrome/browser/translate/translate_prefs.h" | 
|    24 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |    26 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 
|    25 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" |    27 #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" | 
| (...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1340   translate_prefs.ResetTranslationAcceptedCount("fr"); |  1342   translate_prefs.ResetTranslationAcceptedCount("fr"); | 
|  1341   translate_prefs.ResetTranslationDeniedCount("fr"); |  1343   translate_prefs.ResetTranslationDeniedCount("fr"); | 
|  1342   translate_prefs.ResetTranslationAcceptedCount("de"); |  1344   translate_prefs.ResetTranslationAcceptedCount("de"); | 
|  1343   translate_prefs.ResetTranslationDeniedCount("de"); |  1345   translate_prefs.ResetTranslationDeniedCount("de"); | 
|  1344  |  1346  | 
|  1345   // We'll do 4 times in incognito mode first to make sure the button is not |  1347   // We'll do 4 times in incognito mode first to make sure the button is not | 
|  1346   // shown in that case, then 4 times in normal mode. |  1348   // shown in that case, then 4 times in normal mode. | 
|  1347   TranslateInfoBarDelegate* infobar; |  1349   TranslateInfoBarDelegate* infobar; | 
|  1348   TestingProfile* test_profile = |  1350   TestingProfile* test_profile = | 
|  1349       static_cast<TestingProfile*>(contents()->GetBrowserContext()); |  1351       static_cast<TestingProfile*>(contents()->GetBrowserContext()); | 
|  1350   test_profile->CreateExtensionProcessManager(); |  1352   static_cast<TestExtensionSystem*>( | 
 |  1353       ExtensionSystemFactory::GetForProfile(test_profile))-> | 
 |  1354       CreateExtensionProcessManager(); | 
|  1351   test_profile->set_incognito(true); |  1355   test_profile->set_incognito(true); | 
|  1352   for (int i = 0; i < 8; ++i) { |  1356   for (int i = 0; i < 8; ++i) { | 
|  1353     SCOPED_TRACE(::testing::Message() << "Iteration " << i << |  1357     SCOPED_TRACE(::testing::Message() << "Iteration " << i << | 
|  1354         " incognito mode=" << test_profile->IsOffTheRecord()); |  1358         " incognito mode=" << test_profile->IsOffTheRecord()); | 
|  1355     SimulateNavigation(GURL("http://www.google.fr"), "fr", true); |  1359     SimulateNavigation(GURL("http://www.google.fr"), "fr", true); | 
|  1356     infobar = GetTranslateInfoBar(); |  1360     infobar = GetTranslateInfoBar(); | 
|  1357     ASSERT_TRUE(infobar != NULL); |  1361     ASSERT_TRUE(infobar != NULL); | 
|  1358     EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); |  1362     EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); | 
|  1359     if (i < 7) { |  1363     if (i < 7) { | 
|  1360       EXPECT_FALSE(infobar->ShouldShowAlwaysTranslateButton()); |  1364       EXPECT_FALSE(infobar->ShouldShowAlwaysTranslateButton()); | 
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1456           NULL); |  1460           NULL); | 
|  1457   // Now simulate the URL fetch. |  1461   // Now simulate the URL fetch. | 
|  1458   SimulateTranslateScriptURLFetch(true); |  1462   SimulateTranslateScriptURLFetch(true); | 
|  1459   // Now the message should have been sent. |  1463   // Now the message should have been sent. | 
|  1460   int page_id = 0; |  1464   int page_id = 0; | 
|  1461   std::string original_lang, target_lang; |  1465   std::string original_lang, target_lang; | 
|  1462   EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); |  1466   EXPECT_TRUE(GetTranslateMessage(&page_id, &original_lang, &target_lang)); | 
|  1463   EXPECT_EQ("es", original_lang); |  1467   EXPECT_EQ("es", original_lang); | 
|  1464   EXPECT_EQ("en", target_lang); |  1468   EXPECT_EQ("en", target_lang); | 
|  1465 } |  1469 } | 
| OLD | NEW |