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 "apps/shell_window.h" | 7 #include "apps/app_window.h" |
8 #include "apps/shell_window_registry.h" | 8 #include "apps/app_window_registry.h" |
9 #include "apps/ui/native_app_window.h" | 9 #include "apps/ui/native_app_window.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "chrome/browser/chromeos/file_manager/app_id.h" | 16 #include "chrome/browser/chromeos/file_manager/app_id.h" |
17 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 17 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
18 #include "chrome/browser/chromeos/file_manager/select_file_dialog_util.h" | 18 #include "chrome/browser/chromeos/file_manager/select_file_dialog_util.h" |
(...skipping 10 matching lines...) Expand all Loading... |
29 #include "chrome/browser/ui/host_desktop.h" | 29 #include "chrome/browser/ui/host_desktop.h" |
30 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 30 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
31 #include "chrome/browser/ui/views/extensions/extension_dialog.h" | 31 #include "chrome/browser/ui/views/extensions/extension_dialog.h" |
32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
33 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
34 #include "extensions/browser/extension_system.h" | 34 #include "extensions/browser/extension_system.h" |
35 #include "ui/base/base_window.h" | 35 #include "ui/base/base_window.h" |
36 #include "ui/shell_dialogs/selected_file_info.h" | 36 #include "ui/shell_dialogs/selected_file_info.h" |
37 #include "ui/views/widget/widget.h" | 37 #include "ui/views/widget/widget.h" |
38 | 38 |
39 using apps::ShellWindow; | 39 using apps::AppWindow; |
40 using content::BrowserThread; | 40 using content::BrowserThread; |
41 | 41 |
42 namespace { | 42 namespace { |
43 | 43 |
44 const int kFileManagerWidth = 972; // pixels | 44 const int kFileManagerWidth = 972; // pixels |
45 const int kFileManagerHeight = 640; // pixels | 45 const int kFileManagerHeight = 640; // pixels |
46 const int kFileManagerMinimumWidth = 320; // pixels | 46 const int kFileManagerMinimumWidth = 320; // pixels |
47 const int kFileManagerMinimumHeight = 240; // pixels | 47 const int kFileManagerMinimumHeight = 240; // pixels |
48 | 48 |
49 // Holds references to file manager dialogs that have callbacks pending | 49 // Holds references to file manager dialogs that have callbacks pending |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 LOG(ERROR) << "File dialog already in use!"; | 271 LOG(ERROR) << "File dialog already in use!"; |
272 return; | 272 return; |
273 } | 273 } |
274 | 274 |
275 // The base window to associate the dialog with. | 275 // The base window to associate the dialog with. |
276 ui::BaseWindow* base_window = NULL; | 276 ui::BaseWindow* base_window = NULL; |
277 | 277 |
278 // The web contents to associate the dialog with. | 278 // The web contents to associate the dialog with. |
279 content::WebContents* web_contents = NULL; | 279 content::WebContents* web_contents = NULL; |
280 | 280 |
281 // To get the base_window and profile, either a Browser or ShellWindow is | 281 // To get the base_window and profile, either a Browser or AppWindow is |
282 // needed. | 282 // needed. |
283 Browser* owner_browser = NULL; | 283 Browser* owner_browser = NULL; |
284 ShellWindow* shell_window = NULL; | 284 AppWindow* app_window = NULL; |
285 | 285 |
286 // If owner_window is supplied, use that to find a browser or a shell window. | 286 // If owner_window is supplied, use that to find a browser or a app window. |
287 if (owner_window) { | 287 if (owner_window) { |
288 owner_browser = chrome::FindBrowserWithWindow(owner_window); | 288 owner_browser = chrome::FindBrowserWithWindow(owner_window); |
289 if (!owner_browser) { | 289 if (!owner_browser) { |
290 // If an owner_window was supplied but we couldn't find a browser, this | 290 // If an owner_window was supplied but we couldn't find a browser, this |
291 // could be for a shell window. | 291 // could be for a app window. |
292 shell_window = apps::ShellWindowRegistry:: | 292 app_window = |
293 GetShellWindowForNativeWindowAnyProfile(owner_window); | 293 apps::AppWindowRegistry::GetAppWindowForNativeWindowAnyProfile( |
| 294 owner_window); |
294 } | 295 } |
295 } | 296 } |
296 | 297 |
297 if (shell_window) { | 298 if (app_window) { |
298 DCHECK(!shell_window->window_type_is_panel()); | 299 DCHECK(!app_window->window_type_is_panel()); |
299 base_window = shell_window->GetBaseWindow(); | 300 base_window = app_window->GetBaseWindow(); |
300 web_contents = shell_window->web_contents(); | 301 web_contents = app_window->web_contents(); |
301 } else { | 302 } else { |
302 // If the owning window is still unknown, this could be a background page or | 303 // If the owning window is still unknown, this could be a background page or |
303 // and extension popup. Use the last active browser. | 304 // and extension popup. Use the last active browser. |
304 if (!owner_browser) { | 305 if (!owner_browser) { |
305 owner_browser = | 306 owner_browser = |
306 chrome::FindLastActiveWithHostDesktopType(chrome::GetActiveDesktop()); | 307 chrome::FindLastActiveWithHostDesktopType(chrome::GetActiveDesktop()); |
307 } | 308 } |
308 DCHECK(owner_browser); | 309 DCHECK(owner_browser); |
309 base_window = owner_browser->window(); | 310 base_window = owner_browser->window(); |
310 web_contents = owner_browser->tab_strip_model()->GetActiveWebContents(); | 311 web_contents = owner_browser->tab_strip_model()->GetActiveWebContents(); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 } | 404 } |
404 | 405 |
405 // Connect our listener to FileDialogFunction's per-tab callbacks. | 406 // Connect our listener to FileDialogFunction's per-tab callbacks. |
406 AddPending(routing_id); | 407 AddPending(routing_id); |
407 | 408 |
408 extension_dialog_ = dialog; | 409 extension_dialog_ = dialog; |
409 params_ = params; | 410 params_ = params; |
410 routing_id_ = routing_id; | 411 routing_id_ = routing_id; |
411 owner_window_ = owner_window; | 412 owner_window_ = owner_window; |
412 } | 413 } |
OLD | NEW |