blob: 8824183362c3a302a59cf1c0858105021308737e [file] [log] [blame]
[email protected]7df1dad2012-02-27 11:19:511// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]14a000d2010-04-29 21:44:242// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/browser/platform_util.h"
6
[email protected]473c9a4f2013-09-05 03:09:467#include "chrome/browser/chromeos/file_manager/open_util.h"
[email protected]4e8b38a2012-05-24 20:48:048#include "chrome/browser/ui/browser_navigator.h"
[email protected]c38831a12011-10-28 12:44:499#include "content/public/browser/browser_thread.h"
[email protected]761fa4702013-07-02 15:25:1510#include "url/gurl.h"
[email protected]14a000d2010-04-29 21:44:2411
[email protected]631bb742011-11-02 11:29:3912using content::BrowserThread;
13
[email protected]7c3228a2011-11-11 21:35:2214namespace {
[email protected]14a000d2010-04-29 21:44:2415
[email protected]7c3228a2011-11-11 21:35:2216const char kGmailComposeUrl[] =
[email protected]8ef47722010-05-13 23:43:4517 "https://mail.google.com/mail/?extsrc=mailto&url=";
18
[email protected]7c3228a2011-11-11 21:35:2219} // namespace
20
21namespace platform_util {
22
[email protected]650b2d52013-02-10 03:41:4523void ShowItemInFolder(const base::FilePath& full_path) {
[email protected]7c3228a2011-11-11 21:35:2224 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
[email protected]42cee6522013-08-22 08:42:1925 file_manager::util::ShowItemInFolder(full_path);
[email protected]7c3228a2011-11-11 21:35:2226}
27
[email protected]650b2d52013-02-10 03:41:4528void OpenItem(const base::FilePath& full_path) {
[email protected]7c3228a2011-11-11 21:35:2229 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
[email protected]42cee6522013-08-22 08:42:1930 file_manager::util::OpenItem(full_path);
[email protected]7c3228a2011-11-11 21:35:2231}
32
[email protected]7f0a3efa2013-12-12 17:16:1233void OpenExternal(Profile* profile, const GURL& url) {
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
35
[email protected]899dfca2012-05-08 16:47:4036 // This code should be obsolete since we have default handlers in ChromeOS
37 // which should handle this. However - there are two things which make it
38 // necessary to keep it in:
39 // a.) The user might have deleted the default handler in this session.
40 // In this case we would need to have this in place.
41 // b.) There are several code paths which are not clear if they would call
42 // this function directly and which would therefore break (e.g.
43 // "Browser::EmailPageLocation" (to name only one).
44 // As such we should keep this code here.
[email protected]7f0a3efa2013-12-12 17:16:1245 chrome::NavigateParams params(profile, url, content::PAGE_TRANSITION_LINK);
46 params.disposition = NEW_FOREGROUND_TAB;
47 params.host_desktop_type = chrome::HOST_DESKTOP_TYPE_ASH;
48
[email protected]8ef47722010-05-13 23:43:4549 if (url.SchemeIs("mailto")) {
50 std::string string_url = kGmailComposeUrl;
51 string_url.append(url.spec());
[email protected]7f0a3efa2013-12-12 17:16:1252 params.url = GURL(url);
[email protected]8ef47722010-05-13 23:43:4553 }
[email protected]7f0a3efa2013-12-12 17:16:1254
55 chrome::Navigate(&params);
[email protected]14a000d2010-04-29 21:44:2456}
57
58} // namespace platform_util