| 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 #import "chrome/browser/ui/cocoa/web_dialog_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/web_dialog_window_controller.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_nsobject.h" | 8 #include "base/memory/scoped_nsobject.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #import "chrome/browser/ui/browser_dialogs.h" | 10 #import "chrome/browser/ui/browser_dialogs.h" |
| 11 #import "chrome/browser/ui/cocoa/browser_command_executor.h" | 11 #import "chrome/browser/ui/cocoa/browser_command_executor.h" |
| 12 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" | 12 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" |
| 13 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" | 13 #include "chrome/browser/ui/webui/chrome_web_contents_handler.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/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 16 #include "content/public/browser/web_contents_view.h" |
| 16 #include "content/public/browser/web_ui_message_handler.h" | 17 #include "content/public/browser/web_ui_message_handler.h" |
| 17 #include "ui/base/keycodes/keyboard_codes.h" | 18 #include "ui/base/keycodes/keyboard_codes.h" |
| 18 #include "ui/gfx/size.h" | 19 #include "ui/gfx/size.h" |
| 19 #include "ui/web_dialogs/web_dialog_delegate.h" | 20 #include "ui/web_dialogs/web_dialog_delegate.h" |
| 20 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h" | 21 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h" |
| 21 | 22 |
| 22 using content::NativeWebKeyboardEvent; | 23 using content::NativeWebKeyboardEvent; |
| 23 using content::WebContents; | 24 using content::WebContents; |
| 24 using content::WebUIMessageHandler; | 25 using content::WebUIMessageHandler; |
| 25 using ui::WebDialogDelegate; | 26 using ui::WebDialogDelegate; |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 [window setMinSize:dialogRect.size]; | 336 [window setMinSize:dialogRect.size]; |
| 336 [window center]; | 337 [window center]; |
| 337 delegate_.reset( | 338 delegate_.reset( |
| 338 new WebDialogWindowDelegateBridge(self, context, delegate)); | 339 new WebDialogWindowDelegateBridge(self, context, delegate)); |
| 339 return self; | 340 return self; |
| 340 } | 341 } |
| 341 | 342 |
| 342 - (void)loadDialogContents { | 343 - (void)loadDialogContents { |
| 343 webContents_.reset(WebContents::Create( | 344 webContents_.reset(WebContents::Create( |
| 344 WebContents::CreateParams(delegate_->browser_context()))); | 345 WebContents::CreateParams(delegate_->browser_context()))); |
| 345 [[self window] setContentView:webContents_->GetNativeView()]; | 346 [[self window] setContentView:webContents_->GetView()->GetNativeView()]; |
| 346 webContents_->SetDelegate(delegate_.get()); | 347 webContents_->SetDelegate(delegate_.get()); |
| 347 | 348 |
| 348 // This must be done before loading the page; see the comments in | 349 // This must be done before loading the page; see the comments in |
| 349 // WebDialogUI. | 350 // WebDialogUI. |
| 350 WebDialogUI::SetDelegate(webContents_.get(), delegate_.get()); | 351 WebDialogUI::SetDelegate(webContents_.get(), delegate_.get()); |
| 351 | 352 |
| 352 webContents_->GetController().LoadURL( | 353 webContents_->GetController().LoadURL( |
| 353 delegate_->GetDialogContentURL(), | 354 delegate_->GetDialogContentURL(), |
| 354 content::Referrer(), | 355 content::Referrer(), |
| 355 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 356 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 356 std::string()); | 357 std::string()); |
| 357 | 358 |
| 358 // TODO(akalin): add accelerator for ESC to close the dialog box. | 359 // TODO(akalin): add accelerator for ESC to close the dialog box. |
| 359 // | 360 // |
| 360 // TODO(akalin): Figure out why implementing (void)cancel:(id)sender | 361 // TODO(akalin): Figure out why implementing (void)cancel:(id)sender |
| 361 // to do the above doesn't work. | 362 // to do the above doesn't work. |
| 362 } | 363 } |
| 363 | 364 |
| 364 - (void)windowWillClose:(NSNotification*)notification { | 365 - (void)windowWillClose:(NSNotification*)notification { |
| 365 delegate_->WindowControllerClosed(); | 366 delegate_->WindowControllerClosed(); |
| 366 [self autorelease]; | 367 [self autorelease]; |
| 367 } | 368 } |
| 368 | 369 |
| 369 @end | 370 @end |
| OLD | NEW |