Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1680)

Unified Diff: content/browser/screen_orientation/screen_orientation.cc

Issue 2630323002: [ScreenOrientation] Fix a possible crash point in ScreenOrientationProvider. (Closed)
Patch Set: ScreenOrientation does not maintain pending lock request Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/screen_orientation/screen_orientation.cc
diff --git a/content/browser/screen_orientation/screen_orientation.cc b/content/browser/screen_orientation/screen_orientation.cc
index a7e0ad9462a8310f94922710bda4fd7a107c6c62..98daf1cbadd8f233bcfe56a1098af330317a819d 100644
--- a/content/browser/screen_orientation/screen_orientation.cc
+++ b/content/browser/screen_orientation/screen_orientation.cc
@@ -4,16 +4,12 @@
#include "content/browser/screen_orientation/screen_orientation.h"
-#include "base/bind.h"
-#include "base/callback_helpers.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/screen_orientation_provider.h"
#include "content/public/browser/web_contents.h"
namespace content {
-using LockResult = device::mojom::ScreenOrientationLockResult;
-
ScreenOrientation::ScreenOrientation(WebContents* web_contents)
: WebContentsObserver(web_contents),
bindings_(web_contents, this),
@@ -26,21 +22,10 @@ ScreenOrientation::~ScreenOrientation() = default;
void ScreenOrientation::LockOrientation(
blink::WebScreenOrientationLockType orientation,
const LockOrientationCallback& callback) {
- if (!on_result_callback_.is_null()) {
- NotifyLockResult(LockResult::SCREEN_ORIENTATION_LOCK_RESULT_ERROR_CANCELED);
- }
-
- on_result_callback_ = callback;
-
- provider_->LockOrientation(
- orientation,
- base::Bind(&ScreenOrientation::NotifyLockResult, base::Unretained(this)));
+ provider_->LockOrientation(orientation, callback);
}
void ScreenOrientation::UnlockOrientation() {
- // Cancel any pending lock request.
- NotifyLockResult(LockResult::SCREEN_ORIENTATION_LOCK_RESULT_ERROR_CANCELED);
-
provider_->UnlockOrientation();
}
@@ -52,13 +37,6 @@ void ScreenOrientation::DidNavigateMainFrame(
provider_->UnlockOrientation();
}
-void ScreenOrientation::NotifyLockResult(LockResult result) {
- if (on_result_callback_.is_null())
- return;
-
- base::ResetAndReturn(&on_result_callback_).Run(result);
-}
-
ScreenOrientationProvider* ScreenOrientation::GetScreenOrientationProvider() {
return provider_.get();
}

Powered by Google App Engine
This is Rietveld 408576698