forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create weblayer_browsertests target and one simple test.
This will be added to FYI bots in a followup cl. Change-Id: I8ca2e3ce61e628cf6e342a8ab4fc604975c0d225 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1809897 Commit-Queue: John Abd-El-Malek <jam@chromium.org> Auto-Submit: John Abd-El-Malek <jam@chromium.org> Reviewed-by: Scott Violet <sky@chromium.org> Cr-Commit-Position: refs/heads/master@{#697497}
- Loading branch information
John Abd-El-Malek
authored and
Commit Bot
committed
Sep 18, 2019
1 parent
e59b493
commit 002abf2
Showing
21 changed files
with
502 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
// Copyright 2019 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. | ||
|
||
#include "weblayer/shell/app/shell_main_params.h" | ||
|
||
#include "base/callback.h" | ||
#include "base/command_line.h" | ||
#include "base/environment.h" | ||
#include "base/files/file_path.h" | ||
#include "base/files/file_util.h" | ||
#include "base/no_destructor.h" | ||
#include "base/path_service.h" | ||
#include "build/build_config.h" | ||
#include "net/base/filename_util.h" | ||
#include "url/gurl.h" | ||
#include "weblayer/public/main.h" | ||
#include "weblayer/public/profile.h" | ||
#include "weblayer/shell/browser/shell.h" | ||
#include "weblayer/shell/common/shell_switches.h" | ||
|
||
#if defined(OS_WIN) | ||
#include "base/base_paths_win.h" | ||
#elif defined(OS_LINUX) | ||
#include "base/nix/xdg_util.h" | ||
#endif | ||
|
||
namespace weblayer { | ||
|
||
namespace { | ||
|
||
GURL GetStartupURL() { | ||
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | ||
const base::CommandLine::StringVector& args = command_line->GetArgs(); | ||
|
||
#if defined(OS_ANDROID) | ||
// Delay renderer creation on Android until surface is ready. | ||
return GURL(); | ||
#endif | ||
|
||
if (args.empty()) | ||
return GURL("https://www.google.com/"); | ||
|
||
GURL url(args[0]); | ||
if (url.is_valid() && url.has_scheme()) | ||
return url; | ||
|
||
return net::FilePathToFileURL( | ||
base::MakeAbsoluteFilePath(base::FilePath(args[0]))); | ||
} | ||
|
||
class MainDelegateImpl : public MainDelegate { | ||
public: | ||
void PreMainMessageLoopRun() override { | ||
InitializeProfiles(); | ||
|
||
Shell::Initialize(); | ||
|
||
Shell::CreateNewWindow(profile_.get(), GetStartupURL(), gfx::Size()); | ||
} | ||
|
||
void SetMainMessageLoopQuitClosure(base::OnceClosure quit_closure) override { | ||
Shell::SetMainMessageLoopQuitClosure(std::move(quit_closure)); | ||
} | ||
|
||
private: | ||
void InitializeProfiles() { | ||
base::FilePath path; | ||
|
||
base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | ||
if (cmd_line->HasSwitch(switches::kWebLayerShellDataPath)) { | ||
path = cmd_line->GetSwitchValuePath(switches::kWebLayerShellDataPath); | ||
if (base::DirectoryExists(path) || base::CreateDirectory(path)) { | ||
// Profile needs an absolute path, which we would normally get via | ||
// PathService. In this case, manually ensure the path is absolute. | ||
if (!path.IsAbsolute()) | ||
path = base::MakeAbsoluteFilePath(path); | ||
} else { | ||
LOG(ERROR) << "Unable to create data-path directory: " << path.value(); | ||
} | ||
} else { | ||
#if defined(OS_WIN) | ||
CHECK(base::PathService::Get(base::DIR_LOCAL_APP_DATA, &path)); | ||
path = path.AppendASCII("web_shell"); | ||
#elif defined(OS_LINUX) | ||
std::unique_ptr<base::Environment> env(base::Environment::Create()); | ||
base::FilePath config_dir( | ||
base::nix::GetXDGDirectory(env.get(), base::nix::kXdgConfigHomeEnvVar, | ||
base::nix::kDotConfigDir)); | ||
path = config_dir.AppendASCII("web_shell"); | ||
#elif defined(OS_ANDROID) | ||
CHECK(base::PathService::Get(base::DIR_ANDROID_APP_DATA, &path)); | ||
path = path.AppendASCII("web_shell"); | ||
#else | ||
NOTIMPLEMENTED(); | ||
#endif | ||
if (!base::PathExists(path)) | ||
base::CreateDirectory(path); | ||
} | ||
|
||
profile_ = Profile::Create(path); | ||
|
||
// TODO: create an incognito profile as well. | ||
} | ||
|
||
std::unique_ptr<Profile> profile_; | ||
}; | ||
|
||
} // namespace | ||
|
||
MainParams CreateMainParams() { | ||
static const base::NoDestructor<MainDelegateImpl> weblayer_delegate; | ||
MainParams params; | ||
params.delegate = const_cast<MainDelegateImpl*>(&(*weblayer_delegate)); | ||
|
||
base::PathService::Get(base::DIR_EXE, ¶ms.log_filename); | ||
params.log_filename = params.log_filename.AppendASCII("weblayer_shell.log"); | ||
|
||
params.pak_name = "weblayer.pak"; | ||
|
||
params.brand = "weblayer_shell"; | ||
params.full_version = WEBLAYER_SHELL_VERSION; | ||
params.major_version = WEBLAYER_SHELL_MAJOR_VERSION; | ||
return params; | ||
} | ||
|
||
} // namespace weblayer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2019 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. | ||
|
||
#ifndef WEBLAYER_SHELL_APP_SHELL_MAIN_PARAMS_H_ | ||
#define WEBLAYER_SHELL_APP_SHELL_MAIN_PARAMS_H_ | ||
|
||
namespace weblayer { | ||
struct MainParams; | ||
|
||
weblayer::MainParams CreateMainParams(); | ||
|
||
} // namespace weblayer | ||
|
||
#endif // WEBLAYER_SHELL_APP_SHELL_MAIN_PARAMS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright 2019 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. | ||
|
||
#include "weblayer/shell/common/shell_switches.h" | ||
|
||
namespace switches { | ||
|
||
// Makes WebLayer Shell use the given path for its data directory. | ||
const char kWebLayerShellDataPath[] = "data-path"; | ||
|
||
} // namespace switches |
Oops, something went wrong.