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

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 10952016: Simplify the translate infobar code some. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 content::NotificationService::AllSources()); 405 content::NotificationService::AllSources());
406 ui_test_utils::NavigateToURL(browser(), url); 406 ui_test_utils::NavigateToURL(browser(), url);
407 language_observer1.Wait(); 407 language_observer1.Wait();
408 // Verify that the translate infobar showed up. 408 // Verify that the translate infobar showed up.
409 EXPECT_EQ(1u, infobar_helper->GetInfoBarCount()); 409 EXPECT_EQ(1u, infobar_helper->GetInfoBarCount());
410 InfoBarDelegate* infobar_delegate = infobar_helper->GetInfoBarDelegateAt(0); 410 InfoBarDelegate* infobar_delegate = infobar_helper->GetInfoBarDelegateAt(0);
411 TranslateInfoBarDelegate* delegate = 411 TranslateInfoBarDelegate* delegate =
412 infobar_delegate->AsTranslateInfoBarDelegate(); 412 infobar_delegate->AsTranslateInfoBarDelegate();
413 ASSERT_TRUE(delegate); 413 ASSERT_TRUE(delegate);
414 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, delegate->type()); 414 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, delegate->type());
415 EXPECT_EQ("fr", delegate->GetOriginalLanguageCode()); 415 EXPECT_EQ("fr", delegate->original_language_code());
416 416
417 // Now force disable translate. 417 // Now force disable translate.
418 ui_test_utils::CloseAllInfoBars(tab_contents); 418 ui_test_utils::CloseAllInfoBars(tab_contents);
419 EXPECT_EQ(0u, infobar_helper->GetInfoBarCount()); 419 EXPECT_EQ(0u, infobar_helper->GetInfoBarCount());
420 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY, 420 policies.Set(key::kTranslateEnabled, POLICY_LEVEL_MANDATORY,
421 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false)); 421 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false));
422 provider_.UpdateChromePolicy(policies); 422 provider_.UpdateChromePolicy(policies);
423 // Navigating to the same URL now doesn't trigger an infobar. 423 // Navigating to the same URL now doesn't trigger an infobar.
424 content::WindowedNotificationObserver language_observer2( 424 content::WindowedNotificationObserver language_observer2(
425 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, 425 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, 473 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY,
474 POLICY_SCOPE_USER, whitelist.DeepCopy()); 474 POLICY_SCOPE_USER, whitelist.DeepCopy());
475 provider_.UpdateChromePolicy(policies); 475 provider_.UpdateChromePolicy(policies);
476 CheckCanOpenURL(browser(), kAAA); 476 CheckCanOpenURL(browser(), kAAA);
477 CheckURLIsBlocked(browser(), kBBB); 477 CheckURLIsBlocked(browser(), kBBB);
478 CheckCanOpenURL(browser(), kSUB_BBB); 478 CheckCanOpenURL(browser(), kSUB_BBB);
479 CheckCanOpenURL(browser(), kBBB_PATH); 479 CheckCanOpenURL(browser(), kBBB_PATH);
480 } 480 }
481 481
482 } // namespace policy 482 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698