| OLD | NEW |
| 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 Loading... |
| 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::DefaultWebClientState state) { | 64 shell_integration::DefaultWebClientState state) { |
| 65 if (state == shell_integration::IS_DEFAULT) { | 65 if (state == shell_integration::IS_DEFAULT) { |
| 66 // Notify the user in the future if Chrome ceases to be the user's chosen | 66 // Notify the user in the future if Chrome ceases to be the user's chosen |
| 67 // default browser. | 67 // default browser. |
| 68 Profile::FromWebUI(web_ui())->GetPrefs()->SetBoolean( | 68 chrome::ResetDefaultBrowserPrompt(Profile::FromWebUI(web_ui())); |
| 69 prefs::kCheckDefaultBrowser, true); | |
| 70 } | 69 } |
| 71 | 70 |
| 72 base::FundamentalValue is_default(state == shell_integration::IS_DEFAULT); | 71 base::FundamentalValue is_default(state == shell_integration::IS_DEFAULT); |
| 73 base::FundamentalValue can_be_default( | 72 base::FundamentalValue can_be_default( |
| 74 state != shell_integration::UNKNOWN_DEFAULT && | 73 state != shell_integration::UNKNOWN_DEFAULT && |
| 75 !IsDisabledByPolicy(default_browser_policy_) && | 74 !IsDisabledByPolicy(default_browser_policy_) && |
| 76 shell_integration::CanSetAsDefaultBrowser() != | 75 shell_integration::CanSetAsDefaultBrowser() != |
| 77 shell_integration::SET_DEFAULT_NOT_ALLOWED); | 76 shell_integration::SET_DEFAULT_NOT_ALLOWED); |
| 78 | 77 |
| 79 web_ui()->CallJavascriptFunction("Settings.updateDefaultBrowserState", | 78 web_ui()->CallJavascriptFunction("Settings.updateDefaultBrowserState", |
| 80 is_default, can_be_default); | 79 is_default, can_be_default); |
| 81 } | 80 } |
| 82 | 81 |
| 83 } // namespace settings | 82 } // namespace settings |
| OLD | NEW |