| 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 #include <stdint.h> | 5 #include <stdint.h> | 
| 6 #include <utility> | 6 #include <utility> | 
| 7 | 7 | 
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" | 
| 9 #include "base/logging.h" | 9 #include "base/logging.h" | 
| 10 #include "base/macros.h" | 10 #include "base/macros.h" | 
| (...skipping 3407 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3418   void RunBeforeUnloadDialog(WebContents* web_contents, | 3418   void RunBeforeUnloadDialog(WebContents* web_contents, | 
| 3419                              bool is_reload, | 3419                              bool is_reload, | 
| 3420                              const DialogClosedCallback& callback) override {} | 3420                              const DialogClosedCallback& callback) override {} | 
| 3421 | 3421 | 
| 3422   bool HandleJavaScriptDialog(WebContents* web_contents, | 3422   bool HandleJavaScriptDialog(WebContents* web_contents, | 
| 3423                               bool accept, | 3423                               bool accept, | 
| 3424                               const base::string16* prompt_override) override { | 3424                               const base::string16* prompt_override) override { | 
| 3425     return true; | 3425     return true; | 
| 3426   } | 3426   } | 
| 3427 | 3427 | 
| 3428   void CancelActiveAndPendingDialogs(WebContents* web_contents) override {} | 3428   void CancelDialogs(WebContents* web_contents, | 
| 3429 | 3429                      bool suppress_callbacks, | 
| 3430   void ResetDialogState(WebContents* web_contents) override { ++reset_count_; } | 3430                      bool reset_state) override { | 
|  | 3431     if (reset_state) | 
|  | 3432       ++reset_count_; | 
|  | 3433   } | 
| 3431 | 3434 | 
| 3432  private: | 3435  private: | 
| 3433   size_t reset_count_ = 0; | 3436   size_t reset_count_ = 0; | 
| 3434 | 3437 | 
| 3435   DISALLOW_COPY_AND_ASSIGN(TestJavaScriptDialogManager); | 3438   DISALLOW_COPY_AND_ASSIGN(TestJavaScriptDialogManager); | 
| 3436 }; | 3439 }; | 
| 3437 | 3440 | 
| 3438 }  // namespace | 3441 }  // namespace | 
| 3439 | 3442 | 
| 3440 TEST_F(WebContentsImplTest, ResetJavaScriptDialogOnUserNavigate) { | 3443 TEST_F(WebContentsImplTest, ResetJavaScriptDialogOnUserNavigate) { | 
| 3441   TestJavaScriptDialogManager dialog_manager; | 3444   TestJavaScriptDialogManager dialog_manager; | 
| 3442   contents()->SetJavaScriptDialogManagerForTesting(&dialog_manager); | 3445   contents()->SetJavaScriptDialogManagerForTesting(&dialog_manager); | 
| 3443 | 3446 | 
| 3444   // A user-initiated navigation. | 3447   // A user-initiated navigation. | 
| 3445   contents()->TestDidNavigate(main_test_rfh(), 1, 0, true, | 3448   contents()->TestDidNavigate(main_test_rfh(), 1, 0, true, | 
| 3446                               GURL("about:whatever"), | 3449                               GURL("about:whatever"), | 
| 3447                               ui::PAGE_TRANSITION_TYPED); | 3450                               ui::PAGE_TRANSITION_TYPED); | 
| 3448   EXPECT_EQ(1u, dialog_manager.reset_count()); | 3451   EXPECT_EQ(1u, dialog_manager.reset_count()); | 
| 3449 | 3452 | 
| 3450   // An automatic navigation. | 3453   // An automatic navigation. | 
| 3451   main_test_rfh()->SendNavigateWithModificationCallback( | 3454   main_test_rfh()->SendNavigateWithModificationCallback( | 
| 3452       2, 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); | 3455       2, 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); | 
| 3453 | 3456 | 
| 3454   EXPECT_EQ(1u, dialog_manager.reset_count()); | 3457   EXPECT_EQ(1u, dialog_manager.reset_count()); | 
| 3455 | 3458 | 
| 3456   contents()->SetJavaScriptDialogManagerForTesting(nullptr); | 3459   contents()->SetJavaScriptDialogManagerForTesting(nullptr); | 
| 3457 } | 3460 } | 
| 3458 | 3461 | 
| 3459 }  // namespace content | 3462 }  // namespace content | 
| OLD | NEW | 
|---|