| 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/webui/constrained_web_dialog_ui.h" | 5 #include "chrome/browser/ui/webui/constrained_web_dialog_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/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
| 16 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "content/public/browser/web_ui.h" | 18 #include "content/public/browser/web_ui.h" |
| 19 #include "extensions/features/features.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_ui.h" | 21 #include "ui/web_dialogs/web_dialog_ui.h" |
| 21 | 22 |
| 22 #if defined(ENABLE_EXTENSIONS) | 23 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 23 #include "chrome/browser/extensions/tab_helper.h" | 24 #include "chrome/browser/extensions/tab_helper.h" |
| 24 #endif | 25 #endif |
| 25 | 26 |
| 26 using content::RenderViewHost; | 27 using content::RenderViewHost; |
| 27 using content::WebContents; | 28 using content::WebContents; |
| 28 using content::WebUIMessageHandler; | 29 using content::WebUIMessageHandler; |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 const char kConstrainedWebDialogDelegateUserDataKey[] = | 33 const char kConstrainedWebDialogDelegateUserDataKey[] = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 44 private: | 45 private: |
| 45 ConstrainedWebDialogDelegate* delegate_; // unowned | 46 ConstrainedWebDialogDelegate* delegate_; // unowned |
| 46 | 47 |
| 47 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateUserData); | 48 DISALLOW_COPY_AND_ASSIGN(ConstrainedWebDialogDelegateUserData); |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 } // namespace | 51 } // namespace |
| 51 | 52 |
| 52 ConstrainedWebDialogUI::ConstrainedWebDialogUI(content::WebUI* web_ui) | 53 ConstrainedWebDialogUI::ConstrainedWebDialogUI(content::WebUI* web_ui) |
| 53 : WebUIController(web_ui) { | 54 : WebUIController(web_ui) { |
| 54 #if defined(ENABLE_EXTENSIONS) | 55 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 55 extensions::TabHelper::CreateForWebContents(web_ui->GetWebContents()); | 56 extensions::TabHelper::CreateForWebContents(web_ui->GetWebContents()); |
| 56 #endif | 57 #endif |
| 57 } | 58 } |
| 58 | 59 |
| 59 ConstrainedWebDialogUI::~ConstrainedWebDialogUI() { | 60 ConstrainedWebDialogUI::~ConstrainedWebDialogUI() { |
| 60 } | 61 } |
| 61 | 62 |
| 62 void ConstrainedWebDialogUI::RenderViewCreated( | 63 void ConstrainedWebDialogUI::RenderViewCreated( |
| 63 RenderViewHost* render_view_host) { | 64 RenderViewHost* render_view_host) { |
| 64 // Add a "dialogClose" callback which matches WebDialogUI behavior. | 65 // Add a "dialogClose" callback which matches WebDialogUI behavior. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 105 } |
| 105 | 106 |
| 106 ConstrainedWebDialogDelegate* ConstrainedWebDialogUI::GetConstrainedDelegate() { | 107 ConstrainedWebDialogDelegate* ConstrainedWebDialogUI::GetConstrainedDelegate() { |
| 107 ConstrainedWebDialogDelegateUserData* user_data = | 108 ConstrainedWebDialogDelegateUserData* user_data = |
| 108 static_cast<ConstrainedWebDialogDelegateUserData*>( | 109 static_cast<ConstrainedWebDialogDelegateUserData*>( |
| 109 web_ui()->GetWebContents()-> | 110 web_ui()->GetWebContents()-> |
| 110 GetUserData(&kConstrainedWebDialogDelegateUserDataKey)); | 111 GetUserData(&kConstrainedWebDialogDelegateUserDataKey)); |
| 111 | 112 |
| 112 return user_data ? user_data->delegate() : NULL; | 113 return user_data ? user_data->delegate() : NULL; |
| 113 } | 114 } |
| OLD | NEW |