summaryrefslogtreecommitdiff
path: root/Userland/Applications/Browser
diff options
context:
space:
mode:
authorBrandon Scott <xeons@users.noreply.github.com>2021-02-23 06:18:22 -0600
committerAndreas Kling <kling@serenityos.org>2021-02-23 16:23:56 +0100
commit99e6c9b23def60dbdf250306dcec290d77895c3c (patch)
tree297edd06429b9521f2d4c09295ac66e7ba349bef /Userland/Applications/Browser
parent2f56a86a4ee3db4ca6bf712a11072ff53ef1b603 (diff)
downloadserenity-99e6c9b23def60dbdf250306dcec290d77895c3c.zip
Browser: Implement view source for out of process mode
Implemented view source functionality for out of process mode and moved view source dialog creation into seperate static method.
Diffstat (limited to 'Userland/Applications/Browser')
-rw-r--r--Userland/Applications/Browser/Tab.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp
index 3c90645e6e..984882d2d9 100644
--- a/Userland/Applications/Browser/Tab.cpp
+++ b/Userland/Applications/Browser/Tab.cpp
@@ -85,6 +85,20 @@ static void start_download(const URL& url)
[[maybe_unused]] auto& unused = window.leak_ref();
}
+static void view_source(const String& url, const String& source)
+{
+ auto window = GUI::Window::construct();
+ auto& editor = window->set_main_widget<GUI::TextEditor>();
+ editor.set_text(source);
+ editor.set_mode(GUI::TextEditor::ReadOnly);
+ editor.set_ruler_visible(true);
+ window->resize(640, 480);
+ window->set_title(url);
+ window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-text.png"));
+ window->show();
+ [[maybe_unused]] auto& unused = window.leak_ref();
+}
+
Tab::Tab(Type type)
: m_type(type)
{
@@ -232,6 +246,10 @@ Tab::Tab(Type type)
on_favicon_change(icon);
};
+ hooks().on_get_source = [this](auto& url, auto& source) {
+ view_source(url.to_string(), source);
+ };
+
// FIXME: Support JS console in multi-process mode.
if (m_type == Type::InProcessWebView) {
hooks().on_set_document = [this](auto* document) {
@@ -303,18 +321,9 @@ Tab::Tab(Type type)
ASSERT(m_page_view->document());
auto url = m_page_view->document()->url().to_string();
auto source = m_page_view->document()->source();
- auto window = GUI::Window::construct();
- auto& editor = window->set_main_widget<GUI::TextEditor>();
- editor.set_text(source);
- editor.set_mode(GUI::TextEditor::ReadOnly);
- editor.set_ruler_visible(true);
- window->resize(640, 480);
- window->set_title(url);
- window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-text.png"));
- window->show();
- [[maybe_unused]] auto& unused = window.leak_ref();
+ view_source(url, source);
} else {
- TODO();
+ m_web_content_view->get_source();
}
},
this);