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

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

Issue 8515027: Define the public version of the browser side RenderProcessHost interface. This interface is not ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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) 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 <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 23 matching lines...) Expand all
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/notification_types.h" 36 #include "content/public/browser/notification_types.h"
37 #include "webkit/plugins/webplugininfo.h" 37 #include "webkit/plugins/webplugininfo.h"
38 38
39 namespace { 39 namespace {
40 40
41 void EnableInternalPDFPluginForTab(TabContentsWrapper* preview_tab) { 41 void EnableInternalPDFPluginForTab(TabContentsWrapper* preview_tab) {
42 // Always enable the internal PDF plugin for the print preview page. 42 // Always enable the internal PDF plugin for the print preview page.
43 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( 43 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab(
44 preview_tab->render_view_host()->process()->id(), 44 preview_tab->render_view_host()->process()->GetID(),
45 preview_tab->render_view_host()->routing_id(), 45 preview_tab->render_view_host()->routing_id(),
46 GURL(), 46 GURL(),
47 ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName)); 47 ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName));
48 } 48 }
49 49
50 class PrintPreviewTabDelegate : public HtmlDialogUIDelegate { 50 class PrintPreviewTabDelegate : public HtmlDialogUIDelegate {
51 public: 51 public:
52 explicit PrintPreviewTabDelegate(TabContentsWrapper* initiator_tab); 52 explicit PrintPreviewTabDelegate(TabContentsWrapper* initiator_tab);
53 virtual ~PrintPreviewTabDelegate(); 53 virtual ~PrintPreviewTabDelegate();
54 54
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } 189 }
190 return NULL; 190 return NULL;
191 } 191 }
192 192
193 void PrintPreviewTabController::Observe( 193 void PrintPreviewTabController::Observe(
194 int type, 194 int type,
195 const content::NotificationSource& source, 195 const content::NotificationSource& source,
196 const content::NotificationDetails& details) { 196 const content::NotificationDetails& details) {
197 switch (type) { 197 switch (type) {
198 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { 198 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: {
199 OnRendererProcessClosed(content::Source<RenderProcessHost>(source).ptr()); 199 OnRendererProcessClosed(
200 content::Source<content::RenderProcessHost>(source).ptr());
200 break; 201 break;
201 } 202 }
202 case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: { 203 case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: {
203 TabContents* tab = content::Source<TabContents>(source).ptr(); 204 TabContents* tab = content::Source<TabContents>(source).ptr();
204 TabContentsWrapper* wrapper = 205 TabContentsWrapper* wrapper =
205 TabContentsWrapper::GetCurrentWrapperForContents(tab); 206 TabContentsWrapper::GetCurrentWrapperForContents(tab);
206 OnTabContentsDestroyed(wrapper); 207 OnTabContentsDestroyed(wrapper);
207 break; 208 break;
208 } 209 }
209 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: { 210 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: {
210 NavigationController* controller = 211 NavigationController* controller =
211 content::Source<NavigationController>(source).ptr(); 212 content::Source<NavigationController>(source).ptr();
212 TabContentsWrapper* wrapper = 213 TabContentsWrapper* wrapper =
213 TabContentsWrapper::GetCurrentWrapperForContents( 214 TabContentsWrapper::GetCurrentWrapperForContents(
214 controller->tab_contents()); 215 controller->tab_contents());
215 content::LoadCommittedDetails* load_details = 216 content::LoadCommittedDetails* load_details =
216 content::Details<content::LoadCommittedDetails>(details).ptr(); 217 content::Details<content::LoadCommittedDetails>(details).ptr();
217 OnNavEntryCommitted(wrapper, load_details); 218 OnNavEntryCommitted(wrapper, load_details);
218 break; 219 break;
219 } 220 }
220 default: { 221 default: {
221 NOTREACHED(); 222 NOTREACHED();
222 break; 223 break;
223 } 224 }
224 } 225 }
225 } 226 }
226 227
227 void PrintPreviewTabController::OnRendererProcessClosed( 228 void PrintPreviewTabController::OnRendererProcessClosed(
228 RenderProcessHost* rph) { 229 content::RenderProcessHost* rph) {
229 // Store tabs in a vector and deal with them after iterating through 230 // Store tabs in a vector and deal with them after iterating through
230 // |preview_tab_map_| because RemoveFooTab() can change |preview_tab_map_|. 231 // |preview_tab_map_| because RemoveFooTab() can change |preview_tab_map_|.
231 std::vector<TabContentsWrapper*> closed_initiator_tabs; 232 std::vector<TabContentsWrapper*> closed_initiator_tabs;
232 std::vector<TabContentsWrapper*> closed_preview_tabs; 233 std::vector<TabContentsWrapper*> closed_preview_tabs;
233 for (PrintPreviewTabMap::iterator iter = preview_tab_map_.begin(); 234 for (PrintPreviewTabMap::iterator iter = preview_tab_map_.begin();
234 iter != preview_tab_map_.end(); ++iter) { 235 iter != preview_tab_map_.end(); ++iter) {
235 TabContentsWrapper* preview_tab = iter->first; 236 TabContentsWrapper* preview_tab = iter->first;
236 TabContentsWrapper* initiator_tab = iter->second; 237 TabContentsWrapper* initiator_tab = iter->second;
237 if (preview_tab->render_view_host()->process() == rph) { 238 if (preview_tab->render_view_host()->process() == rph) {
238 closed_preview_tabs.push_back(preview_tab); 239 closed_preview_tabs.push_back(preview_tab);
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 void PrintPreviewTabController::AddObservers(TabContentsWrapper* tab) { 398 void PrintPreviewTabController::AddObservers(TabContentsWrapper* tab) {
398 TabContents* contents = tab->tab_contents(); 399 TabContents* contents = tab->tab_contents();
399 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, 400 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
400 content::Source<TabContents>(contents)); 401 content::Source<TabContents>(contents));
401 registrar_.Add( 402 registrar_.Add(
402 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 403 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
403 content::Source<NavigationController>(&contents->controller())); 404 content::Source<NavigationController>(&contents->controller()));
404 405
405 // Multiple sites may share the same RenderProcessHost, so check if this 406 // Multiple sites may share the same RenderProcessHost, so check if this
406 // notification has already been added. 407 // notification has already been added.
407 RenderProcessHost* rph = tab->render_view_host()->process(); 408 content::RenderProcessHost* rph = tab->render_view_host()->process();
408 if (!registrar_.IsRegistered(this, 409 if (!registrar_.IsRegistered(this,
409 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 410 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
410 content::Source<RenderProcessHost>(rph))) { 411 content::Source<content::RenderProcessHost>(
412 rph))) {
411 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 413 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
412 content::Source<RenderProcessHost>(rph)); 414 content::Source<content::RenderProcessHost>(rph));
413 } 415 }
414 } 416 }
415 417
416 void PrintPreviewTabController::RemoveObservers(TabContentsWrapper* tab) { 418 void PrintPreviewTabController::RemoveObservers(TabContentsWrapper* tab) {
417 TabContents* contents = tab->tab_contents(); 419 TabContents* contents = tab->tab_contents();
418 registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, 420 registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
419 content::Source<TabContents>(contents)); 421 content::Source<TabContents>(contents));
420 registrar_.Remove( 422 registrar_.Remove(
421 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 423 this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
422 content::Source<NavigationController>(&contents->controller())); 424 content::Source<NavigationController>(&contents->controller()));
423 425
424 // Multiple sites may share the same RenderProcessHost, so check if this 426 // Multiple sites may share the same RenderProcessHost, so check if this
425 // notification has already been added. 427 // notification has already been added.
426 RenderProcessHost* rph = tab->render_view_host()->process(); 428 content::RenderProcessHost* rph = tab->render_view_host()->process();
427 if (registrar_.IsRegistered(this, 429 if (registrar_.IsRegistered(this,
428 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 430 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
429 content::Source<RenderProcessHost>(rph))) { 431 content::Source<content::RenderProcessHost>(
432 rph))) {
430 registrar_.Remove(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 433 registrar_.Remove(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
431 content::Source<RenderProcessHost>(rph)); 434 content::Source<content::RenderProcessHost>(rph));
432 } 435 }
433 } 436 }
434 437
435 void PrintPreviewTabController::RemoveInitiatorTab( 438 void PrintPreviewTabController::RemoveInitiatorTab(
436 TabContentsWrapper* initiator_tab) { 439 TabContentsWrapper* initiator_tab) {
437 TabContentsWrapper* preview_tab = GetPrintPreviewForTab(initiator_tab); 440 TabContentsWrapper* preview_tab = GetPrintPreviewForTab(initiator_tab);
438 DCHECK(preview_tab); 441 DCHECK(preview_tab);
439 // Update the map entry first, so when the print preview tab gets destroyed 442 // Update the map entry first, so when the print preview tab gets destroyed
440 // and reaches RemovePreviewTab(), it does not attempt to also remove the 443 // and reaches RemovePreviewTab(), it does not attempt to also remove the
441 // initiator tab's observers. 444 // initiator tab's observers.
(...skipping 19 matching lines...) Expand all
461 PrintPreviewUI* print_preview_ui = 464 PrintPreviewUI* print_preview_ui =
462 static_cast<PrintPreviewUI*>(preview_tab->web_ui()); 465 static_cast<PrintPreviewUI*>(preview_tab->web_ui());
463 if (print_preview_ui) 466 if (print_preview_ui)
464 print_preview_ui->OnTabDestroyed(); 467 print_preview_ui->OnTabDestroyed();
465 468
466 preview_tab_map_.erase(preview_tab); 469 preview_tab_map_.erase(preview_tab);
467 RemoveObservers(preview_tab); 470 RemoveObservers(preview_tab);
468 } 471 }
469 472
470 } // namespace printing 473 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_preview_tab_controller.h ('k') | chrome/browser/profiles/profile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698