Skip to content
Browse files

Merge pull request #16 from vsimon/cookies

API addition to set a cookie for a given URL.
  • Loading branch information...
2 parents 4fb5458 + c11cef7 commit 884410591b1b62fdf982b98699486b5706fe72d1 @ewencp ewencp committed Jun 13, 2012
Showing with 17 additions and 1 deletion.
  1. +5 −0 include/berkelium/Berkelium.hpp
  2. +3 −1 src/Berkelium.cpp
  3. +7 −0 src/Root.cpp
  4. +2 −0 src/Root.hpp
View
5 include/berkelium/Berkelium.hpp
@@ -105,6 +105,11 @@ void BERKELIUM_EXPORT update();
void BERKELIUM_EXPORT runUntilStopped();
void BERKELIUM_EXPORT stopRunning();
+/** Sets a cookie for a given URL.
+ * \param url The URL to set the cookie on.
+ * \param cookieString The cookie string.
+ */
+void BERKELIUM_EXPORT setCookie (URLString url, WideString cookieString);
}
#endif
View
4 src/Berkelium.cpp
@@ -72,5 +72,7 @@ void stopRunning() {
void setErrorHandler (ErrorDelegate *errorHandler) {
Root::getSingleton().setErrorHandler(errorHandler);
}
-
+void setCookie (URLString url, WideString cookieString) {
+ Root::getSingleton().setCookie(url, cookieString);
+}
}
View
7 src/Root.cpp
@@ -100,6 +100,8 @@
#include <iostream>
#include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h"
+#include "chrome/common/net/url_request_context_getter.h"
+#include "base/utf_string_conversions.h"
#if !defined(OS_WIN)
extern "C"
@@ -613,5 +615,10 @@ Root::~Root(){
mTempProfileDir.reset(); // Delete the profile if necessary.
}
+void Root::setCookie (URLString url, WideString cookieString) {
+ if (getDefaultRequestContext() )
+ if (net::CookieStore * cs = getDefaultRequestContext () -> GetCookieStore ())
+ cs -> SetCookie (GURL(url.get<std::string>()), WideToUTF8(cookieString.get<std::wstring>()));
+}
}
View
2 src/Root.hpp
@@ -123,6 +123,8 @@ class Root : public Singleton<Root> {
void addWindow(WindowImpl* w);
void removeWindow(WindowImpl* w);
WindowList getWindows();
+
+ void setCookie (URLString url, WideString cookieString);
};
}

0 comments on commit 8844105

Please sign in to comment.
Something went wrong with that request. Please try again.