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/printing/print_preview_dialog_controller.h" | 5 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "content/public/browser/navigation_entry.h" | 33 #include "content/public/browser/navigation_entry.h" |
34 #include "content/public/browser/notification_details.h" | 34 #include "content/public/browser/notification_details.h" |
35 #include "content/public/browser/notification_source.h" | 35 #include "content/public/browser/notification_source.h" |
36 #include "content/public/browser/plugin_service.h" | 36 #include "content/public/browser/plugin_service.h" |
37 #include "content/public/browser/render_frame_host.h" | 37 #include "content/public/browser/render_frame_host.h" |
38 #include "content/public/browser/render_process_host.h" | 38 #include "content/public/browser/render_process_host.h" |
39 #include "content/public/browser/render_view_host.h" | 39 #include "content/public/browser/render_view_host.h" |
40 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
41 #include "content/public/browser/web_contents_delegate.h" | 41 #include "content/public/browser/web_contents_delegate.h" |
42 #include "content/public/common/webplugininfo.h" | 42 #include "content/public/common/webplugininfo.h" |
| 43 #include "extensions/browser/guest_view/guest_view_base.h" |
43 #include "ui/web_dialogs/web_dialog_delegate.h" | 44 #include "ui/web_dialogs/web_dialog_delegate.h" |
44 | 45 |
45 using content::NavigationController; | 46 using content::NavigationController; |
46 using content::WebContents; | 47 using content::WebContents; |
47 using content::WebUIMessageHandler; | 48 using content::WebUIMessageHandler; |
48 | 49 |
49 namespace { | 50 namespace { |
50 | 51 |
51 void EnableInternalPDFPluginForContents(WebContents* preview_dialog) { | 52 void EnableInternalPDFPluginForContents(WebContents* preview_dialog) { |
52 // Always enable the internal PDF plugin for the print preview page. | 53 // Always enable the internal PDF plugin for the print preview page. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // PrintPreviewUI adds its own message handlers. | 116 // PrintPreviewUI adds its own message handlers. |
116 } | 117 } |
117 | 118 |
118 void PrintPreviewDialogDelegate::GetDialogSize(gfx::Size* size) const { | 119 void PrintPreviewDialogDelegate::GetDialogSize(gfx::Size* size) const { |
119 DCHECK(size); | 120 DCHECK(size); |
120 const gfx::Size kMinDialogSize(800, 480); | 121 const gfx::Size kMinDialogSize(800, 480); |
121 const int kBorder = 25; | 122 const int kBorder = 25; |
122 *size = kMinDialogSize; | 123 *size = kMinDialogSize; |
123 | 124 |
124 web_modal::WebContentsModalDialogHost* host = NULL; | 125 web_modal::WebContentsModalDialogHost* host = NULL; |
125 Browser* browser = chrome::FindBrowserWithWebContents(initiator_); | 126 content::WebContents* outermost_web_contents = initiator_; |
| 127 const extensions::GuestViewBase* guest_view = |
| 128 extensions::GuestViewBase::FromWebContents(outermost_web_contents); |
| 129 while (guest_view && guest_view->attached()) { |
| 130 outermost_web_contents = guest_view->embedder_web_contents(); |
| 131 guest_view = |
| 132 extensions::GuestViewBase::FromWebContents(outermost_web_contents); |
| 133 } |
| 134 Browser* browser = chrome::FindBrowserWithWebContents(outermost_web_contents); |
126 if (browser) | 135 if (browser) |
127 host = browser->window()->GetWebContentsModalDialogHost(); | 136 host = browser->window()->GetWebContentsModalDialogHost(); |
128 | 137 |
129 if (host) { | 138 if (host) { |
130 size->SetToMax(host->GetMaximumDialogSize()); | 139 size->SetToMax(host->GetMaximumDialogSize()); |
131 size->Enlarge(-2 * kBorder, -kBorder); | 140 size->Enlarge(-2 * kBorder, -kBorder); |
132 } else { | 141 } else { |
133 size->SetToMax(initiator_->GetContainerBounds().size()); | 142 size->SetToMax(outermost_web_contents->GetContainerBounds().size()); |
134 size->Enlarge(-2 * kBorder, -2 * kBorder); | 143 size->Enlarge(-2 * kBorder, -2 * kBorder); |
135 } | 144 } |
136 | 145 |
137 #if defined(OS_MACOSX) | 146 #if defined(OS_MACOSX) |
138 // Limit the maximum size on MacOS X. | 147 // Limit the maximum size on MacOS X. |
139 // http://crbug.com/105815 | 148 // http://crbug.com/105815 |
140 const gfx::Size kMaxDialogSize(1000, 660); | 149 const gfx::Size kMaxDialogSize(1000, 660); |
141 size->SetToMin(kMaxDialogSize); | 150 size->SetToMin(kMaxDialogSize); |
142 #endif | 151 #endif |
143 } | 152 } |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 static_cast<PrintPreviewUI*>(web_ui->GetController()); | 481 static_cast<PrintPreviewUI*>(web_ui->GetController()); |
473 if (print_preview_ui) | 482 if (print_preview_ui) |
474 print_preview_ui->OnPrintPreviewDialogDestroyed(); | 483 print_preview_ui->OnPrintPreviewDialogDestroyed(); |
475 } | 484 } |
476 | 485 |
477 preview_dialog_map_.erase(preview_dialog); | 486 preview_dialog_map_.erase(preview_dialog); |
478 RemoveObservers(preview_dialog); | 487 RemoveObservers(preview_dialog); |
479 } | 488 } |
480 | 489 |
481 } // namespace printing | 490 } // namespace printing |
OLD | NEW |