| 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/html_dialog_view.h" | 5 #include "chrome/browser/ui/views/web_dialog_view.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/property_bag.h" | 9 #include "base/property_bag.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser_dialogs.h" | 12 #include "chrome/browser/ui/browser_dialogs.h" |
| 13 #include "chrome/browser/ui/webui/html_dialog_controller.h" | 13 #include "chrome/browser/ui/webui/web_dialog_controller.h" |
| 14 #include "content/public/browser/native_web_keyboard_event.h" | 14 #include "content/public/browser/native_web_keyboard_event.h" |
| 15 #include "content/public/browser/notification_details.h" | 15 #include "content/public/browser/notification_details.h" |
| 16 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
| 17 #include "content/public/browser/notification_types.h" | 17 #include "content/public/browser/notification_types.h" |
| 18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "ui/base/keycodes/keyboard_codes.h" | 19 #include "ui/base/keycodes/keyboard_codes.h" |
| 20 #include "ui/views/controls/webview/webview.h" | 20 #include "ui/views/controls/webview/webview.h" |
| 21 #include "ui/views/events/event.h" | 21 #include "ui/views/events/event.h" |
| 22 #include "ui/views/layout/fill_layout.h" | 22 #include "ui/views/layout/fill_layout.h" |
| 23 #include "ui/views/widget/root_view.h" | 23 #include "ui/views/widget/root_view.h" |
| 24 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
| 25 | 25 |
| 26 #if defined(USE_AURA) | 26 #if defined(USE_AURA) |
| 27 #include "ui/aura/event.h" | 27 #include "ui/aura/event.h" |
| 28 #include "ui/views/widget/native_widget_aura.h" | 28 #include "ui/views/widget/native_widget_aura.h" |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 using content::WebContents; | 31 using content::WebContents; |
| 32 using content::WebUIMessageHandler; | 32 using content::WebUIMessageHandler; |
| 33 | 33 |
| 34 namespace browser { | 34 namespace browser { |
| 35 | 35 |
| 36 // Declared in browser_dialogs.h so that others don't need to depend on our .h. | 36 // Declared in browser_dialogs.h so that others don't need to depend on our .h. |
| 37 gfx::NativeWindow ShowHtmlDialog(gfx::NativeWindow parent, | 37 gfx::NativeWindow ShowWebDialog(gfx::NativeWindow parent, |
| 38 Profile* profile, | 38 Profile* profile, |
| 39 Browser* browser, | 39 Browser* browser, |
| 40 HtmlDialogUIDelegate* delegate, | 40 WebDialogDelegate* delegate, |
| 41 DialogStyle style) { | 41 DialogStyle style) { |
| 42 views::Widget* widget = views::Widget::CreateWindowWithParent( | 42 views::Widget* widget = views::Widget::CreateWindowWithParent( |
| 43 new HtmlDialogView(profile, browser, delegate), | 43 new WebDialogView(profile, browser, delegate), |
| 44 parent); | 44 parent); |
| 45 widget->Show(); | 45 widget->Show(); |
| 46 return widget->GetNativeWindow(); | 46 return widget->GetNativeWindow(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void CloseHtmlDialog(gfx::NativeWindow window) { | 49 void CloseWebDialog(gfx::NativeWindow window) { |
| 50 views::Widget::GetWidgetForNativeWindow(window)->Close(); | 50 views::Widget::GetWidgetForNativeWindow(window)->Close(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 } // namespace browser | 53 } // namespace browser |
| 54 | 54 |
| 55 //////////////////////////////////////////////////////////////////////////////// | 55 //////////////////////////////////////////////////////////////////////////////// |
| 56 // HtmlDialogView, public: | 56 // WebDialogView, public: |
| 57 | 57 |
| 58 HtmlDialogView::HtmlDialogView(Profile* profile, | 58 WebDialogView::WebDialogView(Profile* profile, |
| 59 Browser* browser, | 59 Browser* browser, |
| 60 HtmlDialogUIDelegate* delegate) | 60 WebDialogDelegate* delegate) |
| 61 : HtmlDialogTabContentsDelegate(profile), | 61 : WebDialogWebContentsDelegate(profile), |
| 62 initialized_(false), | 62 initialized_(false), |
| 63 delegate_(delegate), | 63 delegate_(delegate), |
| 64 dialog_controller_(new HtmlDialogController(this, profile, browser)), | 64 dialog_controller_(new WebDialogController(this, profile, browser)), |
| 65 web_view_(new views::WebView(profile)) { | 65 web_view_(new views::WebView(profile)) { |
| 66 web_view_->set_allow_accelerators(true); | 66 web_view_->set_allow_accelerators(true); |
| 67 AddChildView(web_view_); | 67 AddChildView(web_view_); |
| 68 SetLayoutManager(new views::FillLayout); | 68 SetLayoutManager(new views::FillLayout); |
| 69 // Pressing the ESC key will close the dialog. | 69 // Pressing the ESC key will close the dialog. |
| 70 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, false, false, false)); | 70 AddAccelerator(ui::Accelerator(ui::VKEY_ESCAPE, false, false, false)); |
| 71 } | 71 } |
| 72 | 72 |
| 73 HtmlDialogView::~HtmlDialogView() { | 73 WebDialogView::~WebDialogView() { |
| 74 } | 74 } |
| 75 | 75 |
| 76 content::WebContents* HtmlDialogView::web_contents() { | 76 content::WebContents* WebDialogView::web_contents() { |
| 77 return web_view_->web_contents(); | 77 return web_view_->web_contents(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 //////////////////////////////////////////////////////////////////////////////// | 80 //////////////////////////////////////////////////////////////////////////////// |
| 81 // HtmlDialogView, views::View implementation: | 81 // WebDialogView, views::View implementation: |
| 82 | 82 |
| 83 gfx::Size HtmlDialogView::GetPreferredSize() { | 83 gfx::Size WebDialogView::GetPreferredSize() { |
| 84 gfx::Size out; | 84 gfx::Size out; |
| 85 if (delegate_) | 85 if (delegate_) |
| 86 delegate_->GetMinimumDialogSize(&out); | 86 delegate_->GetMinimumDialogSize(&out); |
| 87 return out; | 87 return out; |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool HtmlDialogView::AcceleratorPressed(const ui::Accelerator& accelerator) { | 90 bool WebDialogView::AcceleratorPressed(const ui::Accelerator& accelerator) { |
| 91 // Pressing ESC closes the dialog. | 91 // Pressing ESC closes the dialog. |
| 92 DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code()); | 92 DCHECK_EQ(ui::VKEY_ESCAPE, accelerator.key_code()); |
| 93 OnDialogClosed(std::string()); | 93 OnDialogClosed(std::string()); |
| 94 return true; | 94 return true; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void HtmlDialogView::ViewHierarchyChanged(bool is_add, | 97 void WebDialogView::ViewHierarchyChanged(bool is_add, |
| 98 views::View* parent, | 98 views::View* parent, |
| 99 views::View* child) { | 99 views::View* child) { |
| 100 if (is_add && GetWidget()) | 100 if (is_add && GetWidget()) |
| 101 InitDialog(); | 101 InitDialog(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 //////////////////////////////////////////////////////////////////////////////// | 104 //////////////////////////////////////////////////////////////////////////////// |
| 105 // HtmlDialogView, views::WidgetDelegate implementation: | 105 // WebDialogView, views::WidgetDelegate implementation: |
| 106 | 106 |
| 107 bool HtmlDialogView::CanResize() const { | 107 bool WebDialogView::CanResize() const { |
| 108 return true; | 108 return true; |
| 109 } | 109 } |
| 110 | 110 |
| 111 ui::ModalType HtmlDialogView::GetModalType() const { | 111 ui::ModalType WebDialogView::GetModalType() const { |
| 112 return GetDialogModalType(); | 112 return GetDialogModalType(); |
| 113 } | 113 } |
| 114 | 114 |
| 115 string16 HtmlDialogView::GetWindowTitle() const { | 115 string16 WebDialogView::GetWindowTitle() const { |
| 116 if (delegate_) | 116 if (delegate_) |
| 117 return delegate_->GetDialogTitle(); | 117 return delegate_->GetDialogTitle(); |
| 118 return string16(); | 118 return string16(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 std::string HtmlDialogView::GetWindowName() const { | 121 std::string WebDialogView::GetWindowName() const { |
| 122 if (delegate_) | 122 if (delegate_) |
| 123 return delegate_->GetDialogName(); | 123 return delegate_->GetDialogName(); |
| 124 return std::string(); | 124 return std::string(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void HtmlDialogView::WindowClosing() { | 127 void WebDialogView::WindowClosing() { |
| 128 // If we still have a delegate that means we haven't notified it of the | 128 // If we still have a delegate that means we haven't notified it of the |
| 129 // dialog closing. This happens if the user clicks the Close button on the | 129 // dialog closing. This happens if the user clicks the Close button on the |
| 130 // dialog. | 130 // dialog. |
| 131 if (delegate_) | 131 if (delegate_) |
| 132 OnDialogClosed(""); | 132 OnDialogClosed(""); |
| 133 } | 133 } |
| 134 | 134 |
| 135 views::View* HtmlDialogView::GetContentsView() { | 135 views::View* WebDialogView::GetContentsView() { |
| 136 return this; | 136 return this; |
| 137 } | 137 } |
| 138 | 138 |
| 139 views::View* HtmlDialogView::GetInitiallyFocusedView() { | 139 views::View* WebDialogView::GetInitiallyFocusedView() { |
| 140 return web_view_; | 140 return web_view_; |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool HtmlDialogView::ShouldShowWindowTitle() const { | 143 bool WebDialogView::ShouldShowWindowTitle() const { |
| 144 return ShouldShowDialogTitle(); | 144 return ShouldShowDialogTitle(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 views::Widget* HtmlDialogView::GetWidget() { | 147 views::Widget* WebDialogView::GetWidget() { |
| 148 return View::GetWidget(); | 148 return View::GetWidget(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 const views::Widget* HtmlDialogView::GetWidget() const { | 151 const views::Widget* WebDialogView::GetWidget() const { |
| 152 return View::GetWidget(); | 152 return View::GetWidget(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 //////////////////////////////////////////////////////////////////////////////// | 155 //////////////////////////////////////////////////////////////////////////////// |
| 156 // HtmlDialogUIDelegate implementation: | 156 // WebDialogDelegate implementation: |
| 157 | 157 |
| 158 ui::ModalType HtmlDialogView::GetDialogModalType() const { | 158 ui::ModalType WebDialogView::GetDialogModalType() const { |
| 159 if (delegate_) | 159 if (delegate_) |
| 160 return delegate_->GetDialogModalType(); | 160 return delegate_->GetDialogModalType(); |
| 161 return ui::MODAL_TYPE_NONE; | 161 return ui::MODAL_TYPE_NONE; |
| 162 } | 162 } |
| 163 | 163 |
| 164 string16 HtmlDialogView::GetDialogTitle() const { | 164 string16 WebDialogView::GetDialogTitle() const { |
| 165 return GetWindowTitle(); | 165 return GetWindowTitle(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 GURL HtmlDialogView::GetDialogContentURL() const { | 168 GURL WebDialogView::GetDialogContentURL() const { |
| 169 if (delegate_) | 169 if (delegate_) |
| 170 return delegate_->GetDialogContentURL(); | 170 return delegate_->GetDialogContentURL(); |
| 171 return GURL(); | 171 return GURL(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 void HtmlDialogView::GetWebUIMessageHandlers( | 174 void WebDialogView::GetWebUIMessageHandlers( |
| 175 std::vector<WebUIMessageHandler*>* handlers) const { | 175 std::vector<WebUIMessageHandler*>* handlers) const { |
| 176 if (delegate_) | 176 if (delegate_) |
| 177 delegate_->GetWebUIMessageHandlers(handlers); | 177 delegate_->GetWebUIMessageHandlers(handlers); |
| 178 } | 178 } |
| 179 | 179 |
| 180 void HtmlDialogView::GetDialogSize(gfx::Size* size) const { | 180 void WebDialogView::GetDialogSize(gfx::Size* size) const { |
| 181 if (delegate_) | 181 if (delegate_) |
| 182 delegate_->GetDialogSize(size); | 182 delegate_->GetDialogSize(size); |
| 183 } | 183 } |
| 184 | 184 |
| 185 void HtmlDialogView::GetMinimumDialogSize(gfx::Size* size) const { | 185 void WebDialogView::GetMinimumDialogSize(gfx::Size* size) const { |
| 186 if (delegate_) | 186 if (delegate_) |
| 187 delegate_->GetMinimumDialogSize(size); | 187 delegate_->GetMinimumDialogSize(size); |
| 188 } | 188 } |
| 189 | 189 |
| 190 std::string HtmlDialogView::GetDialogArgs() const { | 190 std::string WebDialogView::GetDialogArgs() const { |
| 191 if (delegate_) | 191 if (delegate_) |
| 192 return delegate_->GetDialogArgs(); | 192 return delegate_->GetDialogArgs(); |
| 193 return std::string(); | 193 return std::string(); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void HtmlDialogView::OnDialogClosed(const std::string& json_retval) { | 196 void WebDialogView::OnDialogClosed(const std::string& json_retval) { |
| 197 HtmlDialogTabContentsDelegate::Detach(); | 197 Detach(); |
| 198 if (delegate_) { | 198 if (delegate_) { |
| 199 // Store the dialog content area size. | 199 // Store the dialog content area size. |
| 200 delegate_->StoreDialogSize(GetContentsBounds().size()); | 200 delegate_->StoreDialogSize(GetContentsBounds().size()); |
| 201 } | 201 } |
| 202 | 202 |
| 203 if (GetWidget()) | 203 if (GetWidget()) |
| 204 GetWidget()->Close(); | 204 GetWidget()->Close(); |
| 205 | 205 |
| 206 if (delegate_) { | 206 if (delegate_) { |
| 207 delegate_->OnDialogClosed(json_retval); | 207 delegate_->OnDialogClosed(json_retval); |
| 208 delegate_ = NULL; // We will not communicate further with the delegate. | 208 delegate_ = NULL; // We will not communicate further with the delegate. |
| 209 } | 209 } |
| 210 } | 210 } |
| 211 | 211 |
| 212 void HtmlDialogView::OnCloseContents(WebContents* source, | 212 void WebDialogView::OnCloseContents(WebContents* source, |
| 213 bool* out_close_dialog) { | 213 bool* out_close_dialog) { |
| 214 if (delegate_) | 214 if (delegate_) |
| 215 delegate_->OnCloseContents(source, out_close_dialog); | 215 delegate_->OnCloseContents(source, out_close_dialog); |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool HtmlDialogView::ShouldShowDialogTitle() const { | 218 bool WebDialogView::ShouldShowDialogTitle() const { |
| 219 if (delegate_) | 219 if (delegate_) |
| 220 return delegate_->ShouldShowDialogTitle(); | 220 return delegate_->ShouldShowDialogTitle(); |
| 221 return true; | 221 return true; |
| 222 } | 222 } |
| 223 | 223 |
| 224 bool HtmlDialogView::HandleContextMenu( | 224 bool WebDialogView::HandleContextMenu( |
| 225 const content::ContextMenuParams& params) { | 225 const content::ContextMenuParams& params) { |
| 226 if (delegate_) | 226 if (delegate_) |
| 227 return delegate_->HandleContextMenu(params); | 227 return delegate_->HandleContextMenu(params); |
| 228 return HtmlDialogTabContentsDelegate::HandleContextMenu(params); | 228 return WebDialogWebContentsDelegate::HandleContextMenu(params); |
| 229 } | 229 } |
| 230 | 230 |
| 231 //////////////////////////////////////////////////////////////////////////////// | 231 //////////////////////////////////////////////////////////////////////////////// |
| 232 // content::WebContentsDelegate implementation: | 232 // content::WebContentsDelegate implementation: |
| 233 | 233 |
| 234 void HtmlDialogView::MoveContents(WebContents* source, const gfx::Rect& pos) { | 234 void WebDialogView::MoveContents(WebContents* source, const gfx::Rect& pos) { |
| 235 // The contained web page wishes to resize itself. We let it do this because | 235 // The contained web page wishes to resize itself. We let it do this because |
| 236 // if it's a dialog we know about, we trust it not to be mean to the user. | 236 // if it's a dialog we know about, we trust it not to be mean to the user. |
| 237 GetWidget()->SetBounds(pos); | 237 GetWidget()->SetBounds(pos); |
| 238 } | 238 } |
| 239 | 239 |
| 240 // A simplified version of BrowserView::HandleKeyboardEvent(). | 240 // A simplified version of BrowserView::HandleKeyboardEvent(). |
| 241 // We don't handle global keyboard shortcuts here, but that's fine since | 241 // We don't handle global keyboard shortcuts here, but that's fine since |
| 242 // they're all browser-specific. (This may change in the future.) | 242 // they're all browser-specific. (This may change in the future.) |
| 243 void HtmlDialogView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 243 void WebDialogView::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
| 244 #if defined(USE_AURA) | 244 #if defined(USE_AURA) |
| 245 aura::KeyEvent aura_event(event.os_event->native_event(), false); | 245 aura::KeyEvent aura_event(event.os_event->native_event(), false); |
| 246 views::NativeWidgetAura* aura_widget = | 246 views::NativeWidgetAura* aura_widget = |
| 247 static_cast<views::NativeWidgetAura*>(GetWidget()->native_widget()); | 247 static_cast<views::NativeWidgetAura*>(GetWidget()->native_widget()); |
| 248 aura_widget->OnKeyEvent(&aura_event); | 248 aura_widget->OnKeyEvent(&aura_event); |
| 249 #elif defined(OS_WIN) | 249 #elif defined(OS_WIN) |
| 250 // Any unhandled keyboard/character messages should be defproced. | 250 // Any unhandled keyboard/character messages should be defproced. |
| 251 // This allows stuff like F10, etc to work correctly. | 251 // This allows stuff like F10, etc to work correctly. |
| 252 DefWindowProc(event.os_event.hwnd, event.os_event.message, | 252 DefWindowProc(event.os_event.hwnd, event.os_event.message, |
| 253 event.os_event.wParam, event.os_event.lParam); | 253 event.os_event.wParam, event.os_event.lParam); |
| 254 #endif | 254 #endif |
| 255 } | 255 } |
| 256 | 256 |
| 257 void HtmlDialogView::CloseContents(WebContents* source) { | 257 void WebDialogView::CloseContents(WebContents* source) { |
| 258 bool close_dialog = false; | 258 bool close_dialog = false; |
| 259 OnCloseContents(source, &close_dialog); | 259 OnCloseContents(source, &close_dialog); |
| 260 if (close_dialog) | 260 if (close_dialog) |
| 261 OnDialogClosed(std::string()); | 261 OnDialogClosed(std::string()); |
| 262 } | 262 } |
| 263 | 263 |
| 264 content::WebContents* HtmlDialogView::OpenURLFromTab( | 264 content::WebContents* WebDialogView::OpenURLFromTab( |
| 265 content::WebContents* source, | 265 content::WebContents* source, |
| 266 const content::OpenURLParams& params) { | 266 const content::OpenURLParams& params) { |
| 267 content::WebContents* new_contents = NULL; | 267 content::WebContents* new_contents = NULL; |
| 268 if (delegate_ && | 268 if (delegate_ && |
| 269 delegate_->HandleOpenURLFromTab(source, params, &new_contents)) { | 269 delegate_->HandleOpenURLFromTab(source, params, &new_contents)) { |
| 270 return new_contents; | 270 return new_contents; |
| 271 } | 271 } |
| 272 return HtmlDialogTabContentsDelegate::OpenURLFromTab(source, params); | 272 return WebDialogWebContentsDelegate::OpenURLFromTab(source, params); |
| 273 } | 273 } |
| 274 | 274 |
| 275 void HtmlDialogView::AddNewContents(content::WebContents* source, | 275 void WebDialogView::AddNewContents(content::WebContents* source, |
| 276 content::WebContents* new_contents, | 276 content::WebContents* new_contents, |
| 277 WindowOpenDisposition disposition, | 277 WindowOpenDisposition disposition, |
| 278 const gfx::Rect& initial_pos, | 278 const gfx::Rect& initial_pos, |
| 279 bool user_gesture) { | 279 bool user_gesture) { |
| 280 if (delegate_ && delegate_->HandleAddNewContents( | 280 if (delegate_ && delegate_->HandleAddNewContents( |
| 281 source, new_contents, disposition, initial_pos, user_gesture)) { | 281 source, new_contents, disposition, initial_pos, user_gesture)) { |
| 282 return; | 282 return; |
| 283 } | 283 } |
| 284 HtmlDialogTabContentsDelegate::AddNewContents( | 284 WebDialogWebContentsDelegate::AddNewContents( |
| 285 source, new_contents, disposition, initial_pos, user_gesture); | 285 source, new_contents, disposition, initial_pos, user_gesture); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void HtmlDialogView::LoadingStateChanged(content::WebContents* source) { | 288 void WebDialogView::LoadingStateChanged(content::WebContents* source) { |
| 289 if (delegate_) | 289 if (delegate_) |
| 290 delegate_->OnLoadingStateChanged(source); | 290 delegate_->OnLoadingStateChanged(source); |
| 291 } | 291 } |
| 292 | 292 |
| 293 //////////////////////////////////////////////////////////////////////////////// | 293 //////////////////////////////////////////////////////////////////////////////// |
| 294 // HtmlDialogView, TabRenderWatcher::Delegate implementation: | 294 // WebDialogView, TabRenderWatcher::Delegate implementation: |
| 295 | 295 |
| 296 void HtmlDialogView::OnRenderHostCreated(content::RenderViewHost* host) { | 296 void WebDialogView::OnRenderHostCreated(content::RenderViewHost* host) { |
| 297 } | 297 } |
| 298 | 298 |
| 299 void HtmlDialogView::OnTabMainFrameLoaded() { | 299 void WebDialogView::OnTabMainFrameLoaded() { |
| 300 } | 300 } |
| 301 | 301 |
| 302 void HtmlDialogView::OnTabMainFrameRender() { | 302 void WebDialogView::OnTabMainFrameRender() { |
| 303 tab_watcher_.reset(); | 303 tab_watcher_.reset(); |
| 304 } | 304 } |
| 305 | 305 |
| 306 //////////////////////////////////////////////////////////////////////////////// | 306 //////////////////////////////////////////////////////////////////////////////// |
| 307 // HtmlDialogView, private: | 307 // WebDialogView, private: |
| 308 | 308 |
| 309 void HtmlDialogView::InitDialog() { | 309 void WebDialogView::InitDialog() { |
| 310 content::WebContents* web_contents = web_view_->GetWebContents(); | 310 content::WebContents* web_contents = web_view_->GetWebContents(); |
| 311 if (web_contents->GetDelegate() == this) | 311 if (web_contents->GetDelegate() == this) |
| 312 return; | 312 return; |
| 313 | 313 |
| 314 web_contents->SetDelegate(this); | 314 web_contents->SetDelegate(this); |
| 315 | 315 |
| 316 // Set the delegate. This must be done before loading the page. See | 316 // Set the delegate. This must be done before loading the page. See |
| 317 // the comment above HtmlDialogUI in its header file for why. | 317 // the comment above WebDialogUI in its header file for why. |
| 318 HtmlDialogUI::GetPropertyAccessor().SetProperty( | 318 WebDialogUI::GetPropertyAccessor().SetProperty( |
| 319 web_contents->GetPropertyBag(), this); | 319 web_contents->GetPropertyBag(), this); |
| 320 tab_watcher_.reset(new TabRenderWatcher(web_contents, this)); | 320 tab_watcher_.reset(new TabRenderWatcher(web_contents, this)); |
| 321 | 321 |
| 322 if (delegate_) { | 322 if (delegate_) { |
| 323 gfx::Size out; | 323 gfx::Size out; |
| 324 delegate_->GetDialogSize(&out); | 324 delegate_->GetDialogSize(&out); |
| 325 if (!out.IsEmpty() && GetWidget()) | 325 if (!out.IsEmpty() && GetWidget()) |
| 326 GetWidget()->CenterWindow(out); | 326 GetWidget()->CenterWindow(out); |
| 327 } | 327 } |
| 328 | 328 |
| 329 web_view_->LoadInitialURL(GetDialogContentURL()); | 329 web_view_->LoadInitialURL(GetDialogContentURL()); |
| 330 } | 330 } |
| OLD | NEW |