-
Notifications
You must be signed in to change notification settings - Fork 901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show welcome page only at first run #130
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/ui/webui/brave_welcome_ui.h" | ||
|
||
#include "brave/browser/brave_browser_process_impl.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/common/pref_names.h" | ||
#include "components/prefs/pref_service.h" | ||
|
||
BraveWelcomeUI::BraveWelcomeUI(content::WebUI* web_ui) | ||
: WebUIController(web_ui) { | ||
Profile* profile = Profile::FromWebUI(web_ui); | ||
|
||
profile->GetPrefs()->SetBoolean(prefs::kHasSeenWelcomePage, true); | ||
#if defined(OS_WIN) | ||
g_brave_browser_process->local_state()->SetBoolean( | ||
prefs::kHasSeenWin10PromoPage, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to set this pref even know we don't want a win10 promo page? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked that chrome shows this promo page at first run. Then, it shows welcome page at next run. |
||
true); | ||
#endif | ||
} | ||
|
||
BraveWelcomeUI::~BraveWelcomeUI() { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_UI_WEBUI_BRAVE_WELCOME_UI_H_ | ||
#define BRAVE_BROWSER_UI_WEBUI_BRAVE_WELCOME_UI_H_ | ||
|
||
#include "base/macros.h" | ||
#include "content/public/browser/web_ui_controller.h" | ||
|
||
class BraveWelcomeUI : public content::WebUIController { | ||
public: | ||
explicit BraveWelcomeUI(content::WebUI* web_ui); | ||
~BraveWelcomeUI() override; | ||
|
||
private: | ||
DISALLOW_COPY_AND_ASSIGN(BraveWelcomeUI); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_UI_WEBUI_BRAVE_WELCOME_UI_H_ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "base/command_line.h" | ||
#include "brave/browser/ui/webui/brave_web_ui_controller_factory.h" | ||
#include "brave/common/webui_url_constants.h" | ||
#include "chrome/browser/chrome_notification_types.h" | ||
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/browser/ui/browser.h" | ||
#include "chrome/browser/ui/browser_finder.h" | ||
#include "chrome/browser/ui/startup/startup_browser_creator.h" | ||
#include "chrome/browser/ui/startup/startup_browser_creator_impl.h" | ||
#include "chrome/browser/ui/tabs/tab_strip_model.h" | ||
#include "chrome/common/webui_url_constants.h" | ||
#include "chrome/test/base/in_process_browser_test.h" | ||
#include "content/public/test/test_navigation_observer.h" | ||
#include "content/public/test/test_utils.h" | ||
|
||
namespace { | ||
Browser* OpenNewBrowser(Profile* profile) { | ||
base::CommandLine dummy(base::CommandLine::NO_PROGRAM); | ||
StartupBrowserCreatorImpl creator(base::FilePath(), dummy, | ||
chrome::startup::IS_FIRST_RUN); | ||
creator.Launch(profile, std::vector<GURL>(), false); | ||
return chrome::FindBrowserWithProfile(profile); | ||
} | ||
} | ||
|
||
using BraveWelcomeUIBrowserTest = InProcessBrowserTest; | ||
|
||
// Check whether startup url at first run is our welcome page. | ||
IN_PROC_BROWSER_TEST_F(BraveWelcomeUIBrowserTest, PRE_StartupURLTest) { | ||
Browser* new_browser = OpenNewBrowser(browser()->profile()); | ||
ASSERT_TRUE(new_browser); | ||
TabStripModel* tab_strip = new_browser->tab_strip_model(); | ||
ASSERT_EQ(1, tab_strip->count()); | ||
content::WebContents* web_contents = tab_strip->GetWebContentsAt(0); | ||
content::TestNavigationObserver observer(web_contents, 1); | ||
observer.Wait(); | ||
EXPECT_EQ(kWelcomeRemoteURL, | ||
tab_strip->GetWebContentsAt(0)->GetURL().possibly_invalid_spec()); | ||
} | ||
|
||
// Check wheter startup url is not welcome ui at second run. | ||
IN_PROC_BROWSER_TEST_F(BraveWelcomeUIBrowserTest, StartupURLTest) { | ||
Browser* new_browser = OpenNewBrowser(browser()->profile()); | ||
ASSERT_TRUE(new_browser); | ||
TabStripModel* tab_strip = new_browser->tab_strip_model(); | ||
ASSERT_EQ(1, tab_strip->count()); | ||
content::WebContents* web_contents = tab_strip->GetWebContentsAt(0); | ||
content::TestNavigationObserver observer(web_contents, 1); | ||
observer.Wait(); | ||
EXPECT_EQ(chrome::kChromeUINewTabURL, | ||
tab_strip->GetWebContentsAt(0)->GetURL().possibly_invalid_spec()); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/test/base/brave_test_launcher_delegate.h" | ||
|
||
#include "brave/app/brave_main_delegate.h" | ||
|
||
BraveTestLauncherDelegate::BraveTestLauncherDelegate( | ||
ChromeTestSuiteRunner* runner) | ||
: ChromeTestLauncherDelegate(runner) {} | ||
|
||
BraveTestLauncherDelegate::~BraveTestLauncherDelegate() = default; | ||
|
||
content::ContentMainDelegate* | ||
BraveTestLauncherDelegate::CreateContentMainDelegate() { | ||
return new BraveMainDelegate(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_TEST_BASE_BRAVE_TEST_LAUNCHER_H_ | ||
#define BRAVE_TEST_BASE_BRAVE_TEST_LAUNCHER_H_ | ||
|
||
#include "chrome/test/base/chrome_test_launcher.h" | ||
#include "base/macros.h" | ||
|
||
class BraveTestLauncherDelegate : public ChromeTestLauncherDelegate { | ||
public: | ||
// Does not take ownership of ChromeTestSuiteRunner. | ||
explicit BraveTestLauncherDelegate(ChromeTestSuiteRunner* runner); | ||
~BraveTestLauncherDelegate() override; | ||
|
||
private: | ||
// ChromeLauncherDelegate: | ||
content::ContentMainDelegate* CreateContentMainDelegate() override; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(BraveTestLauncherDelegate); | ||
}; | ||
|
||
#endif // BRAVE_TEST_BASE_BRAVE_TEST_LAUNCHER_H_ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "base/command_line.h" | ||
#include "base/test/launcher/test_launcher.h" | ||
#include "brave/test/base/brave_test_launcher_delegate.h" | ||
#include "build/build_config.h" | ||
|
||
#if defined(OS_WIN) | ||
#include "base/test/test_switches.h" | ||
#include "base/win/win_util.h" | ||
#endif // defined(OS_WIN) | ||
|
||
int main(int argc, char** argv) { | ||
base::CommandLine::Init(argc, argv); | ||
size_t parallel_jobs = base::NumParallelJobs(); | ||
if (parallel_jobs == 0U) { | ||
return 1; | ||
} else if (parallel_jobs > 1U) { | ||
parallel_jobs /= 2U; | ||
} | ||
|
||
#if defined(OS_WIN) | ||
// Enable high-DPI for interactive tests where the user is expected to | ||
// manually verify results. | ||
if (base::CommandLine::ForCurrentProcess()->HasSwitch( | ||
switches::kTestLauncherInteractive)) { | ||
base::win::EnableHighDPISupport(); | ||
} | ||
#endif // defined(OS_WIN) | ||
|
||
ChromeTestSuiteRunner runner; | ||
BraveTestLauncherDelegate delegate(&runner); | ||
return LaunchChromeTests(parallel_jobs, &delegate, argc, argv); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@diracdeltas @bbondy - this isn't directly related to this PR, but I think a remote welcome url is a privacy issue. Is there any reason why it can't be an internal page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed changing to local welcome page but no one has had time to do that yet. Note that browser-laptop is remote too so we have at least baseline parity with that. But we did talk about wanting to move to a local one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like it should be pretty easy to do now that we have a webui for it. Is there a ticket or should I create one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought there was but I couldn't find one, so I posted it here:
brave/brave-browser#276
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here's the original issue by @flamsmark brave/browser-laptop#12691. i also feel strongly that this should be baked into brave for privacy reasons.