| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_html_ui.h" | 5 #include "chrome/browser/ui/webui/constrained_html_ui.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 10 #include "chrome/browser/ui/views/constrained_window_views.h" | 10 #include "chrome/browser/ui/views/constrained_window_views.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 html_tab_contents_(profile, NULL, MSG_ROUTING_NONE, NULL, NULL), | 92 html_tab_contents_(profile, NULL, MSG_ROUTING_NONE, NULL, NULL), |
| 93 html_delegate_(delegate), | 93 html_delegate_(delegate), |
| 94 window_(NULL), | 94 window_(NULL), |
| 95 closed_via_webui_(false) { | 95 closed_via_webui_(false) { |
| 96 CHECK(delegate); | 96 CHECK(delegate); |
| 97 html_tab_contents_.set_delegate(this); | 97 html_tab_contents_.set_delegate(this); |
| 98 | 98 |
| 99 // Set |this| as a property so the ConstrainedHtmlUI can retrieve it. | 99 // Set |this| as a property so the ConstrainedHtmlUI can retrieve it. |
| 100 ConstrainedHtmlUI::GetPropertyAccessor().SetProperty( | 100 ConstrainedHtmlUI::GetPropertyAccessor().SetProperty( |
| 101 html_tab_contents_.property_bag(), this); | 101 html_tab_contents_.property_bag(), this); |
| 102 html_tab_contents_.controller().LoadURL(delegate->GetDialogContentURL(), | 102 html_tab_contents_.controller().LoadURL( |
| 103 GURL(), | 103 delegate->GetDialogContentURL(), |
| 104 PageTransition::START_PAGE, | 104 GURL(), |
| 105 std::string()); | 105 content::PAGE_TRANSITION_START_PAGE, |
| 106 std::string()); |
| 106 } | 107 } |
| 107 | 108 |
| 108 ConstrainedHtmlDelegateViews::~ConstrainedHtmlDelegateViews() { | 109 ConstrainedHtmlDelegateViews::~ConstrainedHtmlDelegateViews() { |
| 109 } | 110 } |
| 110 | 111 |
| 111 HtmlDialogUIDelegate* ConstrainedHtmlDelegateViews::GetHtmlDialogUIDelegate() { | 112 HtmlDialogUIDelegate* ConstrainedHtmlDelegateViews::GetHtmlDialogUIDelegate() { |
| 112 return html_delegate_; | 113 return html_delegate_; |
| 113 } | 114 } |
| 114 | 115 |
| 115 void ConstrainedHtmlDelegateViews::OnDialogCloseFromWebUI() { | 116 void ConstrainedHtmlDelegateViews::OnDialogCloseFromWebUI() { |
| 116 closed_via_webui_ = true; | 117 closed_via_webui_ = true; |
| 117 window_->CloseConstrainedWindow(); | 118 window_->CloseConstrainedWindow(); |
| 118 } | 119 } |
| 119 | 120 |
| 120 // static | 121 // static |
| 121 ConstrainedWindow* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( | 122 ConstrainedWindow* ConstrainedHtmlUI::CreateConstrainedHtmlDialog( |
| 122 Profile* profile, | 123 Profile* profile, |
| 123 HtmlDialogUIDelegate* delegate, | 124 HtmlDialogUIDelegate* delegate, |
| 124 TabContentsWrapper* container) { | 125 TabContentsWrapper* container) { |
| 125 ConstrainedHtmlDelegateViews* constrained_delegate = | 126 ConstrainedHtmlDelegateViews* constrained_delegate = |
| 126 new ConstrainedHtmlDelegateViews(profile, delegate); | 127 new ConstrainedHtmlDelegateViews(profile, delegate); |
| 127 ConstrainedWindow* constrained_window = | 128 ConstrainedWindow* constrained_window = |
| 128 new ConstrainedWindowViews(container, constrained_delegate); | 129 new ConstrainedWindowViews(container, constrained_delegate); |
| 129 constrained_delegate->set_window(constrained_window); | 130 constrained_delegate->set_window(constrained_window); |
| 130 return constrained_window; | 131 return constrained_window; |
| 131 } | 132 } |
| OLD | NEW |