0280df57b6a3ad4ac881a8d648496776bd0ee0a7
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / browser / runtime_platform_util_tizen.cc
1 // Copyright (c) 2014 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "xwalk/runtime/browser/runtime_platform_util.h"
6
7 #include "base/file_util.h"
8 #include "base/logging.h"
9 #include "base/process/kill.h"
10 #include "base/process/launch.h"
11 #include "url/gurl.h"
12
13 namespace platform_util {
14 namespace {
15 // The system default web browser path.
16 // In some Tizen releases, there exists a system browser called 'MiniBrowser',
17 // which we can use to open an external link from a web app.
18 const char kWebBrowserPath[] = "/usr/bin/MiniBrowser";
19 }  // namespace
20
21 void OpenExternal(const GURL& url) {
22   if (url.SchemeIsHTTPOrHTTPS()) {
23     LOG(INFO) << "Open in WebBrowser.";
24     std::vector<std::string> argv;
25     if (base::PathExists(base::FilePath(kWebBrowserPath)))
26       argv.push_back(kWebBrowserPath);
27     else
28       argv.push_back("xwalk");
29     argv.push_back(url.spec());
30     base::ProcessHandle handle;
31
32     if (base::LaunchProcess(argv, base::LaunchOptions(), &handle))
33       base::EnsureProcessGetsReaped(handle);
34   }
35 }
36
37 }  // namespace platform_util