| 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/values.h" | 5 #include "base/values.h" |
| 6 #include "content/browser/frame_host/navigation_entry_impl.h" | 6 #include "content/browser/frame_host/navigation_entry_impl.h" |
| 7 #include "content/browser/web_contents/web_contents_impl.h" | 7 #include "content/browser/web_contents/web_contents_impl.h" |
| 8 #include "content/public/browser/load_notification_details.h" | 8 #include "content/public/browser/load_notification_details.h" |
| 9 #include "content/public/browser/navigation_controller.h" | 9 #include "content/public/browser/navigation_controller.h" |
| 10 #include "content/public/browser/notification_details.h" | 10 #include "content/public/browser/notification_details.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 : WebContentsObserver(shell->web_contents()), | 128 : WebContentsObserver(shell->web_contents()), |
| 129 shell_(shell), | 129 shell_(shell), |
| 130 wcv_new_size_(wcv_new_size) { | 130 wcv_new_size_(wcv_new_size) { |
| 131 } | 131 } |
| 132 | 132 |
| 133 // WebContentsObserver: | 133 // WebContentsObserver: |
| 134 virtual void RenderViewCreated(RenderViewHost* rvh) OVERRIDE { | 134 virtual void RenderViewCreated(RenderViewHost* rvh) OVERRIDE { |
| 135 rwhv_create_size_ = rvh->GetView()->GetViewBounds().size(); | 135 rwhv_create_size_ = rvh->GetView()->GetViewBounds().size(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 virtual void NavigateToPendingEntry( | 138 virtual void DidCreatePendingEntry( |
| 139 const GURL& url, | 139 const GURL& url, |
| 140 NavigationController::ReloadType reload_type) OVERRIDE { | 140 NavigationController::ReloadType reload_type) OVERRIDE { |
| 141 ResizeWebContentsView(shell_, wcv_new_size_, false); | 141 ResizeWebContentsView(shell_, wcv_new_size_, false); |
| 142 } | 142 } |
| 143 | 143 |
| 144 gfx::Size rwhv_create_size() const { return rwhv_create_size_; } | 144 gfx::Size rwhv_create_size() const { return rwhv_create_size_; } |
| 145 | 145 |
| 146 private: | 146 private: |
| 147 Shell* shell_; // Weak ptr. | 147 Shell* shell_; // Weak ptr. |
| 148 gfx::Size wcv_new_size_; | 148 gfx::Size wcv_new_size_; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 gfx::Size init_size(200, 200); | 281 gfx::Size init_size(200, 200); |
| 282 gfx::Size new_size(100, 100); | 282 gfx::Size new_size(100, 100); |
| 283 size_insets = gfx::Size(-20, -30); | 283 size_insets = gfx::Size(-20, -30); |
| 284 ResizeWebContentsView(shell(), init_size, true); | 284 ResizeWebContentsView(shell(), init_size, true); |
| 285 delegate->set_size_insets(size_insets); | 285 delegate->set_size_insets(size_insets); |
| 286 RenderViewSizeObserver observer(shell(), new_size); | 286 RenderViewSizeObserver observer(shell(), new_size); |
| 287 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); | 287 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); |
| 288 // RenderWidgetHostView is created at specified size. | 288 // RenderWidgetHostView is created at specified size. |
| 289 init_size.Enlarge(size_insets.width(), size_insets.height()); | 289 init_size.Enlarge(size_insets.width(), size_insets.height()); |
| 290 EXPECT_EQ(init_size, observer.rwhv_create_size()); | 290 EXPECT_EQ(init_size, observer.rwhv_create_size()); |
| 291 // RenderViewSizeObserver resizes WebContentsView in NavigateToPendingEntry, | 291 // RenderViewSizeObserver resizes WebContentsView in DidCreatePendingEntry, |
| 292 // so both WebContentsView and RenderWidgetHostView adopt this new size. | 292 // so both WebContentsView and RenderWidgetHostView adopt this new size. |
| 293 new_size.Enlarge(size_insets.width(), size_insets.height()); | 293 new_size.Enlarge(size_insets.width(), size_insets.height()); |
| 294 EXPECT_EQ(new_size, | 294 EXPECT_EQ(new_size, |
| 295 shell()->web_contents()->GetRenderWidgetHostView()->GetViewBounds(). | 295 shell()->web_contents()->GetRenderWidgetHostView()->GetViewBounds(). |
| 296 size()); | 296 size()); |
| 297 EXPECT_EQ(new_size, shell()->web_contents()->GetView()->GetContainerSize()); | 297 EXPECT_EQ(new_size, shell()->web_contents()->GetView()->GetContainerSize()); |
| 298 } | 298 } |
| 299 | 299 |
| 300 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, OpenURLSubframe) { | 300 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, OpenURLSubframe) { |
| 301 | 301 |
| 302 // Navigate with source_frame_id 3, FrameTreeNode ID 4. | 302 // Navigate with source_frame_id 3, FrameTreeNode ID 4. |
| 303 const GURL url("http://foo"); | 303 const GURL url("http://foo"); |
| 304 OpenURLParams params(url, Referrer(), 3, 4, CURRENT_TAB, PAGE_TRANSITION_LINK, | 304 OpenURLParams params(url, Referrer(), 3, 4, CURRENT_TAB, PAGE_TRANSITION_LINK, |
| 305 true); | 305 true); |
| 306 shell()->web_contents()->OpenURL(params); | 306 shell()->web_contents()->OpenURL(params); |
| 307 | 307 |
| 308 // Make sure the NavigationEntry ends up with the FrameTreeNode ID. | 308 // Make sure the NavigationEntry ends up with the FrameTreeNode ID. |
| 309 NavigationController* controller = &shell()->web_contents()->GetController(); | 309 NavigationController* controller = &shell()->web_contents()->GetController(); |
| 310 EXPECT_TRUE(controller->GetPendingEntry()); | 310 EXPECT_TRUE(controller->GetPendingEntry()); |
| 311 EXPECT_EQ(4, NavigationEntryImpl::FromNavigationEntry( | 311 EXPECT_EQ(4, NavigationEntryImpl::FromNavigationEntry( |
| 312 controller->GetPendingEntry())->frame_tree_node_id()); | 312 controller->GetPendingEntry())->frame_tree_node_id()); |
| 313 } | 313 } |
| 314 | 314 |
| 315 | 315 |
| 316 } // namespace content | 316 } // namespace content |
| OLD | NEW |