| 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 "base/stringprintf.h" |     5 #include "base/stringprintf.h" | 
|     6 #include "base/utf_string_conversions.h" |     6 #include "base/utf_string_conversions.h" | 
|     7 #include "chrome/browser/automation/automation_util.h" |     7 #include "chrome/browser/automation/automation_util.h" | 
|     8 #include "chrome/browser/extensions/extension_test_message_listener.h" |     8 #include "chrome/browser/extensions/extension_test_message_listener.h" | 
|     9 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |     9 #include "chrome/browser/extensions/platform_app_browsertest_util.h" | 
|    10 #include "chrome/browser/prerender/prerender_link_manager.h" |    10 #include "chrome/browser/prerender/prerender_link_manager.h" | 
| (...skipping 24 matching lines...) Expand all  Loading... | 
|    35 class MockWebContentsDelegate : public content::WebContentsDelegate { |    35 class MockWebContentsDelegate : public content::WebContentsDelegate { | 
|    36  public: |    36  public: | 
|    37   MockWebContentsDelegate() : requested_(false) {} |    37   MockWebContentsDelegate() : requested_(false) {} | 
|    38   virtual ~MockWebContentsDelegate() {} |    38   virtual ~MockWebContentsDelegate() {} | 
|    39  |    39  | 
|    40   virtual void RequestMediaAccessPermission( |    40   virtual void RequestMediaAccessPermission( | 
|    41       content::WebContents* web_contents, |    41       content::WebContents* web_contents, | 
|    42       const content::MediaStreamRequest& request, |    42       const content::MediaStreamRequest& request, | 
|    43       const content::MediaResponseCallback& callback) OVERRIDE { |    43       const content::MediaResponseCallback& callback) OVERRIDE { | 
|    44     requested_ = true; |    44     requested_ = true; | 
|    45     if (message_loop_runner_) |    45     if (message_loop_runner_.get()) | 
|    46       message_loop_runner_->Quit(); |    46       message_loop_runner_->Quit(); | 
|    47   } |    47   } | 
|    48  |    48  | 
|    49   void WaitForSetMediaPermission() { |    49   void WaitForSetMediaPermission() { | 
|    50     if (requested_) |    50     if (requested_) | 
|    51       return; |    51       return; | 
|    52     message_loop_runner_ = new content::MessageLoopRunner; |    52     message_loop_runner_ = new content::MessageLoopRunner; | 
|    53     message_loop_runner_->Run(); |    53     message_loop_runner_->Run(); | 
|    54   } |    54   } | 
|    55  |    55  | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|    96     message_loop_runner_ = new content::MessageLoopRunner; |    96     message_loop_runner_ = new content::MessageLoopRunner; | 
|    97     message_loop_runner_->Run(); |    97     message_loop_runner_->Run(); | 
|    98   } |    98   } | 
|    99  |    99  | 
|   100   void DownloadDecided(bool allow) { |   100   void DownloadDecided(bool allow) { | 
|   101     EXPECT_FALSE(decision_made_); |   101     EXPECT_FALSE(decision_made_); | 
|   102     decision_made_ = true; |   102     decision_made_ = true; | 
|   103  |   103  | 
|   104     if (waiting_for_decision_) { |   104     if (waiting_for_decision_) { | 
|   105       EXPECT_EQ(expect_allow_, allow); |   105       EXPECT_EQ(expect_allow_, allow); | 
|   106       if (message_loop_runner_) |   106       if (message_loop_runner_.get()) | 
|   107         message_loop_runner_->Quit(); |   107         message_loop_runner_->Quit(); | 
|   108       return; |   108       return; | 
|   109     } |   109     } | 
|   110     last_download_allowed_ = allow; |   110     last_download_allowed_ = allow; | 
|   111   } |   111   } | 
|   112  |   112  | 
|   113   void Reset() { |   113   void Reset() { | 
|   114     waiting_for_decision_ = false; |   114     waiting_for_decision_ = false; | 
|   115     decision_made_ = false; |   115     decision_made_ = false; | 
|   116   } |   116   } | 
| (...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1052   EXPECT_TRUE(content::ExecuteScript(guest_web_contents, |  1052   EXPECT_TRUE(content::ExecuteScript(guest_web_contents, | 
|  1053                                      "startDownload('download-link-2')")); |  1053                                      "startDownload('download-link-2')")); | 
|  1054   mock_delegate->WaitForCanDownload(true); // Expect to allow. |  1054   mock_delegate->WaitForCanDownload(true); // Expect to allow. | 
|  1055   mock_delegate->Reset(); |  1055   mock_delegate->Reset(); | 
|  1056  |  1056  | 
|  1057   // 3. Guest requests a download that its embedder ignores, this implies deny. |  1057   // 3. Guest requests a download that its embedder ignores, this implies deny. | 
|  1058   EXPECT_TRUE(content::ExecuteScript(guest_web_contents, |  1058   EXPECT_TRUE(content::ExecuteScript(guest_web_contents, | 
|  1059                                      "startDownload('download-link-3')")); |  1059                                      "startDownload('download-link-3')")); | 
|  1060   mock_delegate->WaitForCanDownload(false); // Expect to not allow. |  1060   mock_delegate->WaitForCanDownload(false); // Expect to not allow. | 
|  1061 } |  1061 } | 
| OLD | NEW |