Commit 86af4462 authored by peletskyi's avatar peletskyi Committed by Commit bot

If DefaultBrowserSettingEnabled set to false and there is the command line

flag that makes chrome default browser, the flag beats Policy. This is wrong
behavior. Thus added the condition that checks policy before set chrome as
a default browser.

BUG=361527

Review URL: https://codereview.chromium.org/927163002

Cr-Commit-Position: refs/heads/master@{#324224}
parent 8666f865
......@@ -1176,6 +1176,13 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() {
#endif // defined(OS_WIN)
if (parsed_command_line().HasSwitch(switches::kMakeDefaultBrowser)) {
bool is_managed = g_browser_process->local_state()->IsManagedPreference(
prefs::kDefaultBrowserSettingEnabled);
if (is_managed && !g_browser_process->local_state()->GetBoolean(
prefs::kDefaultBrowserSettingEnabled)) {
return static_cast<int>(chrome::RESULT_CODE_ACTION_DISALLOWED_BY_POLICY);
}
return ShellIntegration::SetAsDefaultBrowser() ?
static_cast<int>(content::RESULT_CODE_NORMAL_EXIT) :
static_cast<int>(chrome::RESULT_CODE_SHELL_INTEGRATION_FAILED);
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Warning: this file will not be compiled for ChromeOS because the test
// PolicyMakeDefaultBrowserTest is not valid for this platform.
#include "base/command_line.h"
#include "chrome/common/chrome_result_codes.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/policy_map.h"
#include "policy/policy_constants.h"
class PolicyMakeDefaultBrowserTest : public InProcessBrowserTest {
protected:
PolicyMakeDefaultBrowserTest() : InProcessBrowserTest() {
set_expected_exit_code(chrome::RESULT_CODE_ACTION_DISALLOWED_BY_POLICY);
}
void SetUpInProcessBrowserTestFixture() override {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
switches::kMakeDefaultBrowser);
EXPECT_CALL(provider_, IsInitializationComplete(testing::_))
.WillRepeatedly(testing::Return(true));
policy::BrowserPolicyConnector::SetPolicyProviderForTesting(&provider_);
policy::PolicyMap values;
values.Set(policy::key::kDefaultBrowserSettingEnabled,
policy::POLICY_LEVEL_MANDATORY,
policy::POLICY_SCOPE_MACHINE,
new base::FundamentalValue(false),
NULL);
provider_.UpdateChromePolicy(values);
}
private:
policy::MockConfigurationPolicyProvider provider_;
DISALLOW_COPY_AND_ASSIGN(PolicyMakeDefaultBrowserTest);
};
IN_PROC_BROWSER_TEST_F(PolicyMakeDefaultBrowserTest, MakeDefaultDisabled) {
}
......@@ -762,6 +762,7 @@
'browser/policy/cloud/test_request_interceptor.h',
'browser/policy/policy_browsertest.cc',
'browser/policy/policy_prefs_browsertest.cc',
'browser/policy/policy_startup_browsertest.cc',
'browser/ui/webui/options/certificate_manager_browsertest.cc',
'browser/ui/webui/options/preferences_browsertest.cc',
'browser/ui/webui/options/preferences_browsertest.h',
......@@ -2160,6 +2161,7 @@
'../apps/load_and_launch_browsertest.cc',
'browser/printing/cloud_print/test/cloud_print_policy_browsertest.cc',
'browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc',
'browser/policy/policy_startup_browsertest.cc',
# chromeos does not support profile list avatar menu
'browser/profiles/profile_list_desktop_browsertest.cc',
'browser/service_process/service_process_control_browsertest.cc',
......
......@@ -89,6 +89,9 @@ enum ResultCode {
// (Linux-only).
RESULT_CODE_SXS_MIGRATION_FAILED,
// The action is not allowed by a policy.
RESULT_CODE_ACTION_DISALLOWED_BY_POLICY,
// Last return code (keep this last).
RESULT_CODE_CHROME_LAST_CODE,
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment