Add a minor text member to ui::MenuModel.
[chromium-blink-merge.git] / chrome / browser / platform_util_chromeos.cc
blob94e8ea75622b9569c41f0d66ee463870e6ae622d
1 // Copyright (c) 2012 The Chromium Authors. 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.
5 #include "chrome/browser/platform_util.h"
7 #include "base/bind.h"
8 #include "chrome/browser/chromeos/extensions/file_manager/open_util.h"
9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/ui/browser_finder.h"
11 #include "chrome/browser/ui/browser_navigator.h"
12 #include "chrome/browser/ui/host_desktop.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "content/public/browser/browser_thread.h"
15 #include "url/gurl.h"
17 using content::BrowserThread;
19 namespace {
21 const char kGmailComposeUrl[] =
22 "https://mail.google.com/mail/?extsrc=mailto&url=";
24 void OpenURL(const std::string& url) {
25 // TODO(beng): improve this to locate context from call stack.
26 Browser* browser = chrome::FindOrCreateTabbedBrowser(
27 ProfileManager::GetDefaultProfileOrOffTheRecord(),
28 chrome::HOST_DESKTOP_TYPE_ASH);
29 chrome::NavigateParams params(
30 browser, GURL(url), content::PAGE_TRANSITION_LINK);
31 params.disposition = NEW_FOREGROUND_TAB;
32 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
33 chrome::Navigate(&params);
36 } // namespace
38 namespace platform_util {
40 void ShowItemInFolder(const base::FilePath& full_path) {
41 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
42 file_manager::util::ShowItemInFolder(full_path);
45 void OpenItem(const base::FilePath& full_path) {
46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
47 file_manager::util::OpenItem(full_path);
50 void OpenExternal(const GURL& url) {
51 // This code should be obsolete since we have default handlers in ChromeOS
52 // which should handle this. However - there are two things which make it
53 // necessary to keep it in:
54 // a.) The user might have deleted the default handler in this session.
55 // In this case we would need to have this in place.
56 // b.) There are several code paths which are not clear if they would call
57 // this function directly and which would therefore break (e.g.
58 // "Browser::EmailPageLocation" (to name only one).
59 // As such we should keep this code here.
60 if (url.SchemeIs("mailto")) {
61 std::string string_url = kGmailComposeUrl;
62 string_url.append(url.spec());
63 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
64 base::Bind(OpenURL, string_url));
65 } else if (url.is_valid()) {
66 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
67 base::Bind(OpenURL, url.spec()));
71 } // namespace platform_util