Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "chrome/browser/download/download_danger_prompt.h" | 6 #include "chrome/browser/download/download_danger_prompt.h" |
| 7 #include "chrome/browser/ui/views/constrained_window_views.h" | 7 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 8 #include "components/web_modal/web_contents_modal_dialog_host.h" | 8 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 9 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 9 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 10 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | 10 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/browser/download_danger_type.h" | 12 #include "content/public/browser/download_danger_type.h" |
| 13 #include "content/public/browser/download_item.h" | 13 #include "content/public/browser/download_item.h" |
| 14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 15 #include "content/public/browser/web_contents_view.h" | |
| 16 #include "grit/chromium_strings.h" | 15 #include "grit/chromium_strings.h" |
| 17 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/views/controls/button/label_button.h" | 18 #include "ui/views/controls/button/label_button.h" |
| 20 #include "ui/views/controls/label.h" | 19 #include "ui/views/controls/label.h" |
| 21 #include "ui/views/layout/grid_layout.h" | 20 #include "ui/views/layout/grid_layout.h" |
| 22 #include "ui/views/view.h" | 21 #include "ui/views/view.h" |
| 23 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
| 24 #include "ui/views/window/dialog_client_view.h" | 23 #include "ui/views/window/dialog_client_view.h" |
| 25 #include "ui/views/window/dialog_delegate.h" | 24 #include "ui/views/window/dialog_delegate.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 | 204 |
| 206 RunDone(DISMISS); | 205 RunDone(DISMISS); |
| 207 return true; | 206 return true; |
| 208 } | 207 } |
| 209 | 208 |
| 210 // TODO(wittman): Remove this override once we move to the new style frame | 209 // TODO(wittman): Remove this override once we move to the new style frame |
| 211 // view on all dialogs. | 210 // view on all dialogs. |
| 212 views::NonClientFrameView* DownloadDangerPromptViews::CreateNonClientFrameView( | 211 views::NonClientFrameView* DownloadDangerPromptViews::CreateNonClientFrameView( |
| 213 views::Widget* widget) { | 212 views::Widget* widget) { |
| 214 return CreateConstrainedStyleNonClientFrameView( | 213 return CreateConstrainedStyleNonClientFrameView( |
| 215 widget, | 214 widget, web_contents_->GetBrowserContext()); |
| 216 web_contents_->GetBrowserContext()); | |
| 217 } | 215 } |
| 218 | 216 |
| 219 views::View* DownloadDangerPromptViews::GetInitiallyFocusedView() { | 217 views::View* DownloadDangerPromptViews::GetInitiallyFocusedView() { |
| 220 return GetDialogClientView()->cancel_button(); | 218 return GetDialogClientView()->cancel_button(); |
| 221 } | 219 } |
| 222 | 220 |
| 223 views::View* DownloadDangerPromptViews::GetContentsView() { | 221 views::View* DownloadDangerPromptViews::GetContentsView() { |
| 224 return contents_view_; | 222 return contents_view_; |
| 225 } | 223 } |
| 226 | 224 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 359 content::WebContents* web_contents, | 357 content::WebContents* web_contents, |
| 360 bool show_context, | 358 bool show_context, |
| 361 const OnDone& done) { | 359 const OnDone& done) { |
| 362 DownloadDangerPromptViews* download_danger_prompt = | 360 DownloadDangerPromptViews* download_danger_prompt = |
| 363 new DownloadDangerPromptViews(item, web_contents, show_context, done); | 361 new DownloadDangerPromptViews(item, web_contents, show_context, done); |
| 364 | 362 |
| 365 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 363 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
| 366 WebContentsModalDialogManager::FromWebContents(web_contents); | 364 WebContentsModalDialogManager::FromWebContents(web_contents); |
| 367 WebContentsModalDialogManagerDelegate* modal_delegate = | 365 WebContentsModalDialogManagerDelegate* modal_delegate = |
| 368 web_contents_modal_dialog_manager->delegate(); | 366 web_contents_modal_dialog_manager->delegate(); |
| 369 CHECK(modal_delegate); | |
|
sky
2013/11/16 03:03:16
and here
msw
2013/11/16 04:15:44
Done.
| |
| 370 views::Widget* dialog = views::Widget::CreateWindowAsFramelessChild( | 367 views::Widget* dialog = views::Widget::CreateWindowAsFramelessChild( |
| 371 download_danger_prompt, | 368 download_danger_prompt, |
| 372 web_contents->GetView()->GetNativeView(), | |
| 373 modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); | 369 modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); |
| 374 web_contents_modal_dialog_manager->ShowDialog(dialog->GetNativeView()); | 370 web_contents_modal_dialog_manager->ShowDialog(dialog->GetNativeView()); |
| 375 | 371 |
| 376 return download_danger_prompt; | 372 return download_danger_prompt; |
| 377 } | 373 } |
| OLD | NEW |