Skip to content

Commit

Permalink
fix: return true to process downloading by CefViewCore
Browse files Browse the repository at this point in the history
  • Loading branch information
tishion committed Dec 1, 2024
1 parent 0aa55c8 commit a6a6d62
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 37 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/build-linux-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ on:
push:
branches: [main]
paths:
- '.github/workflows/build-linux-x86_64.yml'
- 'CMakeLists.txt'
- 'CefConfig.cmake'
- 'include/**'
- 'src/**'
- ".github/workflows/build-linux-x86_64.yml"
- "CMakeLists.txt"
- "CefConfig.cmake"
- "include/**"
- "src/**"

pull_request:
branches: [main]
paths:
- 'CMakeLists.txt'
- 'CefConfig.cmake'
- 'include/**'
- 'src/**'
- "CMakeLists.txt"
- "CefConfig.cmake"
- "include/**"
- "src/**"

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Checkout Source
uses: actions/checkout@v2
with:
submodules: 'true'
submodules: "true"

- name: Cache CEF folders
uses: actions/cache@v3
Expand All @@ -49,4 +49,4 @@ jobs:

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
22 changes: 11 additions & 11 deletions .github/workflows/build-macos-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ on:
push:
branches: [main]
paths:
- '.github/workflows/build-macos-x86_64.yml'
- 'CMakeLists.txt'
- 'CefConfig.cmake'
- 'include/**'
- 'src/**'
- ".github/workflows/build-macos-x86_64.yml"
- "CMakeLists.txt"
- "CefConfig.cmake"
- "include/**"
- "src/**"

pull_request:
branches: [main]
paths:
- 'CMakeLists.txt'
- 'CefConfig.cmake'
- 'include/**'
- 'src/**'
- "CMakeLists.txt"
- "CefConfig.cmake"
- "include/**"
- "src/**"

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
Expand All @@ -34,7 +34,7 @@ jobs:
- name: Checkout Source
uses: actions/checkout@v2
with:
submodules: 'true'
submodules: "true"

- name: Cache CEF folders
uses: actions/cache@v3
Expand All @@ -45,7 +45,7 @@ jobs:
- name: Setup Xcode version
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '14'
xcode-version: "15"

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/build-windows-x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ on:
push:
branches: [main]
paths:
- '.github/workflows/build-windows-x86_64.yml'
- 'CMakeLists.txt'
- 'CefConfig.cmake'
- 'include/**'
- 'src/**'
- ".github/workflows/build-windows-x86_64.yml"
- "CMakeLists.txt"
- "CefConfig.cmake"
- "include/**"
- "src/**"

pull_request:
branches: [main]
paths:
- 'CMakeLists.txt'
- 'CefConfig.cmake'
- 'include/**'
- 'src/**'
- "CMakeLists.txt"
- "CefConfig.cmake"
- "include/**"
- "src/**"

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
Expand All @@ -34,19 +34,19 @@ jobs:
- name: Checkout Source
uses: actions/checkout@v2
with:
submodules: 'true'
submodules: "true"

- name: Cache CEF folders
uses: actions/cache@v3
with:
path: ${{github.workspace}}/dep
key: ${{ runner.os }}-dep-cef

- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -A x64 -DPROJECT_ARCH=x86_64 -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
20 changes: 17 additions & 3 deletions src/CefView/CefBrowserApp/CefViewBrowserClient_DownloadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,18 @@ CefViewBrowserClient::OnBeforeDownload(CefRefPtr<CefBrowser> browser,
CEF_REQUIRE_UI_THREAD();

auto delegate = client_delegate_.lock();
if (delegate)
if (delegate) {
delegate->onBeforeDownload(browser, download_item, suggested_name, callback);
} else {
// no delegate, just allow this download and then cancel it in OnDownloadUpdated
if (callback) {
callback->Continue("", false);
}
}

return false;
/// Return true and execute |callback| either asynchronously or in this method to continue or cancel the download.
/// Return false to proceed with default handling (cancel with Alloy style, download shelf with Chrome style)
return true;
}
#endif

Expand All @@ -52,6 +60,12 @@ CefViewBrowserClient::OnDownloadUpdated(CefRefPtr<CefBrowser> browser,
CEF_REQUIRE_UI_THREAD();

auto delegate = client_delegate_.lock();
if (delegate)
if (delegate) {
delegate->onDownloadUpdated(browser, download_item, callback);
} else {
// no delegate, just cancel this downloading
if (callback) {
callback->Cancel();
}
}
}

0 comments on commit a6a6d62

Please sign in to comment.