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

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

Issue 7845015: Print Preview: Open print preview tab in the right position when the source is a popup. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/printing/print_preview_tab_controller_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/printing/print_preview_tab_controller.h" 5 #include "chrome/browser/printing/print_preview_tab_controller.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (!g_browser_process) 84 if (!g_browser_process)
85 return NULL; 85 return NULL;
86 return g_browser_process->print_preview_tab_controller(); 86 return g_browser_process->print_preview_tab_controller();
87 } 87 }
88 88
89 // static 89 // static
90 void PrintPreviewTabController::PrintPreview(TabContentsWrapper* tab) { 90 void PrintPreviewTabController::PrintPreview(TabContentsWrapper* tab) {
91 if (tab->tab_contents()->showing_interstitial_page()) 91 if (tab->tab_contents()->showing_interstitial_page())
92 return; 92 return;
93 93
94 PrintPreviewTabController* tab_controller = 94 PrintPreviewTabController* tab_controller = GetInstance();
95 PrintPreviewTabController::GetInstance();
96 if (!tab_controller) 95 if (!tab_controller)
97 return; 96 return;
98 tab_controller->GetOrCreatePreviewTab(tab); 97 tab_controller->GetOrCreatePreviewTab(tab);
99 } 98 }
100 99
101 TabContentsWrapper* PrintPreviewTabController::GetOrCreatePreviewTab( 100 TabContentsWrapper* PrintPreviewTabController::GetOrCreatePreviewTab(
102 TabContentsWrapper* initiator_tab) { 101 TabContentsWrapper* initiator_tab) {
103 DCHECK(initiator_tab); 102 DCHECK(initiator_tab);
104 103
105 // Get the print preview tab for |initiator_tab|. 104 // Get the print preview tab for |initiator_tab|.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 NOTREACHED(); 159 NOTREACHED();
161 break; 160 break;
162 } 161 }
163 } 162 }
164 } 163 }
165 164
166 void PrintPreviewTabController::OnRendererProcessClosed( 165 void PrintPreviewTabController::OnRendererProcessClosed(
167 RenderProcessHost* rph) { 166 RenderProcessHost* rph) {
168 for (PrintPreviewTabMap::iterator iter = preview_tab_map_.begin(); 167 for (PrintPreviewTabMap::iterator iter = preview_tab_map_.begin();
169 iter != preview_tab_map_.end(); ++iter) { 168 iter != preview_tab_map_.end(); ++iter) {
170 if (iter->second != NULL && 169 TabContentsWrapper* initiator_tab = iter->second;
171 iter->second->render_view_host()->process() == rph) { 170 if (initiator_tab &&
172 TabContentsWrapper* preview_tab = GetPrintPreviewForTab(iter->second); 171 initiator_tab->render_view_host()->process() == rph) {
172 TabContentsWrapper* preview_tab = iter->first;
173 PrintPreviewUI* print_preview_ui = 173 PrintPreviewUI* print_preview_ui =
174 static_cast<PrintPreviewUI*>(preview_tab->web_ui()); 174 static_cast<PrintPreviewUI*>(preview_tab->web_ui());
175 print_preview_ui->OnInitiatorTabCrashed(); 175 print_preview_ui->OnInitiatorTabCrashed();
176 } 176 }
177 } 177 }
178 } 178 }
179 179
180 void PrintPreviewTabController::OnTabContentsDestroyed( 180 void PrintPreviewTabController::OnTabContentsDestroyed(
181 TabContentsWrapper* tab) { 181 TabContentsWrapper* tab) {
182 TabContentsWrapper* preview_tab = GetPrintPreviewForTab(tab); 182 TabContentsWrapper* preview_tab = GetPrintPreviewForTab(tab);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 } 313 }
314 } 314 }
315 315
316 // Add a new tab next to initiator tab. 316 // Add a new tab next to initiator tab.
317 browser::NavigateParams params(current_browser, 317 browser::NavigateParams params(current_browser,
318 GURL(chrome::kChromeUIPrintURL), 318 GURL(chrome::kChromeUIPrintURL),
319 PageTransition::LINK); 319 PageTransition::LINK);
320 params.disposition = NEW_FOREGROUND_TAB; 320 params.disposition = NEW_FOREGROUND_TAB;
321 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeFrame)) 321 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeFrame))
322 params.disposition = NEW_POPUP; 322 params.disposition = NEW_POPUP;
323 params.tabstrip_index = current_browser->tabstrip_model()-> 323
324 GetIndexOfTabContents(initiator_tab) + 1; 324 // For normal tabs, set the position as immediately to the right,
325 // otherwise let the tab strip decide.
326 if (current_browser->is_type_tabbed()) {
327 params.tabstrip_index = current_browser->tabstrip_model()->
328 GetIndexOfTabContents(initiator_tab) + 1;
329 }
330
325 browser::Navigate(&params); 331 browser::Navigate(&params);
326 TabContentsWrapper* preview_tab = params.target_contents; 332 TabContentsWrapper* preview_tab = params.target_contents;
327 EnableInternalPDFPluginForTab(preview_tab); 333 EnableInternalPDFPluginForTab(preview_tab);
328 static_cast<RenderViewHostDelegate*>(preview_tab->tab_contents())->Activate(); 334 static_cast<RenderViewHostDelegate*>(preview_tab->tab_contents())->Activate();
329 335
330 // Add an entry to the map. 336 // Add an entry to the map.
331 preview_tab_map_[preview_tab] = initiator_tab; 337 preview_tab_map_[preview_tab] = initiator_tab;
332 waiting_for_new_preview_page_ = true; 338 waiting_for_new_preview_page_ = true;
333 339
334 AddObservers(initiator_tab); 340 AddObservers(initiator_tab);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 RenderProcessHost* rph = tab->render_view_host()->process(); 385 RenderProcessHost* rph = tab->render_view_host()->process();
380 if (registrar_.IsRegistered(this, 386 if (registrar_.IsRegistered(this,
381 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 387 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
382 Source<RenderProcessHost>(rph))) { 388 Source<RenderProcessHost>(rph))) {
383 registrar_.Remove(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 389 registrar_.Remove(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
384 Source<RenderProcessHost>(rph)); 390 Source<RenderProcessHost>(rph));
385 } 391 }
386 } 392 }
387 393
388 } // namespace printing 394 } // namespace printing
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/printing/print_preview_tab_controller_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698