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

Side by Side Diff: content/public/test/content_browser_test_utils.h

Issue 1917073002: Block webpages from navigating to view-source URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add layout and browser tests Created 4 years, 7 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 (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 #ifndef CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_ 5 #ifndef CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_
6 #define CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_ 6 #define CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.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"
11 #include "content/public/browser/web_contents_delegate.h"
11 #include "content/public/common/page_type.h" 12 #include "content/public/common/page_type.h"
12 #include "ui/gfx/native_widget_types.h" 13 #include "ui/gfx/native_widget_types.h"
13 #include "url/gurl.h" 14 #include "url/gurl.h"
14 15
15 namespace base { 16 namespace base {
16 class FilePath; 17 class FilePath;
17 } 18 }
18 19
19 namespace gfx { 20 namespace gfx {
20 class Rect; 21 class Rect;
21 } 22 }
22 23
23 // A collections of functions designed for use with content_shell based browser 24 // A collections of functions designed for use with content_shell based browser
24 // tests. 25 // tests.
25 // Note: if a function here also works with browser_tests, it should be in 26 // Note: if a function here also works with browser_tests, it should be in
26 // content\public\test\browser_test_utils.h 27 // content\public\test\browser_test_utils.h
27 28
28 namespace content { 29 namespace content {
29 30
30 class MessageLoopRunner; 31 class MessageLoopRunner;
31 class Shell; 32 class Shell;
33 class WebContents;
32 34
33 // Generate the file path for testing a particular test. 35 // Generate the file path for testing a particular test.
34 // The file for the tests is all located in 36 // The file for the tests is all located in
35 // content/test/data/dir/<file> 37 // content/test/data/dir/<file>
36 // The returned path is FilePath format. 38 // The returned path is FilePath format.
37 base::FilePath GetTestFilePath(const char* dir, const char* file); 39 base::FilePath GetTestFilePath(const char* dir, const char* file);
38 40
39 // Generate the URL for testing a particular test. 41 // Generate the URL for testing a particular test.
40 // HTML for the tests is all located in 42 // HTML for the tests is all located in
41 // test_root_directory/dir/<file> 43 // test_root_directory/dir/<file>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 93
92 private: 94 private:
93 void ShellCreated(Shell* shell); 95 void ShellCreated(Shell* shell);
94 96
95 Shell* shell_; 97 Shell* shell_;
96 scoped_refptr<MessageLoopRunner> runner_; 98 scoped_refptr<MessageLoopRunner> runner_;
97 99
98 DISALLOW_COPY_AND_ASSIGN(ShellAddedObserver); 100 DISALLOW_COPY_AND_ASSIGN(ShellAddedObserver);
99 }; 101 };
100 102
103 // A WebContentsDelegate that catches messages sent to the console.
104 class ConsoleObserverDelegate : public WebContentsDelegate {
105 public:
106 ConsoleObserverDelegate(WebContents* web_contents, const std::string& filter);
107
108 ~ConsoleObserverDelegate() override;
Charlie Reis 2016/05/24 22:54:17 nit: No blank line above.
meacer 2016/05/31 23:57:54 Done.
109
110 bool AddMessageToConsole(WebContents* source,
Charlie Reis 2016/05/24 22:54:17 nit: // WebContentsDelegate overrides.
meacer 2016/05/31 23:57:54 Done.
111 int32_t level,
112 const base::string16& message,
113 int32_t line_no,
114 const base::string16& source_id) override;
115
116 std::string message() { return message_; }
Charlie Reis 2016/05/24 22:54:17 nit: This is now a public interface, so it needs c
meacer 2016/05/31 23:57:54 Done.
117
118 void Wait();
Charlie Reis 2016/05/24 22:54:17 // Wait for the next message sent to the console.
meacer 2016/05/31 23:57:54 Done.
119
120 private:
121 WebContents* web_contents_;
122 std::string filter_;
123 std::string message_;
124
125 // The MessageLoopRunner used to spin the message loop.
126 scoped_refptr<MessageLoopRunner> message_loop_runner_;
127
128 DISALLOW_COPY_AND_ASSIGN(ConsoleObserverDelegate);
129 };
130
101 #if defined OS_MACOSX 131 #if defined OS_MACOSX
102 void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds); 132 void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds);
103 #endif 133 #endif
104 134
105 } // namespace content 135 } // namespace content
106 136
107 #endif // CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_ 137 #endif // CONTENT_PUBLIC_TEST_CONTENT_BROWSER_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698