Skip to content

Commit

Permalink
API addition to set a cookie for a given URL.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vicken Simonian committed Jun 12, 2012
1 parent 4fb5458 commit c11cef7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions include/berkelium/Berkelium.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion src/Berkelium.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
7 changes: 7 additions & 0 deletions src/Root.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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>()));
}

}
2 changes: 2 additions & 0 deletions src/Root.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 c11cef7

Please sign in to comment.