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

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: 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 scoped_refptr<ShellIntegration::DefaultBrowserWorker>( 179 scoped_refptr<ShellIntegration::DefaultBrowserWorker>(
180 new ShellIntegration::DefaultBrowserWorker(nullptr)) 180 new ShellIntegration::DefaultBrowserWorker(nullptr, false, true))
181 ->StartSetAsDefault(); 181 ->StartSetAsDefault();
182 return true; 182 return true;
183 } 183 }
184 184
185 bool DefaultBrowserInfoBarDelegate::Cancel() { 185 bool DefaultBrowserInfoBarDelegate::Cancel() {
186 action_taken_ = true; 186 action_taken_ = true;
187 content::RecordAction( 187 content::RecordAction(
188 base::UserMetricsAction("DefaultBrowserInfoBar_DontAskAgain")); 188 base::UserMetricsAction("DefaultBrowserInfoBar_DontAskAgain"));
189 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction", 189 UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction",
190 InfoBarUserInteraction::DONT_ASK_AGAIN, 190 InfoBarUserInteraction::DONT_ASK_AGAIN,
(...skipping 11 matching lines...) Expand all
202 : public ShellIntegration::DefaultWebClientObserver { 202 : public ShellIntegration::DefaultWebClientObserver {
203 public: 203 public:
204 CheckDefaultBrowserObserver(const base::FilePath& profile_path, 204 CheckDefaultBrowserObserver(const base::FilePath& profile_path,
205 bool show_prompt, 205 bool show_prompt,
206 chrome::HostDesktopType desktop_type); 206 chrome::HostDesktopType desktop_type);
207 ~CheckDefaultBrowserObserver() override; 207 ~CheckDefaultBrowserObserver() override;
208 208
209 private: 209 private:
210 void SetDefaultWebClientUIState( 210 void SetDefaultWebClientUIState(
211 ShellIntegration::DefaultWebClientUIState state) override; 211 ShellIntegration::DefaultWebClientUIState state) override;
212 bool IsOwnedByWorker() override;
213 212
214 void ResetCheckDefaultBrowserPref(); 213 void ResetCheckDefaultBrowserPref();
215 void ShowPrompt(); 214 void ShowPrompt();
216 215
217 // The path to the profile for which the prompt is to be shown. 216 // The path to the profile for which the prompt is to be shown.
218 base::FilePath profile_path_; 217 base::FilePath profile_path_;
219 218
220 // True if the prompt is to be shown if Chrome is not the default browser. 219 // True if the prompt is to be shown if Chrome is not the default browser.
221 bool show_prompt_; 220 bool show_prompt_;
222 chrome::HostDesktopType desktop_type_; 221 chrome::HostDesktopType desktop_type_;
(...skipping 17 matching lines...) Expand all
240 // Notify the user in the future if Chrome ceases to be the user's chosen 239 // Notify the user in the future if Chrome ceases to be the user's chosen
241 // default browser. 240 // default browser.
242 ResetCheckDefaultBrowserPref(); 241 ResetCheckDefaultBrowserPref();
243 } else if (show_prompt_ && state == ShellIntegration::STATE_NOT_DEFAULT && 242 } else if (show_prompt_ && state == ShellIntegration::STATE_NOT_DEFAULT &&
244 ShellIntegration::CanSetAsDefaultBrowser() != 243 ShellIntegration::CanSetAsDefaultBrowser() !=
245 ShellIntegration::SET_DEFAULT_NOT_ALLOWED) { 244 ShellIntegration::SET_DEFAULT_NOT_ALLOWED) {
246 ShowPrompt(); 245 ShowPrompt();
247 } 246 }
248 } 247 }
249 248
250 bool CheckDefaultBrowserObserver::IsOwnedByWorker() {
251 // Instruct the DefaultBrowserWorker to delete this instance when it is done.
252 return true;
253 }
254
255 void CheckDefaultBrowserObserver::ResetCheckDefaultBrowserPref() { 249 void CheckDefaultBrowserObserver::ResetCheckDefaultBrowserPref() {
256 Profile* profile = 250 Profile* profile =
257 g_browser_process->profile_manager()->GetProfileByPath(profile_path_); 251 g_browser_process->profile_manager()->GetProfileByPath(profile_path_);
258 if (profile) 252 if (profile)
259 profile->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, true); 253 profile->GetPrefs()->SetBoolean(prefs::kCheckDefaultBrowser, true);
260 } 254 }
261 255
262 void CheckDefaultBrowserObserver::ShowPrompt() { 256 void CheckDefaultBrowserObserver::ShowPrompt() {
263 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type_); 257 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type_);
264 if (!browser) 258 if (!browser)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 DCHECK(disable_version_string.empty() || disable_version.IsValid()); 310 DCHECK(disable_version_string.empty() || disable_version.IsValid());
317 if (disable_version.IsValid() && 311 if (disable_version.IsValid() &&
318 disable_version == Version(version_info::GetVersionNumber())) { 312 disable_version == Version(version_info::GetVersionNumber())) {
319 show_prompt = false; 313 show_prompt = false;
320 } 314 }
321 } 315 }
322 316
323 scoped_refptr<ShellIntegration::DefaultBrowserWorker>( 317 scoped_refptr<ShellIntegration::DefaultBrowserWorker>(
324 new ShellIntegration::DefaultBrowserWorker( 318 new ShellIntegration::DefaultBrowserWorker(
325 new CheckDefaultBrowserObserver(profile->GetPath(), show_prompt, 319 new CheckDefaultBrowserObserver(profile->GetPath(), show_prompt,
326 desktop_type))) 320 desktop_type),
321 true, false))
327 ->StartCheckIsDefault(); 322 ->StartCheckIsDefault();
328 } 323 }
329 324
330 #if !defined(OS_WIN) 325 #if !defined(OS_WIN)
331 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) { 326 bool ShowFirstRunDefaultBrowserPrompt(Profile* profile) {
332 return false; 327 return false;
333 } 328 }
334 #endif 329 #endif
335 330
336 } // namespace chrome 331 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698