Commit 8756f413 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Document Browser::tab_strip_model() is never nullptr.

Delete code that assume it can be.

Change-Id: I2e2344d4c04ff957cf403698bdfa17bffdd602b6
Reviewed-on: https://chromium-review.googlesource.com/c/1457431Reviewed-by: default avatarcalamity <calamity@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630172}
parent 6ad99c65
...@@ -759,7 +759,7 @@ bool ExtensionTabUtil::OpenOptionsPage(const Extension* extension, ...@@ -759,7 +759,7 @@ bool ExtensionTabUtil::OpenOptionsPage(const Extension* extension,
// static // static
bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) { bool ExtensionTabUtil::BrowserSupportsTabs(Browser* browser) {
return browser && browser->tab_strip_model() && !browser->is_devtools(); return browser && !browser->is_devtools();
} }
} // namespace extensions } // namespace extensions
...@@ -386,8 +386,9 @@ Browser::Browser(const CreateParams& params) ...@@ -386,8 +386,9 @@ Browser::Browser(const CreateParams& params)
: extension_registry_observer_(this), : extension_registry_observer_(this),
type_(params.type), type_(params.type),
profile_(params.profile), profile_(params.profile),
window_(NULL), window_(nullptr),
tab_strip_model_delegate_(new chrome::BrowserTabStripModelDelegate(this)), tab_strip_model_delegate_(
std::make_unique<chrome::BrowserTabStripModelDelegate>(this)),
tab_strip_model_( tab_strip_model_(
std::make_unique<TabStripModel>(tab_strip_model_delegate_.get(), std::make_unique<TabStripModel>(tab_strip_model_delegate_.get(),
params.profile)), params.profile)),
......
...@@ -284,7 +284,10 @@ class Browser : public TabStripModelObserver, ...@@ -284,7 +284,10 @@ class Browser : public TabStripModelObserver,
location_bar_model->swap(location_bar_model_); location_bar_model->swap(location_bar_model_);
} }
#endif #endif
// Never nullptr.
TabStripModel* tab_strip_model() const { return tab_strip_model_.get(); } TabStripModel* tab_strip_model() const { return tab_strip_model_.get(); }
chrome::BrowserCommandController* command_controller() { chrome::BrowserCommandController* command_controller() {
return command_controller_.get(); return command_controller_.get();
} }
...@@ -966,8 +969,8 @@ class Browser : public TabStripModelObserver, ...@@ -966,8 +969,8 @@ class Browser : public TabStripModelObserver,
// This Browser's window. // This Browser's window.
BrowserWindow* window_; BrowserWindow* window_;
std::unique_ptr<TabStripModelDelegate> tab_strip_model_delegate_; std::unique_ptr<TabStripModelDelegate> const tab_strip_model_delegate_;
std::unique_ptr<TabStripModel> tab_strip_model_; std::unique_ptr<TabStripModel> const tab_strip_model_;
// The application name that is also the name of the window to the shell. // The application name that is also the name of the window to the shell.
// This name should be set when: // This name should be set when:
......
...@@ -118,8 +118,6 @@ base::string16 GetUpgradeDialogMenuItemName() { ...@@ -118,8 +118,6 @@ base::string16 GetUpgradeDialogMenuItemName() {
// Returns the appropriate menu label for the IDC_INSTALL_PWA command if // Returns the appropriate menu label for the IDC_INSTALL_PWA command if
// available. // available.
base::Optional<base::string16> GetInstallPWAAppMenuItemName(Browser* browser) { base::Optional<base::string16> GetInstallPWAAppMenuItemName(Browser* browser) {
if (!browser->tab_strip_model())
return base::nullopt;
WebContents* web_contents = WebContents* web_contents =
browser->tab_strip_model()->GetActiveWebContents(); browser->tab_strip_model()->GetActiveWebContents();
if (!web_contents) if (!web_contents)
...@@ -891,14 +889,11 @@ void AppMenuModel::CreateZoomMenu() { ...@@ -891,14 +889,11 @@ void AppMenuModel::CreateZoomMenu() {
} }
void AppMenuModel::UpdateZoomControls() { void AppMenuModel::UpdateZoomControls() {
int zoom_percent = 100; WebContents* contents = browser_->tab_strip_model()->GetActiveWebContents();
if (browser_->tab_strip_model() && zoom_label_ = base::FormatPercent(
browser_->tab_strip_model()->GetActiveWebContents()) { contents
zoom_percent = zoom::ZoomController::FromWebContents( ? zoom::ZoomController::FromWebContents(contents)->GetZoomPercent()
browser_->tab_strip_model()->GetActiveWebContents()) : 100);
->GetZoomPercent();
}
zoom_label_ = base::FormatPercent(zoom_percent);
} }
bool AppMenuModel::ShouldShowNewIncognitoWindowMenuItem() { bool AppMenuModel::ShouldShowNewIncognitoWindowMenuItem() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment