| 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 <list> | 5 #include <list> |
| 6 #include <set> | 6 #include <set> |
| 7 | 7 |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "chrome/browser/ui/browser.h" | 30 #include "chrome/browser/ui/browser.h" |
| 31 #include "chrome/browser/ui/browser_navigator_params.h" | 31 #include "chrome/browser/ui/browser_navigator_params.h" |
| 32 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 32 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 33 #include "chrome/test/base/ui_test_utils.h" | 33 #include "chrome/test/base/ui_test_utils.h" |
| 34 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
| 35 #include "content/public/browser/navigation_handle.h" | 35 #include "content/public/browser/navigation_handle.h" |
| 36 #include "content/public/browser/render_frame_host.h" | 36 #include "content/public/browser/render_frame_host.h" |
| 37 #include "content/public/browser/render_process_host.h" | 37 #include "content/public/browser/render_process_host.h" |
| 38 #include "content/public/browser/render_view_host.h" | 38 #include "content/public/browser/render_view_host.h" |
| 39 #include "content/public/browser/render_widget_host.h" | 39 #include "content/public/browser/render_widget_host.h" |
| 40 #include "content/public/browser/resource_controller.h" | |
| 41 #include "content/public/browser/resource_dispatcher_host.h" | 40 #include "content/public/browser/resource_dispatcher_host.h" |
| 42 #include "content/public/browser/resource_throttle.h" | 41 #include "content/public/browser/resource_throttle.h" |
| 43 #include "content/public/browser/web_contents.h" | 42 #include "content/public/browser/web_contents.h" |
| 44 #include "content/public/common/browser_side_navigation_policy.h" | 43 #include "content/public/common/browser_side_navigation_policy.h" |
| 45 #include "content/public/common/context_menu_params.h" | 44 #include "content/public/common/context_menu_params.h" |
| 46 #include "content/public/common/resource_type.h" | 45 #include "content/public/common/resource_type.h" |
| 47 #include "content/public/common/url_constants.h" | 46 #include "content/public/common/url_constants.h" |
| 48 #include "content/public/test/browser_test_utils.h" | 47 #include "content/public/test/browser_test_utils.h" |
| 49 #include "content/public/test/test_utils.h" | 48 #include "content/public/test/test_utils.h" |
| 50 #include "extensions/browser/extension_system.h" | 49 #include "extensions/browser/extension_system.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { | 86 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { |
| 88 content::BrowserThread::PostTask( | 87 content::BrowserThread::PostTask( |
| 89 content::BrowserThread::IO, | 88 content::BrowserThread::IO, |
| 90 FROM_HERE, | 89 FROM_HERE, |
| 91 base::Bind(&TestNavigationListener::ResumeAll, this)); | 90 base::Bind(&TestNavigationListener::ResumeAll, this)); |
| 92 return; | 91 return; |
| 93 } | 92 } |
| 94 WeakThrottleList::const_iterator it; | 93 WeakThrottleList::const_iterator it; |
| 95 for (it = throttles_.begin(); it != throttles_.end(); ++it) { | 94 for (it = throttles_.begin(); it != throttles_.end(); ++it) { |
| 96 if (it->get()) | 95 if (it->get()) |
| 97 (*it)->Resume(); | 96 (*it)->ResumeHandler(); |
| 98 } | 97 } |
| 99 throttles_.clear(); | 98 throttles_.clear(); |
| 100 } | 99 } |
| 101 | 100 |
| 102 // Resume a specific request. | 101 // Resume a specific request. |
| 103 void Resume(const GURL& url) { | 102 void Resume(const GURL& url) { |
| 104 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { | 103 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) { |
| 105 content::BrowserThread::PostTask( | 104 content::BrowserThread::PostTask( |
| 106 content::BrowserThread::IO, FROM_HERE, | 105 content::BrowserThread::IO, FROM_HERE, |
| 107 base::Bind(&TestNavigationListener::Resume, this, url)); | 106 base::Bind(&TestNavigationListener::Resume, this, url)); |
| 108 return; | 107 return; |
| 109 } | 108 } |
| 110 WeakThrottleList::iterator it; | 109 WeakThrottleList::iterator it; |
| 111 for (it = throttles_.begin(); it != throttles_.end(); ++it) { | 110 for (it = throttles_.begin(); it != throttles_.end(); ++it) { |
| 112 if (it->get() && it->get()->url() == url) { | 111 if (it->get() && it->get()->url() == url) { |
| 113 (*it)->Resume(); | 112 (*it)->ResumeHandler(); |
| 114 throttles_.erase(it); | 113 throttles_.erase(it); |
| 115 break; | 114 break; |
| 116 } | 115 } |
| 117 } | 116 } |
| 118 } | 117 } |
| 119 | 118 |
| 120 // Constructs a ResourceThrottle if the request for |url| should be held. | 119 // Constructs a ResourceThrottle if the request for |url| should be held. |
| 121 // | 120 // |
| 122 // Needs to be invoked on the IO thread. | 121 // Needs to be invoked on the IO thread. |
| 123 content::ResourceThrottle* CreateResourceThrottle( | 122 content::ResourceThrottle* CreateResourceThrottle( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 134 | 133 |
| 135 private: | 134 private: |
| 136 friend class base::RefCountedThreadSafe<TestNavigationListener>; | 135 friend class base::RefCountedThreadSafe<TestNavigationListener>; |
| 137 | 136 |
| 138 virtual ~TestNavigationListener() {} | 137 virtual ~TestNavigationListener() {} |
| 139 | 138 |
| 140 // Stores a throttle per URL request that we have delayed. | 139 // Stores a throttle per URL request that we have delayed. |
| 141 class Throttle : public content::ResourceThrottle, | 140 class Throttle : public content::ResourceThrottle, |
| 142 public base::SupportsWeakPtr<Throttle> { | 141 public base::SupportsWeakPtr<Throttle> { |
| 143 public: | 142 public: |
| 144 void Resume() { | 143 void ResumeHandler() { Resume(); } |
| 145 controller()->Resume(); | |
| 146 } | |
| 147 | 144 |
| 148 // content::ResourceThrottle implementation. | 145 // content::ResourceThrottle implementation. |
| 149 void WillStartRequest(bool* defer) override { *defer = true; } | 146 void WillStartRequest(bool* defer) override { *defer = true; } |
| 150 | 147 |
| 151 const char* GetNameForLogging() const override { | 148 const char* GetNameForLogging() const override { |
| 152 return "TestNavigationListener::Throttle"; | 149 return "TestNavigationListener::Throttle"; |
| 153 } | 150 } |
| 154 | 151 |
| 155 void set_url(const GURL& url) { url_ = url; } | 152 void set_url(const GURL& url) { url_ = url; } |
| 156 const GURL& url() { return url_; } | 153 const GURL& url() { return url_; } |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 "extensions/api_test/webnavigation/crash/b.html", | 810 "extensions/api_test/webnavigation/crash/b.html", |
| 814 embedded_test_server()->port())); | 811 embedded_test_server()->port())); |
| 815 ui_test_utils::NavigateToURL(browser(), url); | 812 ui_test_utils::NavigateToURL(browser(), url); |
| 816 | 813 |
| 817 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 814 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 818 } | 815 } |
| 819 | 816 |
| 820 #endif | 817 #endif |
| 821 | 818 |
| 822 } // namespace extensions | 819 } // namespace extensions |
| OLD | NEW |