Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(485)

Side by Side Diff: content/browser/web_contents/web_contents_impl_browsertest.cc

Issue 628213003: Replace OVERRIDE and FINAL with override and final in content/browser/web_contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/strings/utf_string_conversions.h" 5 #include "base/strings/utf_string_conversions.h"
6 #include "base/values.h" 6 #include "base/values.h"
7 #include "content/browser/frame_host/navigation_entry_impl.h" 7 #include "content/browser/frame_host/navigation_entry_impl.h"
8 #include "content/browser/web_contents/web_contents_impl.h" 8 #include "content/browser/web_contents/web_contents_impl.h"
9 #include "content/browser/web_contents/web_contents_view.h" 9 #include "content/browser/web_contents/web_contents_view.h"
10 #include "content/public/browser/load_notification_details.h" 10 #include "content/public/browser/load_notification_details.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 class LoadStopNotificationObserver : public WindowedNotificationObserver { 58 class LoadStopNotificationObserver : public WindowedNotificationObserver {
59 public: 59 public:
60 LoadStopNotificationObserver(NavigationController* controller) 60 LoadStopNotificationObserver(NavigationController* controller)
61 : WindowedNotificationObserver(NOTIFICATION_LOAD_STOP, 61 : WindowedNotificationObserver(NOTIFICATION_LOAD_STOP,
62 Source<NavigationController>(controller)), 62 Source<NavigationController>(controller)),
63 session_index_(-1), 63 session_index_(-1),
64 controller_(NULL) { 64 controller_(NULL) {
65 } 65 }
66 virtual void Observe(int type, 66 virtual void Observe(int type,
67 const NotificationSource& source, 67 const NotificationSource& source,
68 const NotificationDetails& details) OVERRIDE { 68 const NotificationDetails& details) override {
69 if (type == NOTIFICATION_LOAD_STOP) { 69 if (type == NOTIFICATION_LOAD_STOP) {
70 const Details<LoadNotificationDetails> load_details(details); 70 const Details<LoadNotificationDetails> load_details(details);
71 url_ = load_details->url; 71 url_ = load_details->url;
72 session_index_ = load_details->session_index; 72 session_index_ = load_details->session_index;
73 controller_ = load_details->controller; 73 controller_ = load_details->controller;
74 } 74 }
75 WindowedNotificationObserver::Observe(type, source, details); 75 WindowedNotificationObserver::Observe(type, source, details);
76 } 76 }
77 77
78 GURL url_; 78 GURL url_;
79 int session_index_; 79 int session_index_;
80 NavigationController* controller_; 80 NavigationController* controller_;
81 }; 81 };
82 82
83 // Starts a new navigation as soon as the current one commits, but does not 83 // Starts a new navigation as soon as the current one commits, but does not
84 // wait for it to complete. This allows us to observe DidStopLoading while 84 // wait for it to complete. This allows us to observe DidStopLoading while
85 // a pending entry is present. 85 // a pending entry is present.
86 class NavigateOnCommitObserver : public WebContentsObserver { 86 class NavigateOnCommitObserver : public WebContentsObserver {
87 public: 87 public:
88 NavigateOnCommitObserver(Shell* shell, GURL url) 88 NavigateOnCommitObserver(Shell* shell, GURL url)
89 : WebContentsObserver(shell->web_contents()), 89 : WebContentsObserver(shell->web_contents()),
90 shell_(shell), 90 shell_(shell),
91 url_(url), 91 url_(url),
92 done_(false) { 92 done_(false) {
93 } 93 }
94 94
95 // WebContentsObserver: 95 // WebContentsObserver:
96 virtual void NavigationEntryCommitted( 96 virtual void NavigationEntryCommitted(
97 const LoadCommittedDetails& load_details) OVERRIDE { 97 const LoadCommittedDetails& load_details) override {
98 if (!done_) { 98 if (!done_) {
99 done_ = true; 99 done_ = true;
100 shell_->Stop(); 100 shell_->Stop();
101 shell_->LoadURL(url_); 101 shell_->LoadURL(url_);
102 } 102 }
103 } 103 }
104 104
105 Shell* shell_; 105 Shell* shell_;
106 GURL url_; 106 GURL url_;
107 bool done_; 107 bool done_;
108 }; 108 };
109 109
110 class RenderViewSizeDelegate : public WebContentsDelegate { 110 class RenderViewSizeDelegate : public WebContentsDelegate {
111 public: 111 public:
112 void set_size_insets(const gfx::Size& size_insets) { 112 void set_size_insets(const gfx::Size& size_insets) {
113 size_insets_ = size_insets; 113 size_insets_ = size_insets;
114 } 114 }
115 115
116 // WebContentsDelegate: 116 // WebContentsDelegate:
117 virtual gfx::Size GetSizeForNewRenderView( 117 virtual gfx::Size GetSizeForNewRenderView(
118 WebContents* web_contents) const OVERRIDE { 118 WebContents* web_contents) const override {
119 gfx::Size size(web_contents->GetContainerBounds().size()); 119 gfx::Size size(web_contents->GetContainerBounds().size());
120 size.Enlarge(size_insets_.width(), size_insets_.height()); 120 size.Enlarge(size_insets_.width(), size_insets_.height());
121 return size; 121 return size;
122 } 122 }
123 123
124 private: 124 private:
125 gfx::Size size_insets_; 125 gfx::Size size_insets_;
126 }; 126 };
127 127
128 class RenderViewSizeObserver : public WebContentsObserver { 128 class RenderViewSizeObserver : public WebContentsObserver {
129 public: 129 public:
130 RenderViewSizeObserver(Shell* shell, const gfx::Size& wcv_new_size) 130 RenderViewSizeObserver(Shell* shell, const gfx::Size& wcv_new_size)
131 : WebContentsObserver(shell->web_contents()), 131 : WebContentsObserver(shell->web_contents()),
132 shell_(shell), 132 shell_(shell),
133 wcv_new_size_(wcv_new_size) { 133 wcv_new_size_(wcv_new_size) {
134 } 134 }
135 135
136 // WebContentsObserver: 136 // WebContentsObserver:
137 virtual void RenderViewCreated(RenderViewHost* rvh) OVERRIDE { 137 virtual void RenderViewCreated(RenderViewHost* rvh) override {
138 rwhv_create_size_ = rvh->GetView()->GetViewBounds().size(); 138 rwhv_create_size_ = rvh->GetView()->GetViewBounds().size();
139 } 139 }
140 140
141 virtual void DidStartNavigationToPendingEntry( 141 virtual void DidStartNavigationToPendingEntry(
142 const GURL& url, 142 const GURL& url,
143 NavigationController::ReloadType reload_type) OVERRIDE { 143 NavigationController::ReloadType reload_type) override {
144 ResizeWebContentsView(shell_, wcv_new_size_, false); 144 ResizeWebContentsView(shell_, wcv_new_size_, false);
145 } 145 }
146 146
147 gfx::Size rwhv_create_size() const { return rwhv_create_size_; } 147 gfx::Size rwhv_create_size() const { return rwhv_create_size_; }
148 148
149 private: 149 private:
150 Shell* shell_; // Weak ptr. 150 Shell* shell_; // Weak ptr.
151 gfx::Size wcv_new_size_; 151 gfx::Size wcv_new_size_;
152 gfx::Size rwhv_create_size_; 152 gfx::Size rwhv_create_size_;
153 }; 153 };
154 154
155 class LoadingStateChangedDelegate : public WebContentsDelegate { 155 class LoadingStateChangedDelegate : public WebContentsDelegate {
156 public: 156 public:
157 LoadingStateChangedDelegate() 157 LoadingStateChangedDelegate()
158 : loadingStateChangedCount_(0) 158 : loadingStateChangedCount_(0)
159 , loadingStateToDifferentDocumentCount_(0) { 159 , loadingStateToDifferentDocumentCount_(0) {
160 } 160 }
161 161
162 // WebContentsDelegate: 162 // WebContentsDelegate:
163 virtual void LoadingStateChanged(WebContents* contents, 163 virtual void LoadingStateChanged(WebContents* contents,
164 bool to_different_document) OVERRIDE { 164 bool to_different_document) override {
165 loadingStateChangedCount_++; 165 loadingStateChangedCount_++;
166 if (to_different_document) 166 if (to_different_document)
167 loadingStateToDifferentDocumentCount_++; 167 loadingStateToDifferentDocumentCount_++;
168 } 168 }
169 169
170 int loadingStateChangedCount() const { return loadingStateChangedCount_; } 170 int loadingStateChangedCount() const { return loadingStateChangedCount_; }
171 int loadingStateToDifferentDocumentCount() const { 171 int loadingStateToDifferentDocumentCount() const {
172 return loadingStateToDifferentDocumentCount_; 172 return loadingStateToDifferentDocumentCount_;
173 } 173 }
174 174
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 378
379 // Observer class to track the creation of RenderFrameHost objects. It is used 379 // Observer class to track the creation of RenderFrameHost objects. It is used
380 // in subsequent tests. 380 // in subsequent tests.
381 class RenderFrameCreatedObserver : public WebContentsObserver { 381 class RenderFrameCreatedObserver : public WebContentsObserver {
382 public: 382 public:
383 RenderFrameCreatedObserver(Shell* shell) 383 RenderFrameCreatedObserver(Shell* shell)
384 : WebContentsObserver(shell->web_contents()), 384 : WebContentsObserver(shell->web_contents()),
385 last_rfh_(NULL) { 385 last_rfh_(NULL) {
386 } 386 }
387 387
388 virtual void RenderFrameCreated(RenderFrameHost* render_frame_host) OVERRIDE { 388 virtual void RenderFrameCreated(RenderFrameHost* render_frame_host) override {
389 last_rfh_ = render_frame_host; 389 last_rfh_ = render_frame_host;
390 } 390 }
391 391
392 RenderFrameHost* last_rfh() const { return last_rfh_; } 392 RenderFrameHost* last_rfh() const { return last_rfh_; }
393 393
394 private: 394 private:
395 RenderFrameHost* last_rfh_; 395 RenderFrameHost* last_rfh_;
396 396
397 DISALLOW_COPY_AND_ASSIGN(RenderFrameCreatedObserver); 397 DISALLOW_COPY_AND_ASSIGN(RenderFrameCreatedObserver);
398 }; 398 };
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 public WebContentsObserver { 483 public WebContentsObserver {
484 LoadProgressDelegateAndObserver(Shell* shell) 484 LoadProgressDelegateAndObserver(Shell* shell)
485 : WebContentsObserver(shell->web_contents()), 485 : WebContentsObserver(shell->web_contents()),
486 did_start_loading(false), 486 did_start_loading(false),
487 did_stop_loading(false) { 487 did_stop_loading(false) {
488 web_contents()->SetDelegate(this); 488 web_contents()->SetDelegate(this);
489 } 489 }
490 490
491 // WebContentsDelegate: 491 // WebContentsDelegate:
492 virtual void LoadProgressChanged(WebContents* source, 492 virtual void LoadProgressChanged(WebContents* source,
493 double progress) OVERRIDE { 493 double progress) override {
494 EXPECT_TRUE(did_start_loading); 494 EXPECT_TRUE(did_start_loading);
495 EXPECT_FALSE(did_stop_loading); 495 EXPECT_FALSE(did_stop_loading);
496 progresses.push_back(progress); 496 progresses.push_back(progress);
497 } 497 }
498 498
499 // WebContentsObserver: 499 // WebContentsObserver:
500 virtual void DidStartLoading(RenderViewHost* render_view_host) OVERRIDE { 500 virtual void DidStartLoading(RenderViewHost* render_view_host) override {
501 EXPECT_FALSE(did_start_loading); 501 EXPECT_FALSE(did_start_loading);
502 EXPECT_EQ(0U, progresses.size()); 502 EXPECT_EQ(0U, progresses.size());
503 EXPECT_FALSE(did_stop_loading); 503 EXPECT_FALSE(did_stop_loading);
504 did_start_loading = true; 504 did_start_loading = true;
505 } 505 }
506 506
507 virtual void DidStopLoading(RenderViewHost* render_view_host) OVERRIDE { 507 virtual void DidStopLoading(RenderViewHost* render_view_host) override {
508 EXPECT_TRUE(did_start_loading); 508 EXPECT_TRUE(did_start_loading);
509 EXPECT_GE(progresses.size(), 1U); 509 EXPECT_GE(progresses.size(), 1U);
510 EXPECT_FALSE(did_stop_loading); 510 EXPECT_FALSE(did_stop_loading);
511 did_stop_loading = true; 511 did_stop_loading = true;
512 } 512 }
513 513
514 bool did_start_loading; 514 bool did_start_loading;
515 std::vector<double> progresses; 515 std::vector<double> progresses;
516 bool did_stop_loading; 516 bool did_stop_loading;
517 }; 517 };
(...skipping 18 matching lines...) Expand all
536 ASSERT_GE(progresses.size(), 1U) 536 ASSERT_GE(progresses.size(), 1U)
537 << "There should be at least one progress update"; 537 << "There should be at least one progress update";
538 EXPECT_EQ(1.0, *progresses.rbegin()); 538 EXPECT_EQ(1.0, *progresses.rbegin());
539 } 539 }
540 540
541 struct FirstVisuallyNonEmptyPaintObserver : public WebContentsObserver { 541 struct FirstVisuallyNonEmptyPaintObserver : public WebContentsObserver {
542 FirstVisuallyNonEmptyPaintObserver(Shell* shell) 542 FirstVisuallyNonEmptyPaintObserver(Shell* shell)
543 : WebContentsObserver(shell->web_contents()), 543 : WebContentsObserver(shell->web_contents()),
544 did_fist_visually_non_empty_paint_(false) {} 544 did_fist_visually_non_empty_paint_(false) {}
545 545
546 virtual void DidFirstVisuallyNonEmptyPaint() OVERRIDE { 546 virtual void DidFirstVisuallyNonEmptyPaint() override {
547 did_fist_visually_non_empty_paint_ = true; 547 did_fist_visually_non_empty_paint_ = true;
548 on_did_first_visually_non_empty_paint_.Run(); 548 on_did_first_visually_non_empty_paint_.Run();
549 } 549 }
550 550
551 void WaitForDidFirstVisuallyNonEmptyPaint() { 551 void WaitForDidFirstVisuallyNonEmptyPaint() {
552 if (did_fist_visually_non_empty_paint_) 552 if (did_fist_visually_non_empty_paint_)
553 return; 553 return;
554 base::RunLoop run_loop; 554 base::RunLoop run_loop;
555 on_did_first_visually_non_empty_paint_ = run_loop.QuitClosure(); 555 on_did_first_visually_non_empty_paint_ = run_loop.QuitClosure();
556 run_loop.Run(); 556 run_loop.Run();
(...skipping 17 matching lines...) Expand all
574 new FirstVisuallyNonEmptyPaintObserver(shell())); 574 new FirstVisuallyNonEmptyPaintObserver(shell()));
575 575
576 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); 576 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"));
577 577
578 observer->WaitForDidFirstVisuallyNonEmptyPaint(); 578 observer->WaitForDidFirstVisuallyNonEmptyPaint();
579 ASSERT_TRUE(observer->did_fist_visually_non_empty_paint_); 579 ASSERT_TRUE(observer->did_fist_visually_non_empty_paint_);
580 } 580 }
581 581
582 } // namespace content 582 } // namespace content
583 583
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/browser/web_contents/web_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698