OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/platform_util.h" | 5 #include "chrome/browser/platform_util.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 11 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
13 #include "chrome/browser/ui/browser_finder.h" | 13 #include "chrome/browser/ui/browser_finder.h" |
14 #include "chrome/browser/ui/browser_navigator.h" | 14 #include "chrome/browser/ui/browser_navigator.h" |
| 15 #include "chrome/browser/ui/host_desktop.h" |
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
18 | 19 |
19 using content::BrowserThread; | 20 using content::BrowserThread; |
20 | 21 |
21 class Profile; | 22 class Profile; |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 const char kGmailComposeUrl[] = | 26 const char kGmailComposeUrl[] = |
26 "https://mail.google.com/mail/?extsrc=mailto&url="; | 27 "https://mail.google.com/mail/?extsrc=mailto&url="; |
27 | 28 |
28 void OpenItemOnFileThread(const FilePath& full_path) { | 29 void OpenItemOnFileThread(const FilePath& full_path) { |
29 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 30 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
30 base::Closure callback; | 31 base::Closure callback; |
31 if (file_util::DirectoryExists(full_path)) | 32 if (file_util::DirectoryExists(full_path)) |
32 callback = base::Bind(&file_manager_util::ViewFolder, full_path); | 33 callback = base::Bind(&file_manager_util::ViewFolder, full_path); |
33 else | 34 else |
34 callback = base::Bind(&file_manager_util::ViewFile, full_path); | 35 callback = base::Bind(&file_manager_util::ViewFile, full_path); |
35 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); | 36 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback); |
36 } | 37 } |
37 | 38 |
38 void OpenURL(const std::string& url) { | 39 void OpenURL(const std::string& url) { |
39 // TODO(beng): improve this to locate context from call stack. | 40 // TODO(beng): improve this to locate context from call stack. |
40 Browser* browser = browser::FindOrCreateTabbedBrowser( | 41 Browser* browser = browser::FindOrCreateTabbedBrowser( |
41 ProfileManager::GetDefaultProfileOrOffTheRecord()); | 42 ProfileManager::GetDefaultProfileOrOffTheRecord(), |
| 43 chrome::HOST_DESKTOP_TYPE_ASH); |
42 chrome::NavigateParams params( | 44 chrome::NavigateParams params( |
43 browser, GURL(url), content::PAGE_TRANSITION_LINK); | 45 browser, GURL(url), content::PAGE_TRANSITION_LINK); |
44 params.disposition = NEW_FOREGROUND_TAB; | 46 params.disposition = NEW_FOREGROUND_TAB; |
45 chrome::Navigate(¶ms); | 47 chrome::Navigate(¶ms); |
46 } | 48 } |
47 | 49 |
48 } // namespace | 50 } // namespace |
49 | 51 |
50 namespace platform_util { | 52 namespace platform_util { |
51 | 53 |
(...skipping 20 matching lines...) Expand all Loading... |
72 // As such we should keep this code here. | 74 // As such we should keep this code here. |
73 if (url.SchemeIs("mailto")) { | 75 if (url.SchemeIs("mailto")) { |
74 std::string string_url = kGmailComposeUrl; | 76 std::string string_url = kGmailComposeUrl; |
75 string_url.append(url.spec()); | 77 string_url.append(url.spec()); |
76 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 78 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
77 base::Bind(OpenURL, string_url)); | 79 base::Bind(OpenURL, string_url)); |
78 } | 80 } |
79 } | 81 } |
80 | 82 |
81 } // namespace platform_util | 83 } // namespace platform_util |
OLD | NEW |