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

Side by Side Diff: chrome/browser/ui/webui/settings/settings_default_browser_handler.cc

Issue 1748773002: Simplify the default browser infobar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: sync to position 379825 Created 4 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/webui/settings/settings_default_browser_handler.h" 5 #include "chrome/browser/ui/webui/settings/settings_default_browser_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/ui/startup/default_browser_prompt.h"
9 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
10 #include "components/prefs/pref_service.h" 11 #include "components/prefs/pref_service.h"
11 #include "content/public/browser/web_ui.h" 12 #include "content/public/browser/web_ui.h"
12 13
13 namespace settings { 14 namespace settings {
14 15
15 namespace { 16 namespace {
16 17
17 bool IsDisabledByPolicy(const BooleanPrefMember& pref) { 18 bool IsDisabledByPolicy(const BooleanPrefMember& pref) {
18 return pref.IsManaged() && !pref.GetValue(); 19 return pref.IsManaged() && !pref.GetValue();
(...skipping 30 matching lines...) Expand all
49 default_browser_worker_->StartCheckIsDefault(); 50 default_browser_worker_->StartCheckIsDefault();
50 } 51 }
51 52
52 void DefaultBrowserHandler::SetAsDefaultBrowser(const base::ListValue* args) { 53 void DefaultBrowserHandler::SetAsDefaultBrowser(const base::ListValue* args) {
53 CHECK(!IsDisabledByPolicy(default_browser_policy_)); 54 CHECK(!IsDisabledByPolicy(default_browser_policy_));
54 55
55 default_browser_worker_->StartSetAsDefault(); 56 default_browser_worker_->StartSetAsDefault();
56 57
57 // If the user attempted to make Chrome the default browser, notify 58 // If the user attempted to make Chrome the default browser, notify
58 // them when this changes. 59 // them when this changes.
59 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( 60 chrome::ResetDefaultBrowserPrompt(Profile::FromWebUI(web_ui()));
60 prefs::kCheckDefaultBrowser, true);
61 } 61 }
62 62
63 void DefaultBrowserHandler::OnDefaultBrowserWorkerFinished( 63 void DefaultBrowserHandler::OnDefaultBrowserWorkerFinished(
64 shell_integration::DefaultWebClientUIState state) { 64 shell_integration::DefaultWebClientUIState state) {
65 if (state == shell_integration::STATE_PROCESSING) 65 if (state == shell_integration::STATE_PROCESSING)
66 return; 66 return;
67 67
68 if (state == shell_integration::STATE_IS_DEFAULT) { 68 if (state == shell_integration::STATE_IS_DEFAULT) {
69 // Notify the user in the future if Chrome ceases to be the user's chosen 69 // Notify the user in the future if Chrome ceases to be the user's chosen
70 // default browser. 70 // default browser.
71 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( 71 chrome::ResetDefaultBrowserPrompt(Profile::FromWebUI(web_ui()));
72 prefs::kCheckDefaultBrowser, true);
73 } 72 }
74 73
75 base::FundamentalValue is_default(state == 74 base::FundamentalValue is_default(state ==
76 shell_integration::STATE_IS_DEFAULT); 75 shell_integration::STATE_IS_DEFAULT);
77 base::FundamentalValue can_be_default( 76 base::FundamentalValue can_be_default(
78 state != shell_integration::STATE_UNKNOWN && 77 state != shell_integration::STATE_UNKNOWN &&
79 !IsDisabledByPolicy(default_browser_policy_) && 78 !IsDisabledByPolicy(default_browser_policy_) &&
80 shell_integration::CanSetAsDefaultBrowser() != 79 shell_integration::CanSetAsDefaultBrowser() !=
81 shell_integration::SET_DEFAULT_NOT_ALLOWED); 80 shell_integration::SET_DEFAULT_NOT_ALLOWED);
82 81
83 web_ui()->CallJavascriptFunction("Settings.updateDefaultBrowserState", 82 web_ui()->CallJavascriptFunction("Settings.updateDefaultBrowserState",
84 is_default, can_be_default); 83 is_default, can_be_default);
85 } 84 }
86 85
87 } // namespace settings 86 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698