| 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/webui/constrained_web_dialog_delegate_base.h" | 5 #include "chrome/browser/ui/webui/constrained_web_dialog_delegate_base.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/browser_finder.h" | 8 #include "chrome/browser/ui/browser_finder.h" |
| 9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
| 10 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" | 10 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 ~WebDialogWebContentsDelegateViews() override {} | 34 ~WebDialogWebContentsDelegateViews() override {} |
| 35 | 35 |
| 36 // ui::WebDialogWebContentsDelegate: | 36 // ui::WebDialogWebContentsDelegate: |
| 37 void WebContentsFocused(content::WebContents* contents) override { | 37 void WebContentsFocused(content::WebContents* contents) override { |
| 38 // Ensure the WebView is focused when its WebContents is focused. | 38 // Ensure the WebView is focused when its WebContents is focused. |
| 39 web_view_->RequestFocus(); | 39 web_view_->RequestFocus(); |
| 40 } | 40 } |
| 41 void HandleKeyboardEvent( | 41 void HandleKeyboardEvent( |
| 42 content::WebContents* source, | 42 content::WebContents* source, |
| 43 const content::NativeWebKeyboardEvent& event) override { | 43 const content::NativeWebKeyboardEvent& event) override { |
| 44 // Forward shortcut keys in dialog to the browser. http://crbug.com/104586 | 44 // Forward shortcut keys in dialog to our initiator's delegate. |
| 45 // http://crbug.com/104586 |
| 45 // Disabled on Mac due to http://crbug.com/112173 | 46 // Disabled on Mac due to http://crbug.com/112173 |
| 46 #if !defined(OS_MACOSX) | 47 #if !defined(OS_MACOSX) |
| 47 Browser* current_browser = chrome::FindBrowserWithWebContents(initiator_); | 48 auto delegate = initiator_->GetDelegate(); |
| 48 if (!current_browser) | 49 if (!delegate) |
| 49 return; | 50 return; |
| 50 current_browser->window()->HandleKeyboardEvent(event); | 51 delegate->HandleKeyboardEvent(initiator_, event); |
| 51 #endif | 52 #endif |
| 52 } | 53 } |
| 53 | 54 |
| 54 private: | 55 private: |
| 55 content::WebContents* initiator_; | 56 content::WebContents* initiator_; |
| 56 views::WebView* web_view_; | 57 views::WebView* web_view_; |
| 57 | 58 |
| 58 DISALLOW_COPY_AND_ASSIGN(WebDialogWebContentsDelegateViews); | 59 DISALLOW_COPY_AND_ASSIGN(WebDialogWebContentsDelegateViews); |
| 59 }; | 60 }; |
| 60 | 61 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( | 188 ConstrainedWebDialogDelegate* CreateConstrainedWebDialog( |
| 188 content::BrowserContext* browser_context, | 189 content::BrowserContext* browser_context, |
| 189 ui::WebDialogDelegate* delegate, | 190 ui::WebDialogDelegate* delegate, |
| 190 content::WebContents* web_contents) { | 191 content::WebContents* web_contents) { |
| 191 ConstrainedWebDialogDelegateViewViews* dialog = | 192 ConstrainedWebDialogDelegateViewViews* dialog = |
| 192 new ConstrainedWebDialogDelegateViewViews( | 193 new ConstrainedWebDialogDelegateViewViews( |
| 193 browser_context, delegate, web_contents); | 194 browser_context, delegate, web_contents); |
| 194 constrained_window::ShowWebModalDialogViews(dialog, web_contents); | 195 constrained_window::ShowWebModalDialogViews(dialog, web_contents); |
| 195 return dialog; | 196 return dialog; |
| 196 } | 197 } |
| OLD | NEW |