-
Notifications
You must be signed in to change notification settings - Fork 871
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 1985: Properly show the widevine absence prompt.
Fixes brave/brave-browser#1985 Replacing a set of hardcoded urls with a blink hook and a corresponding tab helper that updates the widevine content settings icon.
- Loading branch information
Showing
15 changed files
with
256 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/brave_drm_tab_helper.h" | ||
|
||
#include "brave/common/pref_names.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/browser/profiles/profile_manager.h" | ||
#include "chrome/browser/ui/browser_finder.h" | ||
#include "chrome/browser/ui/browser_window.h" | ||
#include "components/prefs/pref_service.h" | ||
#include "content/public/browser/navigation_handle.h" | ||
|
||
BraveDrmTabHelper::BraveDrmTabHelper(content::WebContents* contents) | ||
: WebContentsObserver(contents), bindings_(contents, this) {} | ||
|
||
BraveDrmTabHelper::~BraveDrmTabHelper() {} | ||
|
||
bool BraveDrmTabHelper::ShouldShowWidevineOptIn() const { | ||
// If the user already opted in, don't offer it. | ||
PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); | ||
if (prefs->GetBoolean(kWidevineOptedIn)) { | ||
return false; | ||
} | ||
|
||
return is_widevine_requested_; | ||
} | ||
|
||
void BraveDrmTabHelper::DidStartNavigation( | ||
content::NavigationHandle* navigation_handle) { | ||
if (!navigation_handle->IsInMainFrame() || | ||
navigation_handle->IsSameDocument()) { | ||
return; | ||
} | ||
is_widevine_requested_ = false; | ||
} | ||
|
||
void BraveDrmTabHelper::OnWidevineKeySystemAccessRequest() { | ||
is_widevine_requested_ = true; | ||
|
||
Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); | ||
browser->window()->UpdateToolbar(web_contents()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_DRM_TAB_HELPER_H_ | ||
#define BRAVE_BROWSER_DRM_TAB_HELPER_H_ | ||
|
||
#include "content/public/browser/web_contents_binding_set.h" | ||
#include "content/public/browser/web_contents_observer.h" | ||
#include "content/public/browser/web_contents_user_data.h" | ||
#include "third_party/blink/public/platform/brave_drm.mojom.h" | ||
|
||
// Reacts to DRM content detected on the renderer side. | ||
class BraveDrmTabHelper final | ||
: public content::WebContentsObserver, | ||
public content::WebContentsUserData<BraveDrmTabHelper>, | ||
public blink::mojom::BraveDRM { | ||
public: | ||
BraveDrmTabHelper(content::WebContents* contents); | ||
~BraveDrmTabHelper() override; | ||
|
||
bool ShouldShowWidevineOptIn() const; | ||
|
||
// content::WebContentsObserver | ||
void DidStartNavigation( | ||
content::NavigationHandle* navigation_handle) override; | ||
|
||
// blink::mojom::BraveDRM | ||
void OnWidevineKeySystemAccessRequest() override; | ||
|
||
private: | ||
content::WebContentsFrameBindingSet<blink::mojom::BraveDRM> bindings_; | ||
|
||
// True if we are notified that a page requested widevine availability. | ||
bool is_widevine_requested_ = false; | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_DRM_TAB_HELPER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.