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

Side by Side Diff: chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_model.cc

Issue 2852883002: Settings reset prompt: Fix crash when fetching default settings. (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prom pt_model.h" 5 #include "chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prom pt_model.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // For non Google Chrome builds and cases with an empty |brandcode|, we create 129 // For non Google Chrome builds and cases with an empty |brandcode|, we create
130 // a default-constructed |BrandcodedDefaultSettings| object and post the 130 // a default-constructed |BrandcodedDefaultSettings| object and post the
131 // callback immediately. 131 // callback immediately.
132 PostCallbackAndDeleteSelf(base::MakeUnique<BrandcodedDefaultSettings>()); 132 PostCallbackAndDeleteSelf(base::MakeUnique<BrandcodedDefaultSettings>());
133 } 133 }
134 134
135 void DefaultSettingsFetcher::OnSettingsFetched() { 135 void DefaultSettingsFetcher::OnSettingsFetched() {
136 DCHECK(config_fetcher_); 136 DCHECK(config_fetcher_);
137 DCHECK(!config_fetcher_->IsActive()); 137 DCHECK(!config_fetcher_->IsActive());
138 138
139 PostCallbackAndDeleteSelf(config_fetcher_->GetSettings()); 139 std::unique_ptr<BrandcodedDefaultSettings> settings(
140 config_fetcher_->GetSettings());
141 // Use default settings if fetching of BrandcodedDefaultSettings fails.
142 if (!settings)
143 settings.reset(new BrandcodedDefaultSettings());
144
145 PostCallbackAndDeleteSelf(std::move(settings));
140 } 146 }
141 147
142 void DefaultSettingsFetcher::PostCallbackAndDeleteSelf( 148 void DefaultSettingsFetcher::PostCallbackAndDeleteSelf(
143 std::unique_ptr<BrandcodedDefaultSettings> default_settings) { 149 std::unique_ptr<BrandcodedDefaultSettings> default_settings) {
144 DCHECK(default_settings); 150 DCHECK(default_settings);
145 content::BrowserThread::PostTask( 151 content::BrowserThread::PostTask(
146 content::BrowserThread::UI, FROM_HERE, 152 content::BrowserThread::UI, FROM_HERE,
147 base::BindOnce(std::move(callback_), base::Passed(&default_settings))); 153 base::BindOnce(std::move(callback_), base::Passed(&default_settings)));
148 delete this; 154 delete this;
149 } 155 }
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 GetExtension(profile_, extension_id); 559 GetExtension(profile_, extension_id);
554 if (extension && management_policy->MustRemainEnabled(extension, nullptr)) 560 if (extension && management_policy->MustRemainEnabled(extension, nullptr))
555 return true; 561 return true;
556 } 562 }
557 } 563 }
558 564
559 return false; 565 return false;
560 } 566 }
561 567
562 } // namespace safe_browsing. 568 } // namespace safe_browsing.
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698