Skip to content

Commit 8da1cbc

Browse files
committed
Add button to properties to refresh the current page's cache
Also fixed some spaces that were supposed to be tabs
1 parent 35be41d commit 8da1cbc

File tree

7 files changed

+47
-17
lines changed

7 files changed

+47
-17
lines changed

obs-browser/browser-manager-base.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ void BrowserManager::ExecuteSceneChangeJSCallback(const char *name)
8585
pimpl->ExecuteSceneChangeJSCallback(name);
8686
}
8787

88+
void BrowserManager::RefreshPageNoCache(int browserIdentifier)
89+
{
90+
pimpl->RefreshPageNoCache(browserIdentifier);
91+
}
92+
8893
BrowserManager::Impl::Impl()
8994
{
9095
os_event_init(&dispatchEvent, OS_EVENT_TYPE_AUTO);
@@ -322,6 +327,14 @@ void BrowserManager::Impl::ExecuteSceneChangeJSCallback(const char *name)
322327
});
323328
}
324329

330+
void BrowserManager::Impl::RefreshPageNoCache(int browserIdentifier)
331+
{
332+
ExecuteOnBrowser(browserIdentifier, [&](CefRefPtr<CefBrowser> b)
333+
{
334+
b->ReloadIgnoreCache();
335+
});
336+
}
337+
325338
void
326339
BrowserManager::Impl::Startup()
327340
{

obs-browser/browser-manager-base.hpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ class BrowserManager::Impl
3636
void DestroyBrowser(int browserIdentifier);
3737
void TickBrowser(int browserIdentifier);
3838

39-
void SendMouseClick(int browserIdentifier,
40-
const struct obs_mouse_event *event, int32_t type,
41-
bool mouse_up, uint32_t click_count);
42-
void SendMouseMove(int browserIdentifier,
43-
const struct obs_mouse_event *event, bool mouseLeave);
44-
void SendMouseWheel(int browserIdentifier,
45-
const struct obs_mouse_event *event, int xDelta,
46-
int yDelta);
47-
void SendFocus(int browserIdentifier, bool focus);
48-
void SendKeyClick(int browserIdentifier,
49-
const struct obs_key_event *event, bool keyUp);
39+
void SendMouseClick(int browserIdentifier,
40+
const struct obs_mouse_event *event, int32_t type,
41+
bool mouse_up, uint32_t click_count);
42+
void SendMouseMove(int browserIdentifier,
43+
const struct obs_mouse_event *event, bool mouseLeave);
44+
void SendMouseWheel(int browserIdentifier,
45+
const struct obs_mouse_event *event, int xDelta,
46+
int yDelta);
47+
void SendFocus(int browserIdentifier, bool focus);
48+
void SendKeyClick(int browserIdentifier,
49+
const struct obs_key_event *event, bool keyUp);
5050

5151
void AddListener(const int browserIdentifier,
5252
std::shared_ptr<BrowserListener> browserListener);
@@ -58,6 +58,8 @@ class BrowserManager::Impl
5858

5959
void ExecuteSceneChangeJSCallback(const char *name);
6060

61+
void RefreshPageNoCache(int browserIdentifier);
62+
6163
private:
6264
void ExecuteOnBrowser(int browserIdentifier,
6365
std::function<void(CefRefPtr<CefBrowser>)> f,

obs-browser/main-source.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,17 @@ static bool restart_button_clicked(obs_properties_t *props,
4242
BrowserManager::Instance()->Restart();
4343
return true;
4444
}
45+
46+
static bool refreshnocache_button_clicked(obs_properties_t *props,
47+
obs_property_t *property, void *data)
48+
{
49+
BrowserSource *bs = static_cast<BrowserSource *>(data);
50+
51+
BrowserManager::Instance()->RefreshPageNoCache(bs->GetBrowserIdentifier());
52+
53+
return true;
54+
}
55+
4556
static bool is_local_file_modified(obs_properties_t *props,
4657
obs_property_t *prop, obs_data_t *settings)
4758
{
@@ -97,6 +108,8 @@ static obs_properties_t *browser_source_get_properties(void *data)
97108
obs_properties_add_bool(props, "shutdown",
98109
obs_module_text("Shutdown when not active"));
99110

111+
obs_properties_add_button(props, "refreshnocache",
112+
obs_module_text("Refresh cache of current page"), refreshnocache_button_clicked);
100113

101114
#ifdef __APPLE__
102115
// osx is the only process-isolated cef impl

obs-browser/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static void handle_obs_frontend_event(enum obs_frontend_event event, void *)
4343

4444
bool obs_module_load(void)
4545
{
46-
blog(LOG_INFO, "[browser_source: 'Version: %s']", OBS_BROWSER_VERSION);
46+
blog(LOG_INFO, "[browser_source: 'Version: %s']", OBS_BROWSER_VERSION);
4747

4848
browser_source_info = create_browser_source_info();
4949

shared/browser-app.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class BrowserApp : public CefApp,
4747
private:
4848
virtual void ExecuteJSFunction(CefRefPtr<CefBrowser> browser,
4949
const char *functionName,
50-
CefV8ValueList arguments);
50+
CefV8ValueList arguments);
5151

5252
IMPLEMENT_REFCOUNTING(BrowserApp);
5353

shared/browser-manager.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ class BrowserManager {
6060
const char *GetModulePath() { return path; }
6161

6262
void ExecuteVisiblityJSCallback(int browserIdentifier, bool visible);
63-
64-
void ExecuteSceneChangeJSCallback(const char *name);
63+
64+
void ExecuteSceneChangeJSCallback(const char *name);
65+
66+
void RefreshPageNoCache(int browserIdentifier);
6567

6668
private:
6769
class Impl;

shared/browser-scheme.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ bool BrowserSchemeHandler::ProcessRequest(CefRefPtr<CefRequest> request,
3737

3838
path = CefURIDecode(path, true, cef_uri_unescape_rule_t::UU_SPACES);
3939
path = CefURIDecode(path, true, cef_uri_unescape_rule_t::UU_URL_SPECIAL_CHARS_EXCEPT_PATH_SEPARATORS);
40-
40+
4141
#ifdef WIN32
4242
//blog(LOG_INFO, "%s", path.erase(0,1));
43-
inputStream.open(nowide::widen(path.erase(0,1)), std::ifstream::binary);
43+
inputStream.open(nowide::widen(path.erase(0,1)), std::ifstream::binary);
4444
#else
4545
inputStream.open(path, std::ifstream::binary);
4646
#endif

0 commit comments

Comments
 (0)