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/ui/views/select_file_dialog_extension.h" | 5 #include "chrome/browser/ui/views/select_file_dialog_extension.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/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" | 14 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
15 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 15 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
16 #include "chrome/browser/extensions/extension_host.h" | 16 #include "chrome/browser/extensions/extension_host.h" |
17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
18 #include "chrome/browser/extensions/shell_window_registry.h" | 18 #include "chrome/browser/extensions/shell_window_registry.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/sessions/restore_tab_helper.h" | 20 #include "chrome/browser/sessions/restore_tab_helper.h" |
21 #include "chrome/browser/ui/base_window.h" | 21 #include "chrome/browser/ui/base_window.h" |
22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
23 #include "chrome/browser/ui/browser_finder.h" | 23 #include "chrome/browser/ui/browser_finder.h" |
24 #include "chrome/browser/ui/browser_list.h" | 24 #include "chrome/browser/ui/browser_list.h" |
| 25 #include "chrome/browser/ui/browser_tabstrip.h" |
25 #include "chrome/browser/ui/browser_window.h" | 26 #include "chrome/browser/ui/browser_window.h" |
26 #include "chrome/browser/ui/extensions/shell_window.h" | 27 #include "chrome/browser/ui/extensions/shell_window.h" |
27 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 28 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
28 #include "chrome/browser/ui/views/extensions/extension_dialog.h" | 29 #include "chrome/browser/ui/views/extensions/extension_dialog.h" |
29 #include "content/public/browser/browser_thread.h" | 30 #include "content/public/browser/browser_thread.h" |
30 #include "ui/base/dialogs/selected_file_info.h" | 31 #include "ui/base/dialogs/selected_file_info.h" |
31 | 32 |
32 using content::BrowserThread; | 33 using content::BrowserThread; |
33 | 34 |
34 namespace { | 35 namespace { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 const TabContents* tab = NULL; | 260 const TabContents* tab = NULL; |
260 | 261 |
261 // First try to find a Browser using the supplied owner_window. If no owner | 262 // First try to find a Browser using the supplied owner_window. If no owner |
262 // window has been supplied, this is running from a background page and should | 263 // window has been supplied, this is running from a background page and should |
263 // be associated with the last active browser. | 264 // be associated with the last active browser. |
264 Browser* owner_browser = (owner_window ? | 265 Browser* owner_browser = (owner_window ? |
265 browser::FindBrowserWithWindow(owner_window) : | 266 browser::FindBrowserWithWindow(owner_window) : |
266 BrowserList::GetLastActive()); | 267 BrowserList::GetLastActive()); |
267 if (owner_browser) { | 268 if (owner_browser) { |
268 base_window = owner_browser->window(); | 269 base_window = owner_browser->window(); |
269 tab = owner_browser->GetActiveTabContents(); | 270 tab = chrome::GetActiveTabContents(owner_browser); |
270 profile_ = tab->profile(); | 271 profile_ = tab->profile(); |
271 } else if (owner_window) { | 272 } else if (owner_window) { |
272 // If an owner_window was supplied but we couldn't find a browser, this | 273 // If an owner_window was supplied but we couldn't find a browser, this |
273 // could be for a shell window. | 274 // could be for a shell window. |
274 // TODO(benwells): Find a better way to get a shell window from a native | 275 // TODO(benwells): Find a better way to get a shell window from a native |
275 // window. | 276 // window. |
276 std::vector<Profile*> profiles = | 277 std::vector<Profile*> profiles = |
277 g_browser_process->profile_manager()->GetLoadedProfiles(); | 278 g_browser_process->profile_manager()->GetLoadedProfiles(); |
278 for (std::vector<Profile*>::const_iterator i(profiles.begin()); | 279 for (std::vector<Profile*>::const_iterator i(profiles.begin()); |
279 i < profiles.end(); ++i) { | 280 i < profiles.end(); ++i) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 } | 336 } |
336 | 337 |
337 // Connect our listener to FileDialogFunction's per-tab callbacks. | 338 // Connect our listener to FileDialogFunction's per-tab callbacks. |
338 AddPending(tab_id); | 339 AddPending(tab_id); |
339 | 340 |
340 extension_dialog_ = dialog; | 341 extension_dialog_ = dialog; |
341 params_ = params; | 342 params_ = params; |
342 tab_id_ = tab_id; | 343 tab_id_ = tab_id; |
343 owner_window_ = owner_window; | 344 owner_window_ = owner_window; |
344 } | 345 } |
OLD | NEW |