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" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "chrome/browser/chromeos/extensions/file_handler_util.h" | 16 #include "chrome/browser/chromeos/extensions/file_handler_util.h" |
17 #include "chrome/browser/chromeos/gdata/gdata.pb.h" | 17 #include "chrome/browser/chromeos/gdata/gdata.pb.h" |
18 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" | 18 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" |
19 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 19 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
20 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 20 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
21 #include "chrome/browser/chromeos/media/media_player.h" | 21 #include "chrome/browser/chromeos/media/media_player.h" |
22 #include "chrome/browser/extensions/crx_installer.h" | 22 #include "chrome/browser/extensions/crx_installer.h" |
23 #include "chrome/browser/extensions/extension_install_prompt.h" | 23 #include "chrome/browser/extensions/extension_install_prompt.h" |
24 #include "chrome/browser/extensions/extension_service.h" | 24 #include "chrome/browser/extensions/extension_service.h" |
25 #include "chrome/browser/plugin_prefs.h" | 25 #include "chrome/browser/plugin_prefs.h" |
26 #include "chrome/browser/profiles/profile.h" | 26 #include "chrome/browser/profiles/profile.h" |
27 #include "chrome/browser/profiles/profile_manager.h" | 27 #include "chrome/browser/profiles/profile_manager.h" |
28 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
29 #include "chrome/browser/ui/browser_finder.h" | 29 #include "chrome/browser/ui/browser_finder.h" |
| 30 #include "chrome/browser/ui/browser_tabstrip.h" |
30 #include "chrome/browser/ui/browser_window.h" | 31 #include "chrome/browser/ui/browser_window.h" |
31 #include "chrome/browser/ui/extensions/application_launch.h" | 32 #include "chrome/browser/ui/extensions/application_launch.h" |
32 #include "chrome/browser/ui/simple_message_box.h" | 33 #include "chrome/browser/ui/simple_message_box.h" |
33 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 34 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
34 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
35 #include "chrome/common/chrome_paths.h" | 36 #include "chrome/common/chrome_paths.h" |
36 #include "chrome/common/extensions/file_browser_handler.h" | 37 #include "chrome/common/extensions/file_browser_handler.h" |
37 #include "chrome/common/url_constants.h" | 38 #include "chrome/common/url_constants.h" |
38 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
39 #include "content/public/browser/plugin_service.h" | 40 #include "content/public/browser/plugin_service.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 GDataOperationRegistry::OperationTypeToString(status.operation_type)); | 196 GDataOperationRegistry::OperationTypeToString(status.operation_type)); |
196 result->SetInteger("processed", static_cast<int>(status.progress_current)); | 197 result->SetInteger("processed", static_cast<int>(status.progress_current)); |
197 result->SetInteger("total", static_cast<int>(status.progress_total)); | 198 result->SetInteger("total", static_cast<int>(status.progress_total)); |
198 return result.release(); | 199 return result.release(); |
199 } | 200 } |
200 | 201 |
201 void OpenNewTab(const GURL& url, Profile* profile) { | 202 void OpenNewTab(const GURL& url, Profile* profile) { |
202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
203 Browser* browser = browser::FindOrCreateTabbedBrowser( | 204 Browser* browser = browser::FindOrCreateTabbedBrowser( |
204 profile ? profile : ProfileManager::GetDefaultProfileOrOffTheRecord()); | 205 profile ? profile : ProfileManager::GetDefaultProfileOrOffTheRecord()); |
205 browser->AddSelectedTabWithURL(url, content::PAGE_TRANSITION_LINK); | 206 chrome::AddSelectedTabWithURL(browser, url, content::PAGE_TRANSITION_LINK); |
206 // If the current browser is not tabbed then the new tab will be created | 207 // If the current browser is not tabbed then the new tab will be created |
207 // in a different browser. Make sure it is visible. | 208 // in a different browser. Make sure it is visible. |
208 browser->window()->Show(); | 209 browser->window()->Show(); |
209 } | 210 } |
210 | 211 |
211 // Shows a warning message box saying that the file could not be opened. | 212 // Shows a warning message box saying that the file could not be opened. |
212 void ShowWarningMessageBox(Profile* profile, const FilePath& path) { | 213 void ShowWarningMessageBox(Profile* profile, const FilePath& path) { |
213 // TODO: if FindOrCreateTabbedBrowser creates a new browser the returned | 214 // TODO: if FindOrCreateTabbedBrowser creates a new browser the returned |
214 // browser is leaked. | 215 // browser is leaked. |
215 Browser* browser = browser::FindOrCreateTabbedBrowser(profile); | 216 Browser* browser = browser::FindOrCreateTabbedBrowser(profile); |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
702 GDataOperationRegistry::ProgressStatus>::const_iterator iter = | 703 GDataOperationRegistry::ProgressStatus>::const_iterator iter = |
703 list.begin(); | 704 list.begin(); |
704 iter != list.end(); ++iter) { | 705 iter != list.end(); ++iter) { |
705 result_list->Append( | 706 result_list->Append( |
706 ProgessStatusToDictionaryValue(profile, origin_url, *iter)); | 707 ProgessStatusToDictionaryValue(profile, origin_url, *iter)); |
707 } | 708 } |
708 return result_list.release(); | 709 return result_list.release(); |
709 } | 710 } |
710 | 711 |
711 } // namespace file_manager_util | 712 } // namespace file_manager_util |
OLD | NEW |