Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit 2eab532

Browse files
author
Mikhail Pozdnyakov
committed
Rename xwalk::Runtime to xwalk::XWalkContent
Rename xwalk::Runtime to xwalk::XWalkContent and stop compiling it on Android.
1 parent 8689eaa commit 2eab532

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+359
-337
lines changed

application/browser/application.cc

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "xwalk/application/common/application_manifest_constants.h"
2222
#include "xwalk/application/common/constants.h"
2323
#include "xwalk/application/common/manifest_handlers/warp_handler.h"
24-
#include "xwalk/runtime/browser/runtime.h"
24+
#include "xwalk/runtime/browser/xwalk_content.h"
2525
#include "xwalk/runtime/browser/runtime_ui_delegate.h"
2626
#include "xwalk/runtime/browser/xwalk_browser_context.h"
2727
#include "xwalk/runtime/browser/xwalk_runner.h"
@@ -204,7 +204,7 @@ ui::WindowShowState Application::GetWindowShowState<Manifest::TYPE_MANIFEST>(
204204
}
205205

206206
bool Application::Launch(const LaunchParams& launch_params) {
207-
if (!runtimes_.empty()) {
207+
if (!pages_.empty()) {
208208
LOG(ERROR) << "Attempt to launch app with id " << id()
209209
<< ", but it is already running.";
210210
return false;
@@ -220,14 +220,14 @@ bool Application::Launch(const LaunchParams& launch_params) {
220220

221221
remote_debugging_enabled_ = launch_params.remote_debugging;
222222
auto site = content::SiteInstance::CreateForURL(browser_context_, url);
223-
Runtime* runtime = Runtime::Create(browser_context_, site);
224-
runtime->set_observer(this);
225-
runtimes_.push_back(runtime);
226-
render_process_host_ = runtime->GetRenderProcessHost();
223+
XWalkContent* page = XWalkContent::Create(browser_context_, site);
224+
page->set_observer(this);
225+
pages_.push_back(page);
226+
render_process_host_ = page->GetRenderProcessHost();
227227
render_process_host_->AddObserver(this);
228-
web_contents_ = runtime->web_contents();
228+
web_contents_ = page->web_contents();
229229
InitSecurityPolicy();
230-
runtime->LoadURL(url);
230+
page->LoadURL(url);
231231

232232
NativeAppWindow::CreateParams params;
233233
params.net_wm_pid = launch_params.launcher_pid;
@@ -236,9 +236,9 @@ bool Application::Launch(const LaunchParams& launch_params) {
236236
GetWindowShowState<Manifest::TYPE_MANIFEST>(launch_params);
237237

238238
window_show_params_ = params;
239-
// Only the first runtime can have a launch screen.
239+
// Only the first page can have a launch screen.
240240
params.splash_screen_path = GetSplashScreenPath();
241-
runtime->set_ui_delegate(DefaultRuntimeUIDelegate::Create(runtime, params));
241+
page->set_ui_delegate(DefaultRuntimeUIDelegate::Create(page, params));
242242
// We call "Show" after RP is initialized to reduce
243243
// the application start up time.
244244

@@ -256,32 +256,31 @@ GURL Application::GetAbsoluteURLFromKey(const std::string& key) {
256256
}
257257

258258
void Application::Terminate() {
259-
std::vector<Runtime*> to_be_closed(runtimes_.get());
260-
for (Runtime* runtime : to_be_closed)
261-
runtime->Close();
259+
std::vector<XWalkContent*> to_be_closed(pages_.get());
260+
for (XWalkContent* content : to_be_closed)
261+
content->Close();
262262
}
263263

264264
int Application::GetRenderProcessHostID() const {
265265
DCHECK(render_process_host_);
266266
return render_process_host_->GetID();
267267
}
268268

269-
void Application::OnNewRuntimeAdded(Runtime* runtime) {
270-
runtime->set_remote_debugging_enabled(remote_debugging_enabled_);
271-
runtime->set_observer(this);
272-
runtime->set_ui_delegate(
273-
DefaultRuntimeUIDelegate::Create(runtime, window_show_params_));
274-
runtime->Show();
275-
runtimes_.push_back(runtime);
269+
void Application::OnContentCreated(XWalkContent* page) {
270+
page->set_remote_debugging_enabled(remote_debugging_enabled_);
271+
page->set_observer(this);
272+
page->set_ui_delegate(
273+
DefaultRuntimeUIDelegate::Create(page, window_show_params_));
274+
page->Show();
275+
pages_.push_back(page);
276276
}
277277

278-
void Application::OnRuntimeClosed(Runtime* runtime) {
279-
auto found = std::find(runtimes_.begin(), runtimes_.end(), runtime);
280-
CHECK(found != runtimes_.end());
281-
LOG(INFO) << "Application::OnRuntimeClosed " << runtime;
282-
runtimes_.erase(found);
278+
void Application::OnContentClosed(XWalkContent* page) {
279+
auto found = std::find(pages_.begin(), pages_.end(), page);
280+
CHECK(found != pages_.end());
281+
pages_.erase(found);
283282

284-
if (runtimes_.empty())
283+
if (pages_.empty())
285284
base::MessageLoop::current()->PostTask(FROM_HERE,
286285
base::Bind(&Application::NotifyTermination,
287286
weak_factory_.GetWeakPtr()));
@@ -309,8 +308,8 @@ void Application::NotifyTermination() {
309308
}
310309

311310
void Application::RenderChannelCreated() {
312-
CHECK(!runtimes_.empty());
313-
runtimes_.front()->Show();
311+
CHECK(!pages_.empty());
312+
pages_.front()->Show();
314313
}
315314

316315
bool Application::UseExtension(const std::string& extension_name) const {

application/browser/application.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
#include "ui/base/ui_base_types.h"
2222
#include "xwalk/application/browser/application_security_policy.h"
2323
#include "xwalk/application/common/application_data.h"
24-
#include "xwalk/runtime/browser/runtime.h"
24+
#include "xwalk/runtime/browser/ui/native_app_window.h"
25+
#include "xwalk/runtime/browser/xwalk_content.h"
2526

2627
namespace content {
2728
class RenderProcessHost;
@@ -43,15 +44,15 @@ class ApplicationSecurityPolicy;
4344
// ApplicationService will delete an Application instance when it is
4445
// terminated.
4546
// There's one-to-one correspondence between Application and Render Process
46-
// Host, obtained from its "runtimes" (pages).
47-
class Application : public Runtime::Observer,
47+
// Host, obtained from its "contents" (pages).
48+
class Application : public XWalkContent::Observer,
4849
public content::RenderProcessHostObserver {
4950
public:
5051
virtual ~Application();
5152

5253
class Observer {
5354
public:
54-
// Invoked when application is terminated - all its pages (runtimes)
55+
// Invoked when application is terminated - all its pages (contents)
5556
// are closed.
5657
virtual void OnApplicationTerminated(Application* app) {}
5758

@@ -68,7 +69,7 @@ class Application : public Runtime::Observer,
6869
bool remote_debugging;
6970
};
7071

71-
// Closes all the application's runtimes (application pages).
72+
// Closes all the application's pages (application pages).
7273
// NOTE: Application is terminated asynchronously.
7374
// Please use ApplicationService::Observer::WillDestroyApplication()
7475
// interface to be notified about actual app termination.
@@ -77,7 +78,7 @@ class Application : public Runtime::Observer,
7778
// immediately after its termination.
7879
void Terminate();
7980

80-
const std::vector<Runtime*>& runtimes() const { return runtimes_.get(); }
81+
const std::vector<XWalkContent*>& pages() const { return pages_.get(); }
8182

8283
// Returns the unique application id which is used to distinguish the
8384
// application amoung both running applications and installed ones
@@ -93,7 +94,7 @@ class Application : public Runtime::Observer,
9394
// Tells whether the application use the specified extension.
9495
bool UseExtension(const std::string& extension_name) const;
9596

96-
// The runtime permission mapping is registered by extension which
97+
// The content permission mapping is registered by extension which
9798
// implements some specific API, for example:
9899
// "bluetooth" -> "bluetooth.read, bluetooth.write, bluetooth.management"
99100
// Whenever there comes a API permission request, we can tell whether
@@ -122,16 +123,16 @@ class Application : public Runtime::Observer,
122123
virtual bool Launch(const LaunchParams& launch_params);
123124
virtual void InitSecurityPolicy();
124125

125-
// Runtime::Observer implementation.
126-
virtual void OnNewRuntimeAdded(Runtime* runtime) override;
127-
virtual void OnRuntimeClosed(Runtime* runtime) override;
126+
// XWalkContent::Observer implementation.
127+
virtual void OnContentCreated(XWalkContent* content) override;
128+
virtual void OnContentClosed(XWalkContent* content) override;
128129

129130
// Get the path of splash screen image. Return empty path by default.
130131
// Sub class can override it to return a specific path.
131132
virtual base::FilePath GetSplashScreenPath();
132133

133134
XWalkBrowserContext* browser_context_;
134-
ScopedVector<Runtime> runtimes_;
135+
ScopedVector<XWalkContent> pages_;
135136
scoped_refptr<ApplicationData> const data_;
136137
// The application's render process host.
137138
content::RenderProcessHost* render_process_host_;

application/browser/application_service.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "xwalk/application/common/application_manifest_constants.h"
2323
#include "xwalk/application/common/application_file_util.h"
2424
#include "xwalk/application/common/id_util.h"
25-
#include "xwalk/runtime/browser/runtime.h"
25+
#include "xwalk/runtime/browser/xwalk_content.h"
2626
#include "xwalk/runtime/browser/xwalk_browser_context.h"
2727
#include "xwalk/runtime/common/xwalk_paths.h"
2828

application/browser/application_tizen.cc

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,25 @@ namespace application {
4444
const char kDefaultMediaAppClass[] = "player";
4545
namespace {
4646
#if defined(OS_TIZEN_MOBILE)
47-
void ApplyRootWindowParams(Runtime* runtime,
47+
void ApplyRootWindowParams(XWalkContent* content,
4848
NativeAppWindow::CreateParams* params) {
4949
if (!params->delegate)
50-
params->delegate = runtime;
50+
params->delegate = content;
5151
if (params->bounds.IsEmpty())
5252
params->bounds = gfx::Rect(0, 0, 840, 600);
5353

54-
unsigned int fullscreen_options = runtime->fullscreen_options();
54+
unsigned int fullscreen_options = content->fullscreen_options();
5555
if (params->state == ui::SHOW_STATE_FULLSCREEN)
56-
fullscreen_options |= Runtime::FULLSCREEN_FOR_LAUNCH;
56+
fullscreen_options |= XWalkContent::FULLSCREEN_FOR_LAUNCH;
5757
else
5858
fullscreen_options &= ~Runtime::FULLSCREEN_FOR_LAUNCH;
59-
runtime->set_fullscreen_options(fullscreen_options);
59+
content->set_fullscreen_options(fullscreen_options);
6060
}
6161

62-
NativeAppWindow* CreateRootWindow(Runtime* runtime,
62+
NativeAppWindow* CreateRootWindow(XWalkContent* content,
6363
const NativeAppWindow::CreateParams& params) {
6464
NativeAppWindow::CreateParams effective_params(params);
65-
ApplyRootWindowParams(runtime, &effective_params);
65+
ApplyRootWindowParams(content, &effective_params);
6666
return NativeAppWindow::Create(effective_params);
6767
}
6868
#endif
@@ -109,11 +109,11 @@ class ScreenOrientationProviderTizen :
109109
return;
110110
}
111111
request_id_ = request_id;
112-
const std::vector<Runtime*>& runtimes = app_->runtimes();
113-
DCHECK(!runtimes.empty());
112+
const std::vector<XWalkContent*>& pages = app_->pages();
113+
DCHECK(!pages.empty());
114114
// FIXME: Probably need better alignment with
115115
// https://w3c.github.io/screen-orientation/#screen-orientation-lock-lifetime
116-
for (auto it = runtimes.begin(); it != runtimes.end(); ++it) {
116+
for (auto it = pages.begin(); it != pages.end(); ++it) {
117117
NativeAppWindow* window = (*it)->window();
118118
if (window && window->IsActive()) {
119119
ToNativeAppWindowTizen(window)->LockOrientation(lock);
@@ -157,26 +157,26 @@ ApplicationTizen::~ApplicationTizen() {
157157
}
158158

159159
void ApplicationTizen::Hide() {
160-
DCHECK(!runtimes_.empty());
161-
for (auto it = runtimes_.begin(); it != runtimes_.end(); ++it) {
162-
if ((*it)->window())
163-
(*it)->window()->Minimize();
160+
DCHECK(!pages_.empty());
161+
for (XWalkContent* page : pages_) {
162+
if (auto window = page->window())
163+
window->Minimize();
164164
}
165165
}
166166

167167
void ApplicationTizen::Show() {
168-
DCHECK(!runtimes_.empty());
169-
for (Runtime* runtime : runtimes_) {
170-
if (auto window = runtime->window())
168+
DCHECK(!pages_.empty());
169+
for (XWalkContent* page : pages_) {
170+
if (auto window = page->window())
171171
window->Restore();
172172
}
173173
}
174174

175175
bool ApplicationTizen::Launch(const LaunchParams& launch_params) {
176176
if (Application::Launch(launch_params)) {
177177
#if defined(OS_TIZEN_MOBILE)
178-
if (!runtimes_.empty()) {
179-
root_window_ = CreateRootWindow(*(runtimes_.begin()),
178+
if (!pages_.empty()) {
179+
root_window_ = CreateRootWindow(*(pages_.begin()),
180180
window_show_params_);
181181
window_show_params_.parent = root_window_->GetNativeWindow();
182182
root_window_->Show();
@@ -234,10 +234,9 @@ void ApplicationTizen::Suspend() {
234234
DCHECK(render_process_host_);
235235
render_process_host_->Send(new ViewMsg_SuspendJSEngine(true));
236236

237-
DCHECK(!runtimes_.empty());
238-
for (auto it = runtimes_.begin(); it != runtimes_.end(); ++it) {
239-
if ((*it)->web_contents())
240-
(*it)->web_contents()->WasHidden();
237+
DCHECK(!pages_.empty());
238+
for (XWalkContent* page : pages_) {
239+
page->web_contents()->WasHidden();
241240
}
242241
is_suspended_ = true;
243242
}
@@ -249,10 +248,9 @@ void ApplicationTizen::Resume() {
249248
DCHECK(render_process_host_);
250249
render_process_host_->Send(new ViewMsg_SuspendJSEngine(false));
251250

252-
DCHECK(!runtimes_.empty());
253-
for (auto it = runtimes_.begin(); it != runtimes_.end(); ++it) {
254-
if ((*it)->web_contents())
255-
(*it)->web_contents()->WasShown();
251+
DCHECK(!pages_.empty());
252+
for (XWalkContent* page : pages_) {
253+
page->web_contents()->WasShown();
256254
}
257255
is_suspended_ = false;
258256
}
@@ -282,10 +280,9 @@ void ApplicationTizen::DidProcessEvent(
282280
if (info && !info->hwkey_enabled())
283281
return;
284282

285-
for (auto it = runtimes_.begin();
286-
it != runtimes_.end(); ++it) {
287-
(*it)->web_contents()->GetRenderViewHost()->Send(new ViewMsg_HWKeyPressed(
288-
(*it)->web_contents()->GetRoutingID(), key_event->key_code()));
283+
for (XWalkContent* page : pages_) {
284+
page->web_contents()->GetRenderViewHost()->Send(new ViewMsg_HWKeyPressed(
285+
page->web_contents()->GetRoutingID(), key_event->key_code()));
289286
}
290287
}
291288
#endif
@@ -299,20 +296,20 @@ void ApplicationTizen::SetUserAgentString(
299296
cookie_manager_->SetUserAgentString(render_process_host_, user_agent_string);
300297
}
301298

302-
void ApplicationTizen::OnNewRuntimeAdded(Runtime* runtime) {
303-
DCHECK(runtime);
304-
Application::OnNewRuntimeAdded(runtime);
299+
void ApplicationTizen::OnContentCreated(XWalkContent* content) {
300+
DCHECK(content);
301+
Application::OnContentCreated(content);
305302
#if defined(OS_TIZEN_MOBILE)
306-
if (root_window_ && runtimes_.size() > 1)
303+
if (root_window_ && pages_.size() > 1)
307304
root_window_->Show();
308305
#endif
309306
}
310307

311-
void ApplicationTizen::OnRuntimeClosed(Runtime* runtime) {
312-
DCHECK(runtime);
313-
Application::OnRuntimeClosed(runtime);
308+
void ApplicationTizen::OnContentClosed(XWalkContent* content) {
309+
DCHECK(content);
310+
Application::OnContentClosed(content);
314311
#if defined(OS_TIZEN_MOBILE)
315-
if (runtimes_.empty() && root_window_) {
312+
if (pages_.empty() && root_window_) {
316313
root_window_->Close();
317314
root_window_ = NULL;
318315
}

application/browser/application_tizen.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ class ApplicationTizen : // NOLINT
4242

4343
virtual base::FilePath GetSplashScreenPath() OVERRIDE;
4444

45-
// Runtime::Observer implementation.
46-
virtual void OnNewRuntimeAdded(Runtime* runtime) OVERRIDE;
47-
virtual void OnRuntimeClosed(Runtime* runtime) OVERRIDE;
45+
// XWalkContent::Observer implementation.
46+
virtual void OnContentCreated(XWalkContent* content) OVERRIDE;
47+
virtual void OnContentClosed(XWalkContent* content) OVERRIDE;
4848

4949
#if defined(USE_OZONE)
5050
virtual void WillProcessEvent(const ui::PlatformEvent& event) OVERRIDE;

application/extension/application_runtime_extension.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "ui/base/resource/resource_bundle.h"
1313
#include "xwalk/application/browser/application.h"
1414
#include "xwalk/application/common/application_data.h"
15-
#include "xwalk/runtime/browser/runtime.h"
15+
#include "xwalk/runtime/browser/xwalk_content.h"
1616

1717
using content::BrowserThread;
1818

application/extension/application_widget_extension.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "xwalk/application/common/application_manifest_constants.h"
2020
#include "xwalk/application/common/manifest_handlers/widget_handler.h"
2121
#include "xwalk/application/extension/application_widget_storage.h"
22-
#include "xwalk/runtime/browser/runtime.h"
22+
#include "xwalk/runtime/browser/xwalk_content.h"
2323
#include "xwalk/runtime/browser/xwalk_browser_context.h"
2424
#include "xwalk/runtime/browser/xwalk_runner.h"
2525
#include "xwalk/runtime/common/xwalk_paths.h"

application/test/application_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ IN_PROC_BROWSER_TEST_F(ApplicationTest, TestMultiApp) {
3535
test_runner_->WaitForTestNotification();
3636
EXPECT_EQ(test_runner_->GetTestsResult(), ApiTestRunner::PASS);
3737
// The App1 has 2 pages: main doc page and "main.html" page.
38-
EXPECT_EQ(app1->runtimes().size(), 1);
38+
EXPECT_EQ(app1->pages().size(), 1);
3939

4040
EXPECT_EQ(service->active_applications().size(), currently_running_count + 1);
4141
EXPECT_EQ(service->GetApplicationByID(app1->id()), app1);
@@ -59,7 +59,7 @@ IN_PROC_BROWSER_TEST_F(ApplicationTest, TestMultiApp) {
5959
EXPECT_EQ(test_runner_->GetTestsResult(), ApiTestRunner::PASS);
6060

6161
// The App2 also has 2 pages: main doc page and "main.html" page.
62-
EXPECT_EQ(app2->runtimes().size(), 1);
62+
EXPECT_EQ(app2->pages().size(), 1);
6363

6464
// Check that the apps have different IDs and RPH IDs.
6565
EXPECT_NE(app1->id(), app2->id());

0 commit comments

Comments
 (0)