[email protected] | 7df1dad | 2012-02-27 11:19:51 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 14a000d | 2010-04-29 21:44:24 | [diff] [blame] | 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 "chrome/browser/platform_util.h" | ||||
6 | |||||
[email protected] | 473c9a4f | 2013-09-05 03:09:46 | [diff] [blame] | 7 | #include "chrome/browser/chromeos/file_manager/open_util.h" |
[email protected] | 4e8b38a | 2012-05-24 20:48:04 | [diff] [blame] | 8 | #include "chrome/browser/ui/browser_navigator.h" |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 9 | #include "content/public/browser/browser_thread.h" |
[email protected] | 761fa470 | 2013-07-02 15:25:15 | [diff] [blame] | 10 | #include "url/gurl.h" |
[email protected] | 14a000d | 2010-04-29 21:44:24 | [diff] [blame] | 11 | |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 12 | using content::BrowserThread; |
13 | |||||
[email protected] | 7c3228a | 2011-11-11 21:35:22 | [diff] [blame] | 14 | namespace { |
[email protected] | 14a000d | 2010-04-29 21:44:24 | [diff] [blame] | 15 | |
[email protected] | 7c3228a | 2011-11-11 21:35:22 | [diff] [blame] | 16 | const char kGmailComposeUrl[] = |
[email protected] | 8ef4772 | 2010-05-13 23:43:45 | [diff] [blame] | 17 | "https://mail.google.com/mail/?extsrc=mailto&url="; |
18 | |||||
[email protected] | 7c3228a | 2011-11-11 21:35:22 | [diff] [blame] | 19 | } // namespace |
20 | |||||
21 | namespace platform_util { | ||||
22 | |||||
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 23 | void ShowItemInFolder(const base::FilePath& full_path) { |
[email protected] | 7c3228a | 2011-11-11 21:35:22 | [diff] [blame] | 24 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
[email protected] | 42cee652 | 2013-08-22 08:42:19 | [diff] [blame] | 25 | file_manager::util::ShowItemInFolder(full_path); |
[email protected] | 7c3228a | 2011-11-11 21:35:22 | [diff] [blame] | 26 | } |
27 | |||||
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 28 | void OpenItem(const base::FilePath& full_path) { |
[email protected] | 7c3228a | 2011-11-11 21:35:22 | [diff] [blame] | 29 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
[email protected] | 42cee652 | 2013-08-22 08:42:19 | [diff] [blame] | 30 | file_manager::util::OpenItem(full_path); |
[email protected] | 7c3228a | 2011-11-11 21:35:22 | [diff] [blame] | 31 | } |
32 | |||||
[email protected] | 7f0a3efa | 2013-12-12 17:16:12 | [diff] [blame^] | 33 | void OpenExternal(Profile* profile, const GURL& url) { |
34 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | ||||
35 | |||||
[email protected] | 899dfca | 2012-05-08 16:47:40 | [diff] [blame] | 36 | // 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] | 7f0a3efa | 2013-12-12 17:16:12 | [diff] [blame^] | 45 | 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] | 8ef4772 | 2010-05-13 23:43:45 | [diff] [blame] | 49 | if (url.SchemeIs("mailto")) { |
50 | std::string string_url = kGmailComposeUrl; | ||||
51 | string_url.append(url.spec()); | ||||
[email protected] | 7f0a3efa | 2013-12-12 17:16:12 | [diff] [blame^] | 52 | params.url = GURL(url); |
[email protected] | 8ef4772 | 2010-05-13 23:43:45 | [diff] [blame] | 53 | } |
[email protected] | 7f0a3efa | 2013-12-12 17:16:12 | [diff] [blame^] | 54 | |
55 | chrome::Navigate(¶ms); | ||||
[email protected] | 14a000d | 2010-04-29 21:44:24 | [diff] [blame] | 56 | } |
57 | |||||
58 | } // namespace platform_util |