mirror of
https://github.com/RGBCube/serenity
synced 2025-07-03 05:32:13 +00:00
LibWeb+WebContent: Hook document.cookie to the backend cookie storage
This commit is contained in:
parent
e54837add5
commit
1ef48d50ff
12 changed files with 66 additions and 5 deletions
|
@ -825,15 +825,17 @@ void Document::completely_finish_loading()
|
||||||
dispatch_event(DOM::Event::create(HTML::EventNames::load));
|
dispatch_event(DOM::Event::create(HTML::EventNames::load));
|
||||||
}
|
}
|
||||||
|
|
||||||
String Document::cookie() const
|
String Document::cookie()
|
||||||
{
|
{
|
||||||
// FIXME: Support cookies!
|
if (auto* page = this->page())
|
||||||
|
return page->client().page_did_request_cookie(m_url);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Document::set_cookie(String)
|
void Document::set_cookie(String cookie)
|
||||||
{
|
{
|
||||||
// FIXME: Support cookies!
|
if (auto* page = this->page())
|
||||||
|
page->client().page_did_set_cookie(m_url, cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public:
|
||||||
|
|
||||||
virtual ~Document() override;
|
virtual ~Document() override;
|
||||||
|
|
||||||
String cookie() const;
|
String cookie();
|
||||||
void set_cookie(String);
|
void set_cookie(String);
|
||||||
|
|
||||||
bool should_invalidate_styles_on_attribute_changes() const { return m_should_invalidate_styles_on_attribute_changes; }
|
bool should_invalidate_styles_on_attribute_changes() const { return m_should_invalidate_styles_on_attribute_changes; }
|
||||||
|
|
|
@ -433,4 +433,17 @@ String InProcessWebView::page_did_request_prompt(const String& message, const St
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String InProcessWebView::page_did_request_cookie(const URL& url)
|
||||||
|
{
|
||||||
|
if (on_get_cookie)
|
||||||
|
return on_get_cookie(url);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void InProcessWebView::page_did_set_cookie(const URL& url, const String& cookie)
|
||||||
|
{
|
||||||
|
if (on_set_cookie)
|
||||||
|
on_set_cookie(url, cookie);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,6 +111,8 @@ private:
|
||||||
virtual void page_did_request_alert(const String&) override;
|
virtual void page_did_request_alert(const String&) override;
|
||||||
virtual bool page_did_request_confirm(const String&) override;
|
virtual bool page_did_request_confirm(const String&) override;
|
||||||
virtual String page_did_request_prompt(const String&, const String&) override;
|
virtual String page_did_request_prompt(const String&, const String&) override;
|
||||||
|
virtual String page_did_request_cookie(const URL&) override;
|
||||||
|
virtual void page_did_set_cookie(const URL&, const String&) override;
|
||||||
|
|
||||||
void layout_and_sync_size();
|
void layout_and_sync_size();
|
||||||
|
|
||||||
|
|
|
@ -365,6 +365,19 @@ void OutOfProcessWebView::notify_server_did_change_favicon(const Gfx::Bitmap& fa
|
||||||
on_favicon_change(favicon);
|
on_favicon_change(favicon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String OutOfProcessWebView::notify_server_did_request_cookie(Badge<WebContentClient>, const URL& url)
|
||||||
|
{
|
||||||
|
if (on_get_cookie)
|
||||||
|
return on_get_cookie(url);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutOfProcessWebView::notify_server_did_set_cookie(Badge<WebContentClient>, const URL& url, const String& cookie)
|
||||||
|
{
|
||||||
|
if (on_set_cookie)
|
||||||
|
on_set_cookie(url, cookie);
|
||||||
|
}
|
||||||
|
|
||||||
void OutOfProcessWebView::did_scroll()
|
void OutOfProcessWebView::did_scroll()
|
||||||
{
|
{
|
||||||
client().post_message(Messages::WebContentServer::SetViewportRect(visible_content_rect()));
|
client().post_message(Messages::WebContentServer::SetViewportRect(visible_content_rect()));
|
||||||
|
|
|
@ -79,6 +79,8 @@ public:
|
||||||
void notify_server_did_get_source(const URL& url, const String& source);
|
void notify_server_did_get_source(const URL& url, const String& source);
|
||||||
void notify_server_did_js_console_output(const String& method, const String& line);
|
void notify_server_did_js_console_output(const String& method, const String& line);
|
||||||
void notify_server_did_change_favicon(const Gfx::Bitmap& favicon);
|
void notify_server_did_change_favicon(const Gfx::Bitmap& favicon);
|
||||||
|
String notify_server_did_request_cookie(Badge<WebContentClient>, const URL& url);
|
||||||
|
void notify_server_did_set_cookie(Badge<WebContentClient>, const URL& url, const String& cookie);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OutOfProcessWebView();
|
OutOfProcessWebView();
|
||||||
|
|
|
@ -111,6 +111,8 @@ public:
|
||||||
virtual void page_did_request_alert(const String&) { }
|
virtual void page_did_request_alert(const String&) { }
|
||||||
virtual bool page_did_request_confirm(const String&) { return false; }
|
virtual bool page_did_request_confirm(const String&) { return false; }
|
||||||
virtual String page_did_request_prompt(const String&, const String&) { return {}; }
|
virtual String page_did_request_prompt(const String&, const String&) { return {}; }
|
||||||
|
virtual String page_did_request_cookie(const URL&) { return {}; }
|
||||||
|
virtual void page_did_set_cookie(const URL&, const String&) { }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,4 +197,15 @@ void WebContentClient::handle(const Messages::WebContentClient::DidChangeFavicon
|
||||||
m_view.notify_server_did_change_favicon(*message.favicon().bitmap());
|
m_view.notify_server_did_change_favicon(*message.favicon().bitmap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OwnPtr<Messages::WebContentClient::DidRequestCookieResponse> WebContentClient::handle(const Messages::WebContentClient::DidRequestCookie& message)
|
||||||
|
{
|
||||||
|
auto result = m_view.notify_server_did_request_cookie({}, message.url());
|
||||||
|
return make<Messages::WebContentClient::DidRequestCookieResponse>(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebContentClient::handle(const Messages::WebContentClient::DidSetCookie& message)
|
||||||
|
{
|
||||||
|
m_view.notify_server_did_set_cookie({}, message.url(), message.cookie());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,8 @@ private:
|
||||||
virtual OwnPtr<Messages::WebContentClient::DidRequestAlertResponse> handle(const Messages::WebContentClient::DidRequestAlert&) override;
|
virtual OwnPtr<Messages::WebContentClient::DidRequestAlertResponse> handle(const Messages::WebContentClient::DidRequestAlert&) override;
|
||||||
virtual OwnPtr<Messages::WebContentClient::DidRequestConfirmResponse> handle(const Messages::WebContentClient::DidRequestConfirm&) override;
|
virtual OwnPtr<Messages::WebContentClient::DidRequestConfirmResponse> handle(const Messages::WebContentClient::DidRequestConfirm&) override;
|
||||||
virtual OwnPtr<Messages::WebContentClient::DidRequestPromptResponse> handle(const Messages::WebContentClient::DidRequestPrompt&) override;
|
virtual OwnPtr<Messages::WebContentClient::DidRequestPromptResponse> handle(const Messages::WebContentClient::DidRequestPrompt&) override;
|
||||||
|
virtual OwnPtr<Messages::WebContentClient::DidRequestCookieResponse> handle(const Messages::WebContentClient::DidRequestCookie&) override;
|
||||||
|
virtual void handle(const Messages::WebContentClient::DidSetCookie&) override;
|
||||||
|
|
||||||
OutOfProcessWebView& m_view;
|
OutOfProcessWebView& m_view;
|
||||||
};
|
};
|
||||||
|
|
|
@ -208,4 +208,14 @@ void PageHost::page_did_request_image_context_menu(const Gfx::IntPoint& content_
|
||||||
m_client.post_message(Messages::WebContentClient::DidRequestImageContextMenu(content_position, url, target, modifiers, bitmap->to_shareable_bitmap()));
|
m_client.post_message(Messages::WebContentClient::DidRequestImageContextMenu(content_position, url, target, modifiers, bitmap->to_shareable_bitmap()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String PageHost::page_did_request_cookie(const URL& url)
|
||||||
|
{
|
||||||
|
return m_client.send_sync<Messages::WebContentClient::DidRequestCookie>(url)->cookie();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PageHost::page_did_set_cookie(const URL& url, const String& cookie)
|
||||||
|
{
|
||||||
|
m_client.post_message(Messages::WebContentClient::DidSetCookie(url, cookie));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,8 @@ private:
|
||||||
virtual String page_did_request_prompt(const String&, const String&) override;
|
virtual String page_did_request_prompt(const String&, const String&) override;
|
||||||
virtual void page_did_change_favicon(const Gfx::Bitmap&) override;
|
virtual void page_did_change_favicon(const Gfx::Bitmap&) override;
|
||||||
virtual void page_did_request_image_context_menu(const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers, const Gfx::Bitmap*) override;
|
virtual void page_did_request_image_context_menu(const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers, const Gfx::Bitmap*) override;
|
||||||
|
virtual String page_did_request_cookie(const URL&) override;
|
||||||
|
virtual void page_did_set_cookie(const URL&, const String&) override;
|
||||||
|
|
||||||
explicit PageHost(ClientConnection&);
|
explicit PageHost(ClientConnection&);
|
||||||
|
|
||||||
|
|
|
@ -25,4 +25,6 @@ endpoint WebContentClient = 90
|
||||||
DidGetSource(URL url, String source) =|
|
DidGetSource(URL url, String source) =|
|
||||||
DidJSConsoleOutput(String method, String line) =|
|
DidJSConsoleOutput(String method, String line) =|
|
||||||
DidChangeFavicon(Gfx::ShareableBitmap favicon) =|
|
DidChangeFavicon(Gfx::ShareableBitmap favicon) =|
|
||||||
|
DidRequestCookie(URL url) => (String cookie)
|
||||||
|
DidSetCookie(URL url, String cookie) =|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue