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

Side by Side Diff: chrome/browser/ui/startup/default_browser_prompt.cc

Issue 1657933003: Fixes the interactive default browser UX for policy setting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix merge issue Created 4 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/startup/default_browser_prompt.h" 5 #include "chrome/browser/ui/startup/default_browser_prompt.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 return shell_integration::IsElevationNeededForSettingDefaultProtocolClient(); 169 return shell_integration::IsElevationNeededForSettingDefaultProtocolClient();
170 } 170 }
171 171
172 bool DefaultBrowserInfoBarDelegate::Accept() { 172 bool DefaultBrowserInfoBarDelegate::Accept() {
173 action_taken_ = true; 173 action_taken_ = true;
174 content::RecordAction( 174 content::RecordAction(
175 base::UserMetricsAction("DefaultBrowserInfoBar_Accept")); 175 base::UserMetricsAction("DefaultBrowserInfoBar_Accept"));
176 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction", 176 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction",
177 InfoBarUserInteraction::START_SET_AS_DEFAULT, 177 InfoBarUserInteraction::START_SET_AS_DEFAULT,
178 NUM_INFO_BAR_USER_INTERACTION_TYPES); 178 NUM_INFO_BAR_USER_INTERACTION_TYPES);
179 // The worker pointer is reference counted. While it is running, the
180 // message loops of the FILE and UI thread will hold references to it
181 // and it will be automatically freed once all its tasks have finished.
179 scoped_refptr<shell_integration::DefaultBrowserWorker>( 182 scoped_refptr<shell_integration::DefaultBrowserWorker>(
180 new shell_integration::DefaultBrowserWorker(nullptr)) 183 new shell_integration::DefaultBrowserWorker(nullptr,
184 /*delete_observer=*/false))
181 ->StartSetAsDefault(); 185 ->StartSetAsDefault();
182 return true; 186 return true;
183 } 187 }
184 188
185 bool DefaultBrowserInfoBarDelegate::Cancel() { 189 bool DefaultBrowserInfoBarDelegate::Cancel() {
186 action_taken_ = true; 190 action_taken_ = true;
187 content::RecordAction( 191 content::RecordAction(
188 base::UserMetricsAction("DefaultBrowserInfoBar_DontAskAgain")); 192 base::UserMetricsAction("DefaultBrowserInfoBar_DontAskAgain"));
189 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction", 193 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction",
190 InfoBarUserInteraction::DONT_ASK_AGAIN, 194 InfoBarUserInteraction::DONT_ASK_AGAIN,
(...skipping 10 matching lines...) Expand all
201 class CheckDefaultBrowserObserver 205 class CheckDefaultBrowserObserver
202 : public shell_integration::DefaultWebClientObserver { 206 : public shell_integration::DefaultWebClientObserver {
203 public: 207 public:
204 CheckDefaultBrowserObserver(const base::FilePath& profile_path, 208 CheckDefaultBrowserObserver(const base::FilePath& profile_path,
205 bool show_prompt); 209 bool show_prompt);
206 ~CheckDefaultBrowserObserver() override; 210 ~CheckDefaultBrowserObserver() override;
207 211
208 private: 212 private:
209 void SetDefaultWebClientUIState( 213 void SetDefaultWebClientUIState(
210 shell_integration::DefaultWebClientUIState state) override; 214 shell_integration::DefaultWebClientUIState state) override;
211 bool IsOwnedByWorker() override;
212 215
213 void ResetCheckDefaultBrowserPref(); 216 void ResetCheckDefaultBrowserPref();
214 void ShowPrompt(); 217 void ShowPrompt();
215 218
216 // The path to the profile for which the prompt is to be shown. 219 // The path to the profile for which the prompt is to be shown.
217 base::FilePath profile_path_; 220 base::FilePath profile_path_;
218 221
219 // True if the prompt is to be shown if Chrome is not the default browser. 222 // True if the prompt is to be shown if Chrome is not the default browser.
220 bool show_prompt_; 223 bool show_prompt_;
221 224
(...skipping 13 matching lines...) Expand all
235 // Notify the user in the future if Chrome ceases to be the user's chosen 238 // Notify the user in the future if Chrome ceases to be the user's chosen
236 // default browser. 239 // default browser.
237 ResetCheckDefaultBrowserPref(); 240 ResetCheckDefaultBrowserPref();
238 } else if (show_prompt_ && state == shell_integration::STATE_NOT_DEFAULT && 241 } else if (show_prompt_ && state == shell_integration::STATE_NOT_DEFAULT &&
239 shell_integration::CanSetAsDefaultBrowser() != 242 shell_integration::CanSetAsDefaultBrowser() !=
240 shell_integration::SET_DEFAULT_NOT_ALLOWED) { 243 shell_integration::SET_DEFAULT_NOT_ALLOWED) {
241 ShowPrompt(); 244 ShowPrompt();
242 } 245 }
243 } 246 }
244 247
245 bool CheckDefaultBrowserObserver::IsOwnedByWorker() {
246 // Instruct the DefaultBrowserWorker to delete this instance when it is done.
247 return true;
248 }
249
250 void CheckDefaultBrowserObserver::ResetCheckDefaultBrowserPref() { 248 void CheckDefaultBrowserObserver::ResetCheckDefaultBrowserPref() {
251 Profile* profile = 249 Profile* profile =
252 g_browser_process->profile_manager()->GetProfileByPath(profile_path_); 250 g_browser_process->profile_manager()->GetProfileByPath(profile_path_);
253 if (profile) 251 if (profile)
254 profile->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, true); 252 profile->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, true);
255 } 253 }
256 254
257 void CheckDefaultBrowserObserver::ShowPrompt() { 255 void CheckDefaultBrowserObserver::ShowPrompt() {
258 Browser* browser = chrome::FindLastActive(); 256 Browser* browser = chrome::FindLastActive();
259 if (!browser) 257 if (!browser)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 const Version disable_version(disable_version_string); 308 const Version disable_version(disable_version_string);
311 DCHECK(disable_version_string.empty() || disable_version.IsValid()); 309 DCHECK(disable_version_string.empty() || disable_version.IsValid());
312 if (disable_version.IsValid() && 310 if (disable_version.IsValid() &&
313 disable_version == Version(version_info::GetVersionNumber())) { 311 disable_version == Version(version_info::GetVersionNumber())) {
314 show_prompt = false; 312 show_prompt = false;
315 } 313 }
316 } 314 }
317 315
318 scoped_refptr<shell_integration::DefaultBrowserWorker>( 316 scoped_refptr<shell_integration::DefaultBrowserWorker>(
319 new shell_integration::DefaultBrowserWorker( 317 new shell_integration::DefaultBrowserWorker(
320 new CheckDefaultBrowserObserver(profile->GetPath(), show_prompt))) 318 new CheckDefaultBrowserObserver(profile->GetPath(), show_prompt),
319 /*delete_observer=*/true))
321 ->StartCheckIsDefault(); 320 ->StartCheckIsDefault();
322 } 321 }
323 322
324 #if !defined(OS_WIN) 323 #if !defined(OS_WIN)
325 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { 324 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) {
326 return false; 325 return false;
327 } 326 }
328 #endif 327 #endif
329 328
330 } // namespace chrome 329 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/apps/chrome_app_delegate.cc ('k') | chrome/browser/ui/webui/options/browser_options_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698