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 "ash/shell.h" | 6 #include "ash/shell.h" |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/extensions/crx_installer.h" | 25 #include "chrome/browser/extensions/crx_installer.h" |
26 #include "chrome/browser/extensions/extension_install_prompt.h" | 26 #include "chrome/browser/extensions/extension_install_prompt.h" |
27 #include "chrome/browser/extensions/extension_service.h" | 27 #include "chrome/browser/extensions/extension_service.h" |
28 #include "chrome/browser/extensions/extension_system.h" | 28 #include "chrome/browser/extensions/extension_system.h" |
29 #include "chrome/browser/google_apis/task_util.h" | 29 #include "chrome/browser/google_apis/task_util.h" |
30 #include "chrome/browser/plugins/plugin_prefs.h" | 30 #include "chrome/browser/plugins/plugin_prefs.h" |
31 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
32 #include "chrome/browser/profiles/profile_manager.h" | 32 #include "chrome/browser/profiles/profile_manager.h" |
33 #include "chrome/browser/ui/browser.h" | 33 #include "chrome/browser/ui/browser.h" |
34 #include "chrome/browser/ui/browser_finder.h" | 34 #include "chrome/browser/ui/browser_finder.h" |
35 #include "chrome/browser/ui/browser_list.h" | 35 #include "chrome/browser/ui/browser_iterator.h" |
36 #include "chrome/browser/ui/browser_tabstrip.h" | 36 #include "chrome/browser/ui/browser_tabstrip.h" |
37 #include "chrome/browser/ui/browser_window.h" | 37 #include "chrome/browser/ui/browser_window.h" |
38 #include "chrome/browser/ui/extensions/application_launch.h" | 38 #include "chrome/browser/ui/extensions/application_launch.h" |
39 #include "chrome/browser/ui/host_desktop.h" | 39 #include "chrome/browser/ui/host_desktop.h" |
40 #include "chrome/browser/ui/simple_message_box.h" | 40 #include "chrome/browser/ui/simple_message_box.h" |
41 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 41 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
42 #include "chrome/common/chrome_paths.h" | 42 #include "chrome/common/chrome_paths.h" |
43 #include "chrome/common/chrome_switches.h" | 43 #include "chrome/common/chrome_switches.h" |
44 #include "chrome/common/url_constants.h" | 44 #include "chrome/common/url_constants.h" |
45 #include "content/public/browser/browser_thread.h" | 45 #include "content/public/browser/browser_thread.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 303 |
304 bool FileManageTabExists(const base::FilePath& path, TAB_REUSE_MODE mode) { | 304 bool FileManageTabExists(const base::FilePath& path, TAB_REUSE_MODE mode) { |
305 if (mode == REUSE_NEVER) | 305 if (mode == REUSE_NEVER) |
306 return false; | 306 return false; |
307 | 307 |
308 // We always open full-tab File Manager via chrome://files URL, never | 308 // We always open full-tab File Manager via chrome://files URL, never |
309 // chrome-extension://, so we only check against chrome://files | 309 // chrome-extension://, so we only check against chrome://files |
310 const GURL origin(chrome::kChromeUIFileManagerURL); | 310 const GURL origin(chrome::kChromeUIFileManagerURL); |
311 const std::string ref = std::string("/") + path.value(); | 311 const std::string ref = std::string("/") + path.value(); |
312 | 312 |
313 for (BrowserList::const_iterator browser_iterator = BrowserList::begin(); | 313 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
314 browser_iterator != BrowserList::end(); ++browser_iterator) { | 314 Browser* browser = *it; |
315 Browser* browser = *browser_iterator; | |
316 TabStripModel* tab_strip = browser->tab_strip_model(); | 315 TabStripModel* tab_strip = browser->tab_strip_model(); |
317 for (int idx = 0; idx < tab_strip->count(); idx++) { | 316 for (int idx = 0; idx < tab_strip->count(); idx++) { |
318 content::WebContents* web_contents = tab_strip->GetWebContentsAt(idx); | 317 content::WebContents* web_contents = tab_strip->GetWebContentsAt(idx); |
319 const GURL& url = web_contents->GetURL(); | 318 const GURL& url = web_contents->GetURL(); |
320 if (origin == url.GetOrigin()) { | 319 if (origin == url.GetOrigin()) { |
321 if (mode == REUSE_ANY_FILE_MANAGER || ref == url.ref()) { | 320 if (mode == REUSE_ANY_FILE_MANAGER || ref == url.ref()) { |
322 if (mode == REUSE_SAME_PATH && tab_strip->active_index() != idx) { | 321 if (mode == REUSE_SAME_PATH && tab_strip->active_index() != idx) { |
323 browser->window()->Show(); | 322 browser->window()->Show(); |
324 tab_strip->ActivateTabAt(idx, false); | 323 tab_strip->ActivateTabAt(idx, false); |
325 } | 324 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 return; | 426 return; |
428 | 427 |
429 chrome::AppLaunchParams params(profile, extension, | 428 chrome::AppLaunchParams params(profile, extension, |
430 extension_misc::LAUNCH_WINDOW, | 429 extension_misc::LAUNCH_WINDOW, |
431 NEW_FOREGROUND_TAB); | 430 NEW_FOREGROUND_TAB); |
432 params.override_url = GURL(url); | 431 params.override_url = GURL(url); |
433 chrome::OpenApplication(params); | 432 chrome::OpenApplication(params); |
434 } | 433 } |
435 | 434 |
436 Browser* GetBrowserForUrl(GURL target_url) { | 435 Browser* GetBrowserForUrl(GURL target_url) { |
437 for (BrowserList::const_iterator browser_iterator = BrowserList::begin(); | 436 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
438 browser_iterator != BrowserList::end(); ++browser_iterator) { | 437 Browser* browser = *it; |
439 Browser* browser = *browser_iterator; | |
440 TabStripModel* tab_strip = browser->tab_strip_model(); | 438 TabStripModel* tab_strip = browser->tab_strip_model(); |
441 for (int idx = 0; idx < tab_strip->count(); idx++) { | 439 for (int idx = 0; idx < tab_strip->count(); idx++) { |
442 content::WebContents* web_contents = tab_strip->GetWebContentsAt(idx); | 440 content::WebContents* web_contents = tab_strip->GetWebContentsAt(idx); |
443 const GURL& url = web_contents->GetURL(); | 441 const GURL& url = web_contents->GetURL(); |
444 if (url == target_url) | 442 if (url == target_url) |
445 return browser; | 443 return browser; |
446 } | 444 } |
447 } | 445 } |
448 return NULL; | 446 return NULL; |
449 } | 447 } |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 for (google_apis::OperationProgressStatusList::const_iterator iter = | 943 for (google_apis::OperationProgressStatusList::const_iterator iter = |
946 list.begin(); | 944 list.begin(); |
947 iter != list.end(); ++iter) { | 945 iter != list.end(); ++iter) { |
948 result_list->Append( | 946 result_list->Append( |
949 ProgessStatusToDictionaryValue(profile, extension_id, *iter)); | 947 ProgessStatusToDictionaryValue(profile, extension_id, *iter)); |
950 } | 948 } |
951 return result_list.release(); | 949 return result_list.release(); |
952 } | 950 } |
953 | 951 |
954 } // namespace file_manager_util | 952 } // namespace file_manager_util |
OLD | NEW |