| 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 <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/property_bag.h" | 13 #include "base/property_bag.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 15 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
| 16 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
| 17 #include "content/browser/renderer_host/render_view_host.h" | 17 #include "content/browser/renderer_host/render_view_host.h" |
| 18 #include "content/browser/tab_contents/tab_contents.h" | |
| 19 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 19 #include "content/public/browser/web_contents.h" |
| 20 |
| 21 using content::WebContents; |
| 20 | 22 |
| 21 static base::LazyInstance<base::PropertyAccessor<ConstrainedHtmlUIDelegate*> > | 23 static base::LazyInstance<base::PropertyAccessor<ConstrainedHtmlUIDelegate*> > |
| 22 g_constrained_html_ui_property_accessor = LAZY_INSTANCE_INITIALIZER; | 24 g_constrained_html_ui_property_accessor = LAZY_INSTANCE_INITIALIZER; |
| 23 | 25 |
| 24 ConstrainedHtmlUI::ConstrainedHtmlUI(TabContents* contents) | 26 ConstrainedHtmlUI::ConstrainedHtmlUI(WebContents* contents) |
| 25 : ChromeWebUI(contents) { | 27 : ChromeWebUI(contents) { |
| 26 } | 28 } |
| 27 | 29 |
| 28 ConstrainedHtmlUI::~ConstrainedHtmlUI() { | 30 ConstrainedHtmlUI::~ConstrainedHtmlUI() { |
| 29 } | 31 } |
| 30 | 32 |
| 31 void ConstrainedHtmlUI::RenderViewCreated(RenderViewHost* render_view_host) { | 33 void ConstrainedHtmlUI::RenderViewCreated(RenderViewHost* render_view_host) { |
| 32 ChromeWebUI::RenderViewCreated(render_view_host); | 34 ChromeWebUI::RenderViewCreated(render_view_host); |
| 33 | 35 |
| 34 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); | 36 ConstrainedHtmlUIDelegate* delegate = GetConstrainedDelegate(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 63 | 65 |
| 64 std::string json_retval; | 66 std::string json_retval; |
| 65 if (!args->empty() && !args->GetString(0, &json_retval)) | 67 if (!args->empty() && !args->GetString(0, &json_retval)) |
| 66 NOTREACHED() << "Could not read JSON argument"; | 68 NOTREACHED() << "Could not read JSON argument"; |
| 67 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(json_retval); | 69 delegate->GetHtmlDialogUIDelegate()->OnDialogClosed(json_retval); |
| 68 delegate->OnDialogCloseFromWebUI(); | 70 delegate->OnDialogCloseFromWebUI(); |
| 69 } | 71 } |
| 70 | 72 |
| 71 ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::GetConstrainedDelegate() { | 73 ConstrainedHtmlUIDelegate* ConstrainedHtmlUI::GetConstrainedDelegate() { |
| 72 ConstrainedHtmlUIDelegate** property = | 74 ConstrainedHtmlUIDelegate** property = |
| 73 GetPropertyAccessor().GetProperty(tab_contents()->GetPropertyBag()); | 75 GetPropertyAccessor().GetProperty(web_contents()->GetPropertyBag()); |
| 74 return property ? *property : NULL; | 76 return property ? *property : NULL; |
| 75 } | 77 } |
| 76 | 78 |
| 77 // static | 79 // static |
| 78 base::PropertyAccessor<ConstrainedHtmlUIDelegate*>& | 80 base::PropertyAccessor<ConstrainedHtmlUIDelegate*>& |
| 79 ConstrainedHtmlUI::GetPropertyAccessor() { | 81 ConstrainedHtmlUI::GetPropertyAccessor() { |
| 80 return g_constrained_html_ui_property_accessor.Get(); | 82 return g_constrained_html_ui_property_accessor.Get(); |
| 81 } | 83 } |
| OLD | NEW |