Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(442)

Side by Side Diff: chrome/browser/printing/print_preview_dialog_controller.cc

Issue 12334073: Remove WebContents methods that duplicate WebContentsView methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
33 #include "content/public/browser/navigation_controller.h" 33 #include "content/public/browser/navigation_controller.h"
34 #include "content/public/browser/navigation_details.h" 34 #include "content/public/browser/navigation_details.h"
35 #include "content/public/browser/navigation_entry.h" 35 #include "content/public/browser/navigation_entry.h"
36 #include "content/public/browser/notification_details.h" 36 #include "content/public/browser/notification_details.h"
37 #include "content/public/browser/notification_source.h" 37 #include "content/public/browser/notification_source.h"
38 #include "content/public/browser/plugin_service.h" 38 #include "content/public/browser/plugin_service.h"
39 #include "content/public/browser/render_process_host.h" 39 #include "content/public/browser/render_process_host.h"
40 #include "content/public/browser/render_view_host.h" 40 #include "content/public/browser/render_view_host.h"
41 #include "content/public/browser/web_contents.h" 41 #include "content/public/browser/web_contents.h"
42 #include "content/public/browser/web_contents_delegate.h" 42 #include "content/public/browser/web_contents_delegate.h"
43 #include "content/public/browser/web_contents_view.h"
43 #include "ui/web_dialogs/web_dialog_delegate.h" 44 #include "ui/web_dialogs/web_dialog_delegate.h"
44 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h" 45 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h"
45 #include "webkit/plugins/webplugininfo.h" 46 #include "webkit/plugins/webplugininfo.h"
46 47
47 using content::NativeWebKeyboardEvent; 48 using content::NativeWebKeyboardEvent;
48 using content::NavigationController; 49 using content::NavigationController;
49 using content::WebContents; 50 using content::WebContents;
50 using content::WebUIMessageHandler; 51 using content::WebUIMessageHandler;
51 using ui::WebDialogDelegate; 52 using ui::WebDialogDelegate;
52 using ui::WebDialogWebContentsDelegate; 53 using ui::WebDialogWebContentsDelegate;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 void PrintPreviewTabDelegate::GetWebUIMessageHandlers( 121 void PrintPreviewTabDelegate::GetWebUIMessageHandlers(
121 std::vector<WebUIMessageHandler*>* /* handlers */) const { 122 std::vector<WebUIMessageHandler*>* /* handlers */) const {
122 // PrintPreviewUI adds its own message handlers. 123 // PrintPreviewUI adds its own message handlers.
123 } 124 }
124 125
125 void PrintPreviewTabDelegate::GetDialogSize(gfx::Size* size) const { 126 void PrintPreviewTabDelegate::GetDialogSize(gfx::Size* size) const {
126 DCHECK(size); 127 DCHECK(size);
127 const gfx::Size kMinDialogSize(800, 480); 128 const gfx::Size kMinDialogSize(800, 480);
128 const int kBorder = 50; 129 const int kBorder = 50;
129 gfx::Rect rect; 130 gfx::Rect rect;
130 initiator_tab_->GetContainerBounds(&rect); 131 initiator_tab_->GetView()->GetContainerBounds(&rect);
131 size->set_width(std::max(rect.width(), kMinDialogSize.width()) - kBorder); 132 size->set_width(std::max(rect.width(), kMinDialogSize.width()) - kBorder);
132 size->set_height(std::max(rect.height(), kMinDialogSize.height()) - kBorder); 133 size->set_height(std::max(rect.height(), kMinDialogSize.height()) - kBorder);
133 134
134 #if defined(OS_MACOSX) 135 #if defined(OS_MACOSX)
135 // Limit the maximum size on MacOS X. 136 // Limit the maximum size on MacOS X.
136 // http://crbug.com/105815 137 // http://crbug.com/105815
137 const gfx::Size kMaxDialogSize(1000, 660); 138 const gfx::Size kMaxDialogSize(1000, 660);
138 size->set_width(std::min(size->width(), kMaxDialogSize.width())); 139 size->set_width(std::min(size->width(), kMaxDialogSize.width()));
139 size->set_height(std::min(size->height(), kMaxDialogSize.height())); 140 size->set_height(std::min(size->height(), kMaxDialogSize.height()));
140 #endif 141 #endif
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 void PrintPreviewDialogController::EraseInitiatorTabInfo( 299 void PrintPreviewDialogController::EraseInitiatorTabInfo(
299 WebContents* preview_tab) { 300 WebContents* preview_tab) {
300 PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab); 301 PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab);
301 if (it == preview_tab_map_.end()) 302 if (it == preview_tab_map_.end())
302 return; 303 return;
303 304
304 RemoveObservers(it->second); 305 RemoveObservers(it->second);
305 preview_tab_map_[preview_tab] = NULL; 306 preview_tab_map_[preview_tab] = NULL;
306 } 307 }
307 308
308 bool PrintPreviewDialogController::is_creating_print_preview_dialog() const {
309 return is_creating_print_preview_dialog_;
310 }
311
312 PrintPreviewDialogController::~PrintPreviewDialogController() {} 309 PrintPreviewDialogController::~PrintPreviewDialogController() {}
313 310
314 void PrintPreviewDialogController::OnRendererProcessClosed( 311 void PrintPreviewDialogController::OnRendererProcessClosed(
315 content::RenderProcessHost* rph) { 312 content::RenderProcessHost* rph) {
316 // Store tabs in a vector and deal with them after iterating through 313 // Store tabs in a vector and deal with them after iterating through
317 // |preview_tab_map_| because RemoveFooTab() can change |preview_tab_map_|. 314 // |preview_tab_map_| because RemoveFooTab() can change |preview_tab_map_|.
318 std::vector<WebContents*> closed_initiator_tabs; 315 std::vector<WebContents*> closed_initiator_tabs;
319 std::vector<WebContents*> closed_preview_tabs; 316 std::vector<WebContents*> closed_preview_tabs;
320 for (PrintPreviewTabMap::iterator iter = preview_tab_map_.begin(); 317 for (PrintPreviewTabMap::iterator iter = preview_tab_map_.begin();
321 iter != preview_tab_map_.end(); ++iter) { 318 iter != preview_tab_map_.end(); ++iter) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 EnableInternalPDFPluginForTab(preview_tab); 424 EnableInternalPDFPluginForTab(preview_tab);
428 PrintViewManager::CreateForWebContents(preview_tab); 425 PrintViewManager::CreateForWebContents(preview_tab);
429 426
430 // Add an entry to the map. 427 // Add an entry to the map.
431 preview_tab_map_[preview_tab] = initiator_tab; 428 preview_tab_map_[preview_tab] = initiator_tab;
432 waiting_for_new_preview_page_ = true; 429 waiting_for_new_preview_page_ = true;
433 430
434 AddObservers(initiator_tab); 431 AddObservers(initiator_tab);
435 AddObservers(preview_tab); 432 AddObservers(preview_tab);
436 433
434 if (!print_preview_tab_created_callback_.is_null())
435 print_preview_tab_created_callback_.Run();
436
437 return preview_tab; 437 return preview_tab;
438 } 438 }
439 439
440 void PrintPreviewDialogController::SaveInitiatorTabTitle( 440 void PrintPreviewDialogController::SaveInitiatorTabTitle(
441 WebContents* preview_dialog) { 441 WebContents* preview_dialog) {
442 WebContents* initiator_tab = GetInitiatorTab(preview_dialog); 442 WebContents* initiator_tab = GetInitiatorTab(preview_dialog);
443 if (initiator_tab && preview_dialog->GetWebUI()) { 443 if (initiator_tab && preview_dialog->GetWebUI()) {
444 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( 444 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
445 preview_dialog->GetWebUI()->GetController()); 445 preview_dialog->GetWebUI()->GetController());
446 print_preview_ui->SetInitiatorTabTitle( 446 print_preview_ui->SetInitiatorTabTitle(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( 514 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
515 preview_tab->GetWebUI()->GetController()); 515 preview_tab->GetWebUI()->GetController());
516 if (print_preview_ui) 516 if (print_preview_ui)
517 print_preview_ui->OnPrintPreviewDialogDestroyed(); 517 print_preview_ui->OnPrintPreviewDialogDestroyed();
518 518
519 preview_tab_map_.erase(preview_tab); 519 preview_tab_map_.erase(preview_tab);
520 RemoveObservers(preview_tab); 520 RemoveObservers(preview_tab);
521 } 521 }
522 522
523 } // namespace printing 523 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_preview_dialog_controller.h ('k') | chrome/browser/speech/speech_recognition_bubble.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698