OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/app_modal/chrome_javascript_native_dialog_factory.h" | 5 #include "chrome/browser/ui/app_modal/chrome_javascript_native_dialog_factory.h" |
6 | 6 |
7 #include "components/app_modal/javascript_dialog_manager.h" | 7 #include "components/app_modal/javascript_dialog_manager.h" |
8 #include "components/app_modal/javascript_native_dialog_factory.h" | 8 #include "components/app_modal/javascript_native_dialog_factory.h" |
9 #include "components/constrained_window/constrained_window_views.h" | 9 #include "components/constrained_window/constrained_window_views.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 private: | 50 private: |
51 app_modal::NativeAppModalDialog* CreateNativeJavaScriptDialog( | 51 app_modal::NativeAppModalDialog* CreateNativeJavaScriptDialog( |
52 app_modal::JavaScriptAppModalDialog* dialog) override { | 52 app_modal::JavaScriptAppModalDialog* dialog) override { |
53 app_modal::JavaScriptAppModalDialogViews* d = nullptr; | 53 app_modal::JavaScriptAppModalDialogViews* d = nullptr; |
54 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 54 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
55 d = new JavaScriptAppModalDialogViewsX11(dialog); | 55 d = new JavaScriptAppModalDialogViewsX11(dialog); |
56 #else | 56 #else |
57 d = new ChromeJavaScriptAppModalDialogViews(dialog); | 57 d = new ChromeJavaScriptAppModalDialogViews(dialog); |
58 #endif | 58 #endif |
59 | 59 |
| 60 // TODO(johnme): Can we sometimes be certain this was for a user gesture? |
60 dialog->web_contents()->GetDelegate()->ActivateContents( | 61 dialog->web_contents()->GetDelegate()->ActivateContents( |
61 dialog->web_contents()); | 62 dialog->web_contents(), false /* user_gesture */); |
62 gfx::NativeWindow parent_window = | 63 gfx::NativeWindow parent_window = |
63 dialog->web_contents()->GetTopLevelNativeWindow(); | 64 dialog->web_contents()->GetTopLevelNativeWindow(); |
64 #if defined(USE_AURA) | 65 #if defined(USE_AURA) |
65 if (!parent_window->GetRootWindow()) { | 66 if (!parent_window->GetRootWindow()) { |
66 // When we are part of a WebContents that isn't actually being displayed | 67 // When we are part of a WebContents that isn't actually being displayed |
67 // on the screen, we can't actually attach to it. | 68 // on the screen, we can't actually attach to it. |
68 parent_window = NULL; | 69 parent_window = NULL; |
69 } | 70 } |
70 #endif | 71 #endif |
71 constrained_window::CreateBrowserModalDialogViews(d, parent_window); | 72 constrained_window::CreateBrowserModalDialogViews(d, parent_window); |
72 return d; | 73 return d; |
73 } | 74 } |
74 | 75 |
75 DISALLOW_COPY_AND_ASSIGN(ChromeJavaScriptNativeDialogViewsFactory); | 76 DISALLOW_COPY_AND_ASSIGN(ChromeJavaScriptNativeDialogViewsFactory); |
76 }; | 77 }; |
77 | 78 |
78 } // namespace | 79 } // namespace |
79 | 80 |
80 void InstallChromeJavaScriptNativeDialogFactory() { | 81 void InstallChromeJavaScriptNativeDialogFactory() { |
81 app_modal::JavaScriptDialogManager::GetInstance()-> | 82 app_modal::JavaScriptDialogManager::GetInstance()-> |
82 SetNativeDialogFactory( | 83 SetNativeDialogFactory( |
83 make_scoped_ptr(new ChromeJavaScriptNativeDialogViewsFactory)); | 84 make_scoped_ptr(new ChromeJavaScriptNativeDialogViewsFactory)); |
84 } | 85 } |
OLD | NEW |