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/property_bag.h" | 9 #include "base/property_bag.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 [window setTitle:base::SysUTF16ToNSString(delegate->GetDialogTitle())]; | 330 [window setTitle:base::SysUTF16ToNSString(delegate->GetDialogTitle())]; |
331 [window setMinSize:dialogRect.size]; | 331 [window setMinSize:dialogRect.size]; |
332 [window center]; | 332 [window center]; |
333 delegate_.reset( | 333 delegate_.reset( |
334 new WebDialogWindowDelegateBridge(self, context, delegate)); | 334 new WebDialogWindowDelegateBridge(self, context, delegate)); |
335 return self; | 335 return self; |
336 } | 336 } |
337 | 337 |
338 - (void)loadDialogContents { | 338 - (void)loadDialogContents { |
339 tabContents_.reset(new TabContents(WebContents::Create( | 339 tabContents_.reset(new TabContents(WebContents::Create( |
340 delegate_->browser_context(), NULL, MSG_ROUTING_NONE, NULL, NULL))); | 340 delegate_->browser_context(), NULL, MSG_ROUTING_NONE, NULL))); |
341 [[self window] | 341 [[self window] |
342 setContentView:tabContents_->web_contents()->GetNativeView()]; | 342 setContentView:tabContents_->web_contents()->GetNativeView()]; |
343 tabContents_->web_contents()->SetDelegate(delegate_.get()); | 343 tabContents_->web_contents()->SetDelegate(delegate_.get()); |
344 | 344 |
345 // This must be done before loading the page; see the comments in | 345 // This must be done before loading the page; see the comments in |
346 // WebDialogUI. | 346 // WebDialogUI. |
347 WebDialogUI::GetPropertyAccessor().SetProperty( | 347 WebDialogUI::GetPropertyAccessor().SetProperty( |
348 tabContents_->web_contents()->GetPropertyBag(), delegate_.get()); | 348 tabContents_->web_contents()->GetPropertyBag(), delegate_.get()); |
349 | 349 |
350 tabContents_->web_contents()->GetController().LoadURL( | 350 tabContents_->web_contents()->GetController().LoadURL( |
351 delegate_->GetDialogContentURL(), | 351 delegate_->GetDialogContentURL(), |
352 content::Referrer(), | 352 content::Referrer(), |
353 content::PAGE_TRANSITION_START_PAGE, | 353 content::PAGE_TRANSITION_START_PAGE, |
354 std::string()); | 354 std::string()); |
355 | 355 |
356 // TODO(akalin): add accelerator for ESC to close the dialog box. | 356 // TODO(akalin): add accelerator for ESC to close the dialog box. |
357 // | 357 // |
358 // TODO(akalin): Figure out why implementing (void)cancel:(id)sender | 358 // TODO(akalin): Figure out why implementing (void)cancel:(id)sender |
359 // to do the above doesn't work. | 359 // to do the above doesn't work. |
360 } | 360 } |
361 | 361 |
362 - (void)windowWillClose:(NSNotification*)notification { | 362 - (void)windowWillClose:(NSNotification*)notification { |
363 delegate_->WindowControllerClosed(); | 363 delegate_->WindowControllerClosed(); |
364 [self autorelease]; | 364 [self autorelease]; |
365 } | 365 } |
366 | 366 |
367 @end | 367 @end |
OLD | NEW |