| 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/chromeos/extensions/file_browser_private_api.h" | 13 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
| 14 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 14 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
| 15 #include "chrome/browser/extensions/extension_host.h" | 15 #include "chrome/browser/extensions/extension_host.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 16 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/sessions/restore_tab_helper.h" | 17 #include "chrome/browser/sessions/restore_tab_helper.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
| 20 #include "chrome/browser/ui/browser_list.h" | 20 #include "chrome/browser/ui/browser_list.h" |
| 21 #include "chrome/browser/ui/browser_window.h" | 21 #include "chrome/browser/ui/browser_window.h" |
| 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 22 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 23 #include "chrome/browser/ui/views/extensions/extension_dialog.h" | 23 #include "chrome/browser/ui/views/extensions/extension_dialog.h" |
| 24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/common/selected_file_info.h" | 25 #include "content/public/common/selected_file_info.h" |
| 26 | 26 |
| 27 using content::BrowserThread; | 27 using content::BrowserThread; |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 const int kFileManagerWidth = 954; // pixels | 31 const int kFileManagerWidth = 954; // pixels |
| 32 const int kFileManagerHeight = 640; // pixels | 32 const int kFileManagerHeight = 640; // pixels |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 248 } |
| 249 // Extension background pages may not supply an owner_window. | 249 // Extension background pages may not supply an owner_window. |
| 250 owner_browser_ = (owner_window ? | 250 owner_browser_ = (owner_window ? |
| 251 browser::FindBrowserWithWindow(owner_window) : | 251 browser::FindBrowserWithWindow(owner_window) : |
| 252 BrowserList::GetLastActive()); | 252 BrowserList::GetLastActive()); |
| 253 if (!owner_browser_) { | 253 if (!owner_browser_) { |
| 254 NOTREACHED() << "Can't find owning browser"; | 254 NOTREACHED() << "Can't find owning browser"; |
| 255 return; | 255 return; |
| 256 } | 256 } |
| 257 | 257 |
| 258 TabContentsWrapper* tab = owner_browser_->GetSelectedTabContentsWrapper(); | 258 TabContents* tab = owner_browser_->GetActiveTabContents(); |
| 259 | 259 |
| 260 // Check if we have another dialog opened in the tab. It's unlikely, but | 260 // Check if we have another dialog opened in the tab. It's unlikely, but |
| 261 // possible. | 261 // possible. |
| 262 int32 tab_id = tab ? tab->restore_tab_helper()->session_id().id() : 0; | 262 int32 tab_id = tab ? tab->restore_tab_helper()->session_id().id() : 0; |
| 263 if (PendingExists(tab_id)) { | 263 if (PendingExists(tab_id)) { |
| 264 DLOG(WARNING) << "Pending dialog exists with id " << tab_id; | 264 DLOG(WARNING) << "Pending dialog exists with id " << tab_id; |
| 265 return; | 265 return; |
| 266 } | 266 } |
| 267 | 267 |
| 268 FilePath virtual_path; | 268 FilePath virtual_path; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 294 } | 294 } |
| 295 | 295 |
| 296 // Connect our listener to FileDialogFunction's per-tab callbacks. | 296 // Connect our listener to FileDialogFunction's per-tab callbacks. |
| 297 AddPending(tab_id); | 297 AddPending(tab_id); |
| 298 | 298 |
| 299 extension_dialog_ = dialog; | 299 extension_dialog_ = dialog; |
| 300 params_ = params; | 300 params_ = params; |
| 301 tab_id_ = tab_id; | 301 tab_id_ = tab_id; |
| 302 owner_window_ = owner_window; | 302 owner_window_ = owner_window; |
| 303 } | 303 } |
| OLD | NEW |