Skip to content

Commit

Permalink
Merge pull request #4565 from brave/disable-sync-temp
Browse files Browse the repository at this point in the history
Append --disable-sync swtich to disable sync temporarily
  • Loading branch information
darkdh authored and bbondy committed Feb 8, 2020
1 parent 007a96f commit 02e9305
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 6 deletions.
3 changes: 3 additions & 0 deletions app/brave_main_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ bool BraveMainDelegate::BasicStartupComplete(int* exit_code) {
command_line.AppendSwitchASCII(switches::kSyncServiceURL,
"https://no-thanks.invalid");

// Disable sync temporarily
command_line.AppendSwitch(switches::kDisableSync);

// Enabled features.
const std::unordered_set<const char*> enabled_features = {
password_manager::features::kPasswordImport.name,
Expand Down
11 changes: 8 additions & 3 deletions browser/brave_content_browser_client_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/prefs/pref_service.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h"
Expand Down Expand Up @@ -154,10 +155,11 @@ IN_PROC_BROWSER_TEST_F(BraveContentBrowserClientTest, CanLoadCustomBravePages) {
#if BUILDFLAG(BRAVE_REWARDS_ENABLED)
"rewards",
#endif
};
#if BUILDFLAG(ENABLE_BRAVE_SYNC)
chrome::kChromeUISyncHost,
if (switches::IsSyncAllowedByFlag())
pages.push_back(chrome::kChromeUISyncHost);
#endif
};

std::vector<std::string> schemes {
"brave://",
Expand Down Expand Up @@ -221,7 +223,10 @@ IN_PROC_BROWSER_TEST_F(BraveContentBrowserClientTest,
browser()->tab_strip_model()->GetActiveWebContents();
ui_test_utils::NavigateToURL(
browser(), GURL(scheme + chrome::kChromeUISyncInternalsHost));
ASSERT_TRUE(WaitForLoadStop(contents));
if (switches::IsSyncAllowedByFlag())
ASSERT_TRUE(WaitForLoadStop(contents));
else
ASSERT_FALSE(WaitForLoadStop(contents));

EXPECT_STREQ(base::UTF16ToUTF8(browser()->location_bar_model()
->GetFormattedFullURL()).c_str(),
Expand Down
16 changes: 13 additions & 3 deletions browser/ui/brave_browser_command_controller_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_utils.h"

Expand Down Expand Up @@ -53,7 +54,10 @@ IN_PROC_BROWSER_TEST_F(BraveBrowserCommandControllerTest,
#endif

#if BUILDFLAG(ENABLE_BRAVE_SYNC)
EXPECT_TRUE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_SYNC));
if (switches::IsSyncAllowedByFlag())
EXPECT_TRUE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_SYNC));
else
EXPECT_FALSE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_SYNC));
#else
EXPECT_FALSE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_SYNC));
#endif
Expand Down Expand Up @@ -86,7 +90,10 @@ IN_PROC_BROWSER_TEST_F(BraveBrowserCommandControllerTest,
#endif

#if BUILDFLAG(ENABLE_BRAVE_SYNC)
EXPECT_TRUE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_SYNC));
if (switches::IsSyncAllowedByFlag())
EXPECT_TRUE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_SYNC));
else
EXPECT_FALSE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_SYNC));
#endif

#if BUILDFLAG(BRAVE_WALLET_ENABLED)
Expand Down Expand Up @@ -171,7 +178,10 @@ IN_PROC_BROWSER_TEST_F(BraveBrowserCommandControllerTest,
#endif

#if BUILDFLAG(ENABLE_BRAVE_SYNC)
EXPECT_TRUE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_SYNC));
if (switches::IsSyncAllowedByFlag())
EXPECT_TRUE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_SYNC));
else
EXPECT_FALSE(command_controller->IsCommandEnabled(IDC_SHOW_BRAVE_SYNC));
#endif

#if BUILDFLAG(BRAVE_WALLET_ENABLED)
Expand Down
31 changes: 31 additions & 0 deletions browser/ui/toolbar/brave_app_menu_model_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "content/public/browser/notification_service.h"
#include "content/public/test/test_utils.h"

Expand Down Expand Up @@ -88,6 +89,16 @@ IN_PROC_BROWSER_TEST_F(BraveAppMenuBrowserTest, MenuOrderTest) {
std::vector<int> commands_disabled_for_normal_profile = {
IDC_NEW_TOR_CONNECTION_FOR_SITE,
};
#if BUILDFLAG(ENABLE_BRAVE_SYNC)
if (!switches::IsSyncAllowedByFlag()) {
commands_in_order_for_normal_profile.erase(
std::remove(commands_in_order_for_normal_profile.begin(),
commands_in_order_for_normal_profile.end(),
IDC_SHOW_BRAVE_SYNC),
commands_in_order_for_normal_profile.end());
commands_disabled_for_normal_profile.push_back(IDC_SHOW_BRAVE_SYNC);
}
#endif
CheckCommandsAreInOrderInMenuModel(browser(),
commands_in_order_for_normal_profile);
CheckCommandsAreDisabledInMenuModel(browser(),
Expand Down Expand Up @@ -122,6 +133,16 @@ IN_PROC_BROWSER_TEST_F(BraveAppMenuBrowserTest, MenuOrderTest) {
IDC_NEW_TOR_CONNECTION_FOR_SITE,
IDC_RECENT_TABS_MENU,
};
#if BUILDFLAG(ENABLE_BRAVE_SYNC)
if (!switches::IsSyncAllowedByFlag()) {
commands_in_order_for_private_profile.erase(
std::remove(commands_in_order_for_private_profile.begin(),
commands_in_order_for_private_profile.end(),
IDC_SHOW_BRAVE_SYNC),
commands_in_order_for_private_profile.end());
commands_disabled_for_private_profile.push_back(IDC_SHOW_BRAVE_SYNC);
}
#endif
CheckCommandsAreInOrderInMenuModel(private_browser,
commands_in_order_for_private_profile);
CheckCommandsAreDisabledInMenuModel(private_browser,
Expand Down Expand Up @@ -215,6 +236,16 @@ IN_PROC_BROWSER_TEST_F(BraveAppMenuBrowserTest, MenuOrderTest) {
std::vector<int> commands_disabled_for_tor_profile = {
IDC_RECENT_TABS_MENU,
};
#if BUILDFLAG(ENABLE_BRAVE_SYNC)
if (!switches::IsSyncAllowedByFlag()) {
commands_in_order_for_tor_profile.erase(
std::remove(commands_in_order_for_tor_profile.begin(),
commands_in_order_for_tor_profile.end(),
IDC_SHOW_BRAVE_SYNC),
commands_in_order_for_tor_profile.end());
commands_disabled_for_tor_profile.push_back(IDC_SHOW_BRAVE_SYNC);
}
#endif
CheckCommandsAreInOrderInMenuModel(tor_browser,
commands_in_order_for_tor_profile);
CheckCommandsAreDisabledInMenuModel(tor_browser,
Expand Down

0 comments on commit 02e9305

Please sign in to comment.