forked from crosswalk-project/chromium-crosswalk
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix restoration of session after a crash.
Disable sending kTabModelNewTabWillOpenNotification notification when the TabModel is restoring a session as this breaks the BVC state that does not expect the notification to be sent when a tab is added due to session restoration. This is a reland of http://crrev.com/c/664557 that fixes EG tests by correctly initialising TabModelNotificationObserver (should not be disabled except during the restoration of the session). This CL also improves on the original CL by using a scoped closure runner to re-enable TabModelNotificationObserver to protect against early returns in -restoreSessionWindow:persistState:. Bug: 763964 Change-Id: Ie950ac3f35b13566abcc1ca6eae774512ed7a16a Reviewed-on: https://chromium-review.googlesource.com/665238 Reviewed-by: Rohit Rao (ping after 24h) <[email protected]> Commit-Queue: Sylvain Defresne <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#501944}(cherry picked from commit e8ae6ad) Reviewed-on: https://chromium-review.googlesource.com/674983 Reviewed-by: Sylvain Defresne <[email protected]> Cr-Commit-Position: refs/branch-heads/3202@{crosswalk-project#353} Cr-Branched-From: fa6a5d8-refs/heads/master@{#499098}
- Loading branch information
Showing
6 changed files
with
116 additions
and
26 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
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
34 changes: 34 additions & 0 deletions
34
ios/chrome/browser/tabs/tab_model_web_usage_enabled_observer.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef IOS_CHROME_BROWSER_TABS_TAB_MODEL_WEB_USAGE_ENABLED_OBSERVER_H_ | ||
#define IOS_CHROME_BROWSER_TABS_TAB_MODEL_WEB_USAGE_ENABLED_OBSERVER_H_ | ||
|
||
#include "base/macros.h" | ||
#import "ios/chrome/browser/web_state_list/web_state_list_observer.h" | ||
|
||
@class TabModel; | ||
|
||
class TabModelWebUsageEnabledObserver : public WebStateListObserver { | ||
public: | ||
explicit TabModelWebUsageEnabledObserver(TabModel* tab_model); | ||
~TabModelWebUsageEnabledObserver() override; | ||
|
||
// WebStateListObserver implementation. | ||
void WebStateInsertedAt(WebStateList* web_state_list, | ||
web::WebState* web_state, | ||
int index, | ||
bool activating) override; | ||
void WebStateReplacedAt(WebStateList* web_state_list, | ||
web::WebState* old_web_state, | ||
web::WebState* new_web_state, | ||
int index) override; | ||
|
||
private: | ||
__weak TabModel* tab_model_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(TabModelWebUsageEnabledObserver); | ||
}; | ||
|
||
#endif // IOS_CHROME_BROWSER_TABS_TAB_MODEL_WEB_USAGE_ENABLED_OBSERVER_H_ |
46 changes: 46 additions & 0 deletions
46
ios/chrome/browser/tabs/tab_model_web_usage_enabled_observer.mm
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,46 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import "ios/chrome/browser/tabs/tab_model_web_usage_enabled_observer.h" | ||
|
||
#import "ios/chrome/browser/tabs/tab_model.h" | ||
#import "ios/web/public/web_state/web_state.h" | ||
|
||
#if !defined(__has_feature) || !__has_feature(objc_arc) | ||
#error "This file requires ARC support." | ||
#endif | ||
|
||
namespace { | ||
|
||
// Sets |web_state| web usage enabled property and starts loading the content | ||
// if necessary. | ||
void SetWebUsageEnabled(web::WebState* web_state, bool web_usage_enabled) { | ||
web_state->SetWebUsageEnabled(web_usage_enabled); | ||
if (web_usage_enabled) | ||
web_state->GetNavigationManager()->LoadIfNecessary(); | ||
} | ||
|
||
} // namespace | ||
|
||
TabModelWebUsageEnabledObserver::TabModelWebUsageEnabledObserver( | ||
TabModel* tab_model) | ||
: tab_model_(tab_model) {} | ||
|
||
TabModelWebUsageEnabledObserver::~TabModelWebUsageEnabledObserver() = default; | ||
|
||
void TabModelWebUsageEnabledObserver::WebStateInsertedAt( | ||
WebStateList* web_state_list, | ||
web::WebState* web_state, | ||
int index, | ||
bool activating) { | ||
SetWebUsageEnabled(web_state, tab_model_.webUsageEnabled); | ||
} | ||
|
||
void TabModelWebUsageEnabledObserver::WebStateReplacedAt( | ||
WebStateList* web_state_list, | ||
web::WebState* old_web_state, | ||
web::WebState* new_web_state, | ||
int index) { | ||
SetWebUsageEnabled(new_web_state, tab_model_.webUsageEnabled); | ||
} |