| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/renderer_preferences_util.h" | 10 #include "chrome/browser/renderer_preferences_util.h" |
| 11 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" | 11 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" |
| 12 #include "content/public/browser/host_zoom_map.h" |
| 12 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
| 13 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/common/renderer_preferences.h" |
| 14 #include "ipc/ipc_message.h" | 16 #include "ipc/ipc_message.h" |
| 15 #include "ui/web_dialogs/web_dialog_delegate.h" | 17 #include "ui/web_dialogs/web_dialog_delegate.h" |
| 16 #include "ui/web_dialogs/web_dialog_ui.h" | 18 #include "ui/web_dialogs/web_dialog_ui.h" |
| 17 | 19 |
| 18 using content::NativeWebKeyboardEvent; | 20 using content::NativeWebKeyboardEvent; |
| 19 using content::WebContents; | 21 using content::WebContents; |
| 20 using ui::WebDialogDelegate; | 22 using ui::WebDialogDelegate; |
| 21 using ui::WebDialogWebContentsDelegate; | 23 using ui::WebDialogWebContentsDelegate; |
| 22 | 24 |
| 23 ConstrainedWebDialogDelegateBase::ConstrainedWebDialogDelegateBase( | 25 ConstrainedWebDialogDelegateBase::ConstrainedWebDialogDelegateBase( |
| 24 content::BrowserContext* browser_context, | 26 content::BrowserContext* browser_context, |
| 25 WebDialogDelegate* delegate, | 27 WebDialogDelegate* delegate, |
| 26 WebDialogWebContentsDelegate* tab_delegate) | 28 WebDialogWebContentsDelegate* tab_delegate) |
| 27 : WebDialogWebContentsDelegate(browser_context, | 29 : WebDialogWebContentsDelegate(browser_context, |
| 28 new ChromeWebContentsHandler), | 30 new ChromeWebContentsHandler), |
| 29 web_dialog_delegate_(delegate), | 31 web_dialog_delegate_(delegate), |
| 30 closed_via_webui_(false), | 32 closed_via_webui_(false), |
| 31 release_contents_on_close_(false) { | 33 release_contents_on_close_(false) { |
| 32 CHECK(delegate); | 34 CHECK(delegate); |
| 33 web_contents_.reset( | 35 web_contents_.reset( |
| 34 WebContents::Create(WebContents::CreateParams(browser_context))); | 36 WebContents::Create(WebContents::CreateParams(browser_context))); |
| 35 if (tab_delegate) { | 37 if (tab_delegate) { |
| 36 override_tab_delegate_.reset(tab_delegate); | 38 override_tab_delegate_.reset(tab_delegate); |
| 37 web_contents_->SetDelegate(tab_delegate); | 39 web_contents_->SetDelegate(tab_delegate); |
| 38 } else { | 40 } else { |
| 39 web_contents_->SetDelegate(this); | 41 web_contents_->SetDelegate(this); |
| 40 } | 42 } |
| 43 content::RendererPreferences* prefs = |
| 44 web_contents_->GetMutableRendererPrefs(); |
| 41 renderer_preferences_util::UpdateFromSystemSettings( | 45 renderer_preferences_util::UpdateFromSystemSettings( |
| 42 web_contents_->GetMutableRendererPrefs(), | 46 prefs, Profile::FromBrowserContext(browser_context)); |
| 43 Profile::FromBrowserContext(browser_context)); | 47 // TODO(wjmaclean): Convert this to use the HostZoomMap for the WebContents |
| 48 // when HostZoomMap moves to StoragePartition. |
| 49 prefs->default_zoom_level = content::HostZoomMap::GetDefaultForBrowserContext( |
| 50 browser_context)->GetDefaultZoomLevel(); |
| 51 |
| 44 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); | 52 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
| 45 | 53 |
| 46 // Set |this| as a delegate so the ConstrainedWebDialogUI can retrieve it. | 54 // Set |this| as a delegate so the ConstrainedWebDialogUI can retrieve it. |
| 47 ConstrainedWebDialogUI::SetConstrainedDelegate(web_contents_.get(), this); | 55 ConstrainedWebDialogUI::SetConstrainedDelegate(web_contents_.get(), this); |
| 48 | 56 |
| 49 web_contents_->GetController().LoadURL(delegate->GetDialogContentURL(), | 57 web_contents_->GetController().LoadURL(delegate->GetDialogContentURL(), |
| 50 content::Referrer(), | 58 content::Referrer(), |
| 51 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 59 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 52 std::string()); | 60 std::string()); |
| 53 } | 61 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 95 } |
| 88 | 96 |
| 89 WebContents* ConstrainedWebDialogDelegateBase::GetWebContents() { | 97 WebContents* ConstrainedWebDialogDelegateBase::GetWebContents() { |
| 90 return web_contents_.get(); | 98 return web_contents_.get(); |
| 91 } | 99 } |
| 92 | 100 |
| 93 void ConstrainedWebDialogDelegateBase::HandleKeyboardEvent( | 101 void ConstrainedWebDialogDelegateBase::HandleKeyboardEvent( |
| 94 content::WebContents* source, | 102 content::WebContents* source, |
| 95 const NativeWebKeyboardEvent& event) { | 103 const NativeWebKeyboardEvent& event) { |
| 96 } | 104 } |
| OLD | NEW |