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 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 4 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
5 | 5 |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/extensions/extension_service.h" | 25 #include "chrome/browser/extensions/extension_service.h" |
26 #include "chrome/browser/plugins/plugin_prefs.h" | 26 #include "chrome/browser/plugins/plugin_prefs.h" |
27 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
28 #include "chrome/browser/profiles/profile_manager.h" | 28 #include "chrome/browser/profiles/profile_manager.h" |
29 #include "chrome/browser/ui/browser.h" | 29 #include "chrome/browser/ui/browser.h" |
30 #include "chrome/browser/ui/browser_finder.h" | 30 #include "chrome/browser/ui/browser_finder.h" |
31 #include "chrome/browser/ui/browser_list.h" | 31 #include "chrome/browser/ui/browser_list.h" |
32 #include "chrome/browser/ui/browser_tabstrip.h" | 32 #include "chrome/browser/ui/browser_tabstrip.h" |
33 #include "chrome/browser/ui/browser_window.h" | 33 #include "chrome/browser/ui/browser_window.h" |
34 #include "chrome/browser/ui/extensions/application_launch.h" | 34 #include "chrome/browser/ui/extensions/application_launch.h" |
| 35 #include "chrome/browser/ui/host_desktop.h" |
35 #include "chrome/browser/ui/simple_message_box.h" | 36 #include "chrome/browser/ui/simple_message_box.h" |
36 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 37 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
37 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 38 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
38 #include "chrome/common/chrome_paths.h" | 39 #include "chrome/common/chrome_paths.h" |
39 #include "chrome/common/extensions/file_browser_handler.h" | 40 #include "chrome/common/extensions/file_browser_handler.h" |
40 #include "chrome/common/url_constants.h" | 41 #include "chrome/common/url_constants.h" |
41 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
42 #include "content/public/browser/plugin_service.h" | 43 #include "content/public/browser/plugin_service.h" |
43 #include "content/public/browser/storage_partition.h" | 44 #include "content/public/browser/storage_partition.h" |
44 #include "content/public/browser/user_metrics.h" | 45 #include "content/public/browser/user_metrics.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 result->SetString("transferType", | 200 result->SetString("transferType", |
200 OperationTypeToString(status.operation_type)); | 201 OperationTypeToString(status.operation_type)); |
201 result->SetInteger("processed", static_cast<int>(status.progress_current)); | 202 result->SetInteger("processed", static_cast<int>(status.progress_current)); |
202 result->SetInteger("total", static_cast<int>(status.progress_total)); | 203 result->SetInteger("total", static_cast<int>(status.progress_total)); |
203 return result.release(); | 204 return result.release(); |
204 } | 205 } |
205 | 206 |
206 void OpenNewTab(const GURL& url, Profile* profile) { | 207 void OpenNewTab(const GURL& url, Profile* profile) { |
207 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 208 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
208 Browser* browser = browser::FindOrCreateTabbedBrowser( | 209 Browser* browser = browser::FindOrCreateTabbedBrowser( |
209 profile ? profile : ProfileManager::GetDefaultProfileOrOffTheRecord()); | 210 profile ? profile : ProfileManager::GetDefaultProfileOrOffTheRecord(), |
| 211 chrome::HOST_DESKTOP_TYPE_ASH); |
210 chrome::AddSelectedTabWithURL(browser, url, content::PAGE_TRANSITION_LINK); | 212 chrome::AddSelectedTabWithURL(browser, url, content::PAGE_TRANSITION_LINK); |
211 // If the current browser is not tabbed then the new tab will be created | 213 // If the current browser is not tabbed then the new tab will be created |
212 // in a different browser. Make sure it is visible. | 214 // in a different browser. Make sure it is visible. |
213 browser->window()->Show(); | 215 browser->window()->Show(); |
214 } | 216 } |
215 | 217 |
216 // Shows a warning message box saying that the file could not be opened. | 218 // Shows a warning message box saying that the file could not be opened. |
217 void ShowWarningMessageBox(Profile* profile, const FilePath& path) { | 219 void ShowWarningMessageBox(Profile* profile, const FilePath& path) { |
218 // TODO: if FindOrCreateTabbedBrowser creates a new browser the returned | 220 // TODO: if FindOrCreateTabbedBrowser creates a new browser the returned |
219 // browser is leaked. | 221 // browser is leaked. |
220 Browser* browser = browser::FindOrCreateTabbedBrowser(profile); | 222 Browser* browser = |
| 223 browser::FindOrCreateTabbedBrowser(profile, |
| 224 chrome::HOST_DESKTOP_TYPE_ASH); |
221 chrome::ShowMessageBox( | 225 chrome::ShowMessageBox( |
222 browser->window()->GetNativeWindow(), | 226 browser->window()->GetNativeWindow(), |
223 l10n_util::GetStringFUTF16( | 227 l10n_util::GetStringFUTF16( |
224 IDS_FILE_BROWSER_ERROR_VIEWING_FILE_TITLE, | 228 IDS_FILE_BROWSER_ERROR_VIEWING_FILE_TITLE, |
225 UTF8ToUTF16(path.BaseName().value())), | 229 UTF8ToUTF16(path.BaseName().value())), |
226 l10n_util::GetStringUTF16(IDS_FILE_BROWSER_ERROR_VIEWING_FILE), | 230 l10n_util::GetStringUTF16(IDS_FILE_BROWSER_ERROR_VIEWING_FILE), |
227 chrome::MESSAGE_BOX_TYPE_WARNING); | 231 chrome::MESSAGE_BOX_TYPE_WARNING); |
228 } | 232 } |
229 | 233 |
230 // Called when a file on Drive was found. Opens the file found at |file_path| | 234 // Called when a file on Drive was found. Opens the file found at |file_path| |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 scoped_ptr<ListValue> result_list(new ListValue()); | 810 scoped_ptr<ListValue> result_list(new ListValue()); |
807 for (gdata::OperationProgressStatusList::const_iterator iter = list.begin(); | 811 for (gdata::OperationProgressStatusList::const_iterator iter = list.begin(); |
808 iter != list.end(); ++iter) { | 812 iter != list.end(); ++iter) { |
809 result_list->Append( | 813 result_list->Append( |
810 ProgessStatusToDictionaryValue(profile, origin_url, *iter)); | 814 ProgessStatusToDictionaryValue(profile, origin_url, *iter)); |
811 } | 815 } |
812 return result_list.release(); | 816 return result_list.release(); |
813 } | 817 } |
814 | 818 |
815 } // namespace file_manager_util | 819 } // namespace file_manager_util |
OLD | NEW |