OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 if (!encoding_screenshot_in_progress_) | 95 if (!encoding_screenshot_in_progress_) |
96 return; | 96 return; |
97 message_loop_runner_ = new content::MessageLoopRunner; | 97 message_loop_runner_ = new content::MessageLoopRunner; |
98 message_loop_runner_->Run(); | 98 message_loop_runner_->Run(); |
99 } | 99 } |
100 | 100 |
101 private: | 101 private: |
102 // Overridden from content::NavigationEntryScreenshotManager: | 102 // Overridden from content::NavigationEntryScreenshotManager: |
103 virtual void TakeScreenshotImpl( | 103 virtual void TakeScreenshotImpl( |
104 content::RenderViewHost* host, | 104 content::RenderViewHost* host, |
105 content::NavigationEntryImpl* entry) OVERRIDE { | 105 content::NavigationEntryImpl* entry) override { |
106 } | 106 } |
107 | 107 |
108 virtual void OnScreenshotSet(content::NavigationEntryImpl* entry) OVERRIDE { | 108 virtual void OnScreenshotSet(content::NavigationEntryImpl* entry) override { |
109 encoding_screenshot_in_progress_ = false; | 109 encoding_screenshot_in_progress_ = false; |
110 NavigationEntryScreenshotManager::OnScreenshotSet(entry); | 110 NavigationEntryScreenshotManager::OnScreenshotSet(entry); |
111 if (message_loop_runner_.get()) | 111 if (message_loop_runner_.get()) |
112 message_loop_runner_->Quit(); | 112 message_loop_runner_->Quit(); |
113 } | 113 } |
114 | 114 |
115 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 115 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
116 bool encoding_screenshot_in_progress_; | 116 bool encoding_screenshot_in_progress_; |
117 | 117 |
118 DISALLOW_COPY_AND_ASSIGN(MockScreenshotManager); | 118 DISALLOW_COPY_AND_ASSIGN(MockScreenshotManager); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 181 |
182 // NavigationControllerTest ---------------------------------------------------- | 182 // NavigationControllerTest ---------------------------------------------------- |
183 | 183 |
184 class NavigationControllerTest | 184 class NavigationControllerTest |
185 : public RenderViewHostImplTestHarness, | 185 : public RenderViewHostImplTestHarness, |
186 public WebContentsObserver { | 186 public WebContentsObserver { |
187 public: | 187 public: |
188 NavigationControllerTest() : navigation_entry_committed_counter_(0) { | 188 NavigationControllerTest() : navigation_entry_committed_counter_(0) { |
189 } | 189 } |
190 | 190 |
191 virtual void SetUp() OVERRIDE { | 191 virtual void SetUp() override { |
192 RenderViewHostImplTestHarness::SetUp(); | 192 RenderViewHostImplTestHarness::SetUp(); |
193 WebContents* web_contents = RenderViewHostImplTestHarness::web_contents(); | 193 WebContents* web_contents = RenderViewHostImplTestHarness::web_contents(); |
194 ASSERT_TRUE(web_contents); // The WebContents should be created by now. | 194 ASSERT_TRUE(web_contents); // The WebContents should be created by now. |
195 WebContentsObserver::Observe(web_contents); | 195 WebContentsObserver::Observe(web_contents); |
196 } | 196 } |
197 | 197 |
198 // WebContentsObserver: | 198 // WebContentsObserver: |
199 virtual void DidStartNavigationToPendingEntry( | 199 virtual void DidStartNavigationToPendingEntry( |
200 const GURL& url, | 200 const GURL& url, |
201 NavigationController::ReloadType reload_type) OVERRIDE { | 201 NavigationController::ReloadType reload_type) override { |
202 navigated_url_ = url; | 202 navigated_url_ = url; |
203 } | 203 } |
204 | 204 |
205 virtual void NavigationEntryCommitted( | 205 virtual void NavigationEntryCommitted( |
206 const LoadCommittedDetails& load_details) OVERRIDE { | 206 const LoadCommittedDetails& load_details) override { |
207 navigation_entry_committed_counter_++; | 207 navigation_entry_committed_counter_++; |
208 } | 208 } |
209 | 209 |
210 const GURL& navigated_url() const { | 210 const GURL& navigated_url() const { |
211 return navigated_url_; | 211 return navigated_url_; |
212 } | 212 } |
213 | 213 |
214 NavigationControllerImpl& controller_impl() { | 214 NavigationControllerImpl& controller_impl() { |
215 return static_cast<NavigationControllerImpl&>(controller()); | 215 return static_cast<NavigationControllerImpl&>(controller()); |
216 } | 216 } |
(...skipping 24 matching lines...) Expand all Loading... |
241 int navigation_state_change_count() { | 241 int navigation_state_change_count() { |
242 return navigation_state_change_count_; | 242 return navigation_state_change_count_; |
243 } | 243 } |
244 | 244 |
245 int repost_form_warning_count() { | 245 int repost_form_warning_count() { |
246 return repost_form_warning_count_; | 246 return repost_form_warning_count_; |
247 } | 247 } |
248 | 248 |
249 // Keep track of whether the tab has notified us of a navigation state change. | 249 // Keep track of whether the tab has notified us of a navigation state change. |
250 virtual void NavigationStateChanged(const WebContents* source, | 250 virtual void NavigationStateChanged(const WebContents* source, |
251 InvalidateTypes changed_flags) OVERRIDE { | 251 InvalidateTypes changed_flags) override { |
252 navigation_state_change_count_++; | 252 navigation_state_change_count_++; |
253 } | 253 } |
254 | 254 |
255 virtual void ShowRepostFormWarningDialog(WebContents* source) OVERRIDE { | 255 virtual void ShowRepostFormWarningDialog(WebContents* source) override { |
256 repost_form_warning_count_++; | 256 repost_form_warning_count_++; |
257 } | 257 } |
258 | 258 |
259 private: | 259 private: |
260 // The number of times NavigationStateChanged has been called. | 260 // The number of times NavigationStateChanged has been called. |
261 int navigation_state_change_count_; | 261 int navigation_state_change_count_; |
262 | 262 |
263 // The number of times ShowRepostFormWarningDialog() was called. | 263 // The number of times ShowRepostFormWarningDialog() was called. |
264 int repost_form_warning_count_; | 264 int repost_form_warning_count_; |
265 }; | 265 }; |
(...skipping 2021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2287 class PrunedListener : public NotificationObserver { | 2287 class PrunedListener : public NotificationObserver { |
2288 public: | 2288 public: |
2289 explicit PrunedListener(NavigationControllerImpl* controller) | 2289 explicit PrunedListener(NavigationControllerImpl* controller) |
2290 : notification_count_(0) { | 2290 : notification_count_(0) { |
2291 registrar_.Add(this, NOTIFICATION_NAV_LIST_PRUNED, | 2291 registrar_.Add(this, NOTIFICATION_NAV_LIST_PRUNED, |
2292 Source<NavigationController>(controller)); | 2292 Source<NavigationController>(controller)); |
2293 } | 2293 } |
2294 | 2294 |
2295 virtual void Observe(int type, | 2295 virtual void Observe(int type, |
2296 const NotificationSource& source, | 2296 const NotificationSource& source, |
2297 const NotificationDetails& details) OVERRIDE { | 2297 const NotificationDetails& details) override { |
2298 if (type == NOTIFICATION_NAV_LIST_PRUNED) { | 2298 if (type == NOTIFICATION_NAV_LIST_PRUNED) { |
2299 notification_count_++; | 2299 notification_count_++; |
2300 details_ = *(Details<PrunedDetails>(details).ptr()); | 2300 details_ = *(Details<PrunedDetails>(details).ptr()); |
2301 } | 2301 } |
2302 } | 2302 } |
2303 | 2303 |
2304 // Number of times NAV_LIST_PRUNED has been observed. | 2304 // Number of times NAV_LIST_PRUNED has been observed. |
2305 int notification_count_; | 2305 int notification_count_; |
2306 | 2306 |
2307 // Details from the last NAV_LIST_PRUNED. | 2307 // Details from the last NAV_LIST_PRUNED. |
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4354 params.post_id = -1; | 4354 params.post_id = -1; |
4355 test_rvh()->SendNavigateWithParams(¶ms); | 4355 test_rvh()->SendNavigateWithParams(¶ms); |
4356 | 4356 |
4357 // Now reload. replaceState overrides the POST, so we should not show a | 4357 // Now reload. replaceState overrides the POST, so we should not show a |
4358 // repost warning dialog. | 4358 // repost warning dialog. |
4359 controller_impl().Reload(true); | 4359 controller_impl().Reload(true); |
4360 EXPECT_EQ(0, delegate->repost_form_warning_count()); | 4360 EXPECT_EQ(0, delegate->repost_form_warning_count()); |
4361 } | 4361 } |
4362 | 4362 |
4363 } // namespace content | 4363 } // namespace content |
OLD | NEW |