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

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

Issue 7790020: Cleanup: Convert PrintPreviewTabController to use TabContentsWrapper. (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
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 PluginService::OverriddenPlugin plugin; 57 PluginService::OverriddenPlugin plugin;
58 plugin.render_process_id = preview_tab->render_view_host()->process()->id(); 58 plugin.render_process_id = preview_tab->render_view_host()->process()->id();
59 plugin.render_view_id = preview_tab->render_view_host()->routing_id(); 59 plugin.render_view_id = preview_tab->render_view_host()->routing_id();
60 plugin.plugin = plugins[0]; 60 plugin.plugin = plugins[0];
61 plugin.plugin.enabled = WebPluginInfo::USER_ENABLED; 61 plugin.plugin.enabled = WebPluginInfo::USER_ENABLED;
62 62
63 PluginService::GetInstance()->OverridePluginForTab(plugin); 63 PluginService::GetInstance()->OverridePluginForTab(plugin);
64 } 64 }
65 } 65 }
66 66
67 void ResetPreviewTabOverrideTitle(TabContents* preview_tab) { 67 void ResetPreviewTabOverrideTitle(TabContentsWrapper* preview_tab) {
68 TabContentsWrapper* wrapper = 68 preview_tab->print_view_manager()->ResetTitleOverride();
69 TabContentsWrapper::GetCurrentWrapperForContents(preview_tab);
70 wrapper->print_view_manager()->ResetTitleOverride();
71 } 69 }
72 70
73 } // namespace 71 } // namespace
74 72
75 namespace printing { 73 namespace printing {
76 74
77 PrintPreviewTabController::PrintPreviewTabController() 75 PrintPreviewTabController::PrintPreviewTabController()
78 : waiting_for_new_preview_page_(false) { 76 : waiting_for_new_preview_page_(false) {
79 } 77 }
80 78
81 PrintPreviewTabController::~PrintPreviewTabController() {} 79 PrintPreviewTabController::~PrintPreviewTabController() {}
82 80
83 // static 81 // static
84 PrintPreviewTabController* PrintPreviewTabController::GetInstance() { 82 PrintPreviewTabController* PrintPreviewTabController::GetInstance() {
85 if (!g_browser_process) 83 if (!g_browser_process)
86 return NULL; 84 return NULL;
87 return g_browser_process->print_preview_tab_controller(); 85 return g_browser_process->print_preview_tab_controller();
88 } 86 }
89 87
90 // static 88 // static
91 void PrintPreviewTabController::PrintPreview(TabContents* tab) { 89 void PrintPreviewTabController::PrintPreview(TabContentsWrapper* tab) {
92 if (tab->showing_interstitial_page()) 90 if (tab->tab_contents()->showing_interstitial_page())
93 return; 91 return;
94 92
95 printing::PrintPreviewTabController* tab_controller = 93 PrintPreviewTabController* tab_controller =
96 printing::PrintPreviewTabController::GetInstance(); 94 PrintPreviewTabController::GetInstance();
97 if (!tab_controller) 95 if (!tab_controller)
98 return; 96 return;
99 tab_controller->GetOrCreatePreviewTab(tab); 97 tab_controller->GetOrCreatePreviewTab(tab);
100 } 98 }
101 99
102 TabContents* PrintPreviewTabController::GetOrCreatePreviewTab( 100 TabContentsWrapper* PrintPreviewTabController::GetOrCreatePreviewTab(
103 TabContents* initiator_tab) { 101 TabContentsWrapper* initiator_tab) {
104 DCHECK(initiator_tab); 102 DCHECK(initiator_tab);
105 103
106 // Get the print preview tab for |initiator_tab|. 104 // Get the print preview tab for |initiator_tab|.
107 TabContents* preview_tab = GetPrintPreviewForTab(initiator_tab); 105 TabContentsWrapper* preview_tab = GetPrintPreviewForTab(initiator_tab);
108 if (preview_tab) { 106 if (!preview_tab)
109 // Show current preview tab. 107 return CreatePrintPreviewTab(initiator_tab);
110 static_cast<RenderViewHostDelegate*>(preview_tab)->Activate(); 108
111 return preview_tab; 109 // Show current preview tab.
112 } 110 static_cast<RenderViewHostDelegate*>(preview_tab->tab_contents())->Activate();
113 return CreatePrintPreviewTab(initiator_tab); 111 return preview_tab;
114 } 112 }
115 113
116 TabContents* PrintPreviewTabController::GetPrintPreviewForTab( 114 TabContentsWrapper* PrintPreviewTabController::GetPrintPreviewForTab(
117 TabContents* tab) const { 115 TabContentsWrapper* tab) const {
118 // |preview_tab_map_| is keyed by the preview tab, so if find() succeeds, then 116 // |preview_tab_map_| is keyed by the preview tab, so if find() succeeds, then
119 // |tab| is the preview tab. 117 // |tab| is the preview tab.
120 PrintPreviewTabMap::const_iterator it = preview_tab_map_.find(tab); 118 PrintPreviewTabMap::const_iterator it = preview_tab_map_.find(tab);
121 if (it != preview_tab_map_.end()) 119 if (it != preview_tab_map_.end())
122 return tab; 120 return tab;
123 121
124 for (it = preview_tab_map_.begin(); it != preview_tab_map_.end(); ++it) { 122 for (it = preview_tab_map_.begin(); it != preview_tab_map_.end(); ++it) {
125 // If |tab| is an initiator tab. 123 // If |tab| is an initiator tab.
126 if (tab == it->second) { 124 if (tab == it->second) {
127 // Return the associated preview tab. 125 // Return the associated preview tab.
128 return it->first; 126 return it->first;
129 } 127 }
130 } 128 }
131 return NULL; 129 return NULL;
132 } 130 }
133 131
134 void PrintPreviewTabController::Observe(int type, 132 void PrintPreviewTabController::Observe(int type,
135 const NotificationSource& source, 133 const NotificationSource& source,
136 const NotificationDetails& details) { 134 const NotificationDetails& details) {
137 switch (type) { 135 switch (type) {
138 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { 136 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: {
139 OnRendererProcessClosed(Source<RenderProcessHost>(source).ptr()); 137 OnRendererProcessClosed(Source<RenderProcessHost>(source).ptr());
140 break; 138 break;
141 } 139 }
142 case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: { 140 case content::NOTIFICATION_TAB_CONTENTS_DESTROYED: {
143 OnTabContentsDestroyed(Source<TabContents>(source).ptr()); 141 TabContents* tab = Source<TabContents>(source).ptr();
142 TabContentsWrapper* wrapper =
143 TabContentsWrapper::GetCurrentWrapperForContents(tab);
144 OnTabContentsDestroyed(wrapper);
144 break; 145 break;
145 } 146 }
146 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: { 147 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: {
147 NavigationController* controller = 148 NavigationController* controller =
148 Source<NavigationController>(source).ptr(); 149 Source<NavigationController>(source).ptr();
150 TabContentsWrapper* wrapper =
151 TabContentsWrapper::GetCurrentWrapperForContents(
152 controller->tab_contents());
149 content::LoadCommittedDetails* load_details = 153 content::LoadCommittedDetails* load_details =
150 Details<content::LoadCommittedDetails>(details).ptr(); 154 Details<content::LoadCommittedDetails>(details).ptr();
151 OnNavEntryCommitted(controller->tab_contents(), load_details); 155 OnNavEntryCommitted(wrapper, load_details);
152 break; 156 break;
153 } 157 }
154 default: { 158 default: {
155 NOTREACHED(); 159 NOTREACHED();
156 break; 160 break;
157 } 161 }
158 } 162 }
159 } 163 }
160 164
161 void PrintPreviewTabController::OnRendererProcessClosed( 165 void PrintPreviewTabController::OnRendererProcessClosed(
162 RenderProcessHost* rph) { 166 RenderProcessHost* rph) {
163 for (PrintPreviewTabMap::iterator iter = preview_tab_map_.begin(); 167 for (PrintPreviewTabMap::iterator iter = preview_tab_map_.begin();
164 iter != preview_tab_map_.end(); ++iter) { 168 iter != preview_tab_map_.end(); ++iter) {
165 if (iter->second != NULL && 169 if (iter->second != NULL &&
166 iter->second->render_view_host()->process() == rph) { 170 iter->second->render_view_host()->process() == rph) {
167 TabContents* preview_tab = GetPrintPreviewForTab(iter->second); 171 TabContentsWrapper* preview_tab = GetPrintPreviewForTab(iter->second);
168 PrintPreviewUI* print_preview_ui = 172 PrintPreviewUI* print_preview_ui =
169 static_cast<PrintPreviewUI*>(preview_tab->web_ui()); 173 static_cast<PrintPreviewUI*>(preview_tab->web_ui());
170 print_preview_ui->OnInitiatorTabCrashed(); 174 print_preview_ui->OnInitiatorTabCrashed();
171 } 175 }
172 } 176 }
173 } 177 }
174 178
175 void PrintPreviewTabController::OnTabContentsDestroyed(TabContents* tab) { 179 void PrintPreviewTabController::OnTabContentsDestroyed(
176 TabContents* preview_tab = GetPrintPreviewForTab(tab); 180 TabContentsWrapper* tab) {
181 TabContentsWrapper* preview_tab = GetPrintPreviewForTab(tab);
177 if (!preview_tab) 182 if (!preview_tab)
178 return; 183 return;
179 184
180 if (tab == preview_tab) { 185 if (tab == preview_tab) {
181 // Remove the initiator tab's observers before erasing the mapping. 186 // Remove the initiator tab's observers before erasing the mapping.
182 TabContents* initiator_tab = GetInitiatorTab(tab); 187 TabContentsWrapper* initiator_tab = GetInitiatorTab(tab);
183 if (initiator_tab) 188 if (initiator_tab)
184 RemoveObservers(initiator_tab); 189 RemoveObservers(initiator_tab);
185 190
186 // Print preview tab contents are destroyed. Notify |PrintPreviewUI| to 191 // Print preview tab contents are destroyed. Notify |PrintPreviewUI| to
187 // abort the initiator tab preview request. 192 // abort the initiator tab preview request.
188 if (IsPrintPreviewTab(tab) && tab->web_ui()) { 193 if (IsPrintPreviewTab(tab) && tab->web_ui()) {
189 PrintPreviewUI* print_preview_ui = 194 PrintPreviewUI* print_preview_ui =
190 static_cast<PrintPreviewUI*>(tab->web_ui()); 195 static_cast<PrintPreviewUI*>(tab->web_ui());
191 print_preview_ui->OnTabDestroyed(); 196 print_preview_ui->OnTabDestroyed();
192 } 197 }
(...skipping 10 matching lines...) Expand all
203 208
204 // |tab| is an initiator tab, update the map entry and remove observers. 209 // |tab| is an initiator tab, update the map entry and remove observers.
205 preview_tab_map_[preview_tab] = NULL; 210 preview_tab_map_[preview_tab] = NULL;
206 } 211 }
207 212
208 ResetPreviewTabOverrideTitle(preview_tab); 213 ResetPreviewTabOverrideTitle(preview_tab);
209 RemoveObservers(tab); 214 RemoveObservers(tab);
210 } 215 }
211 216
212 void PrintPreviewTabController::OnNavEntryCommitted( 217 void PrintPreviewTabController::OnNavEntryCommitted(
213 TabContents* tab, content::LoadCommittedDetails* details) { 218 TabContentsWrapper* tab, content::LoadCommittedDetails* details) {
214 TabContents* preview_tab = GetPrintPreviewForTab(tab); 219 TabContentsWrapper* preview_tab = GetPrintPreviewForTab(tab);
215 bool source_tab_is_preview_tab = (tab == preview_tab); 220 bool source_tab_is_preview_tab = (tab == preview_tab);
216 if (details) { 221 if (details) {
217 PageTransition::Type transition_type = details->entry->transition_type(); 222 PageTransition::Type transition_type = details->entry->transition_type();
218 NavigationType::Type nav_type = details->type; 223 NavigationType::Type nav_type = details->type;
219 224
220 // Don't update/erase the map entry if the page has not changed. 225 // Don't update/erase the map entry if the page has not changed.
221 if (transition_type == PageTransition::RELOAD || 226 if (transition_type == PageTransition::RELOAD ||
222 nav_type == NavigationType::SAME_PAGE) { 227 nav_type == NavigationType::SAME_PAGE) {
223 if (source_tab_is_preview_tab) 228 if (source_tab_is_preview_tab)
224 SetInitiatorTabURLAndTitle(preview_tab); 229 SetInitiatorTabURLAndTitle(preview_tab);
(...skipping 15 matching lines...) Expand all
240 transition_type == PageTransition::FORWARD_BACK && 245 transition_type == PageTransition::FORWARD_BACK &&
241 nav_type == NavigationType::EXISTING_PAGE) { 246 nav_type == NavigationType::EXISTING_PAGE) {
242 return; 247 return;
243 } 248 }
244 } 249 }
245 250
246 RemoveObservers(tab); 251 RemoveObservers(tab);
247 ResetPreviewTabOverrideTitle(preview_tab); 252 ResetPreviewTabOverrideTitle(preview_tab);
248 if (source_tab_is_preview_tab) { 253 if (source_tab_is_preview_tab) {
249 // Remove the initiator tab's observers before erasing the mapping. 254 // Remove the initiator tab's observers before erasing the mapping.
250 TabContents* initiator_tab = GetInitiatorTab(tab); 255 TabContentsWrapper* initiator_tab = GetInitiatorTab(tab);
251 if (initiator_tab) 256 if (initiator_tab)
252 RemoveObservers(initiator_tab); 257 RemoveObservers(initiator_tab);
253 preview_tab_map_.erase(tab); 258 preview_tab_map_.erase(tab);
254 } else { 259 } else {
255 preview_tab_map_[preview_tab] = NULL; 260 preview_tab_map_[preview_tab] = NULL;
256 261
257 // Initiator tab is closed. Disable the controls in preview tab. 262 // Initiator tab is closed. Disable the controls in preview tab.
258 if (preview_tab->web_ui()) { 263 if (preview_tab->web_ui()) {
259 PrintPreviewUI* print_preview_ui = 264 PrintPreviewUI* print_preview_ui =
260 static_cast<PrintPreviewUI*>(preview_tab->web_ui()); 265 static_cast<PrintPreviewUI*>(preview_tab->web_ui());
261 print_preview_ui->OnInitiatorTabClosed(); 266 print_preview_ui->OnInitiatorTabClosed();
262 } 267 }
263 } 268 }
264 } 269 }
265 270
266 // static 271 // static
267 bool PrintPreviewTabController::IsPrintPreviewTab(TabContents* tab) { 272 bool PrintPreviewTabController::IsPrintPreviewTab(TabContentsWrapper* tab) {
268 const GURL& url = tab->GetURL(); 273 const GURL& url = tab->tab_contents()->GetURL();
269 return (url.SchemeIs(chrome::kChromeUIScheme) && 274 return (url.SchemeIs(chrome::kChromeUIScheme) &&
270 url.host() == chrome::kChromeUIPrintHost); 275 url.host() == chrome::kChromeUIPrintHost);
271 } 276 }
272 277
273 void PrintPreviewTabController::EraseInitiatorTabInfo( 278 void PrintPreviewTabController::EraseInitiatorTabInfo(
274 TabContents* preview_tab) { 279 TabContentsWrapper* preview_tab) {
275 PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab); 280 PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab);
276 if (it == preview_tab_map_.end()) 281 if (it == preview_tab_map_.end())
277 return; 282 return;
278 283
279 RemoveObservers(it->second); 284 RemoveObservers(it->second);
280 preview_tab_map_[preview_tab] = NULL; 285 preview_tab_map_[preview_tab] = NULL;
281 ResetPreviewTabOverrideTitle(preview_tab); 286 ResetPreviewTabOverrideTitle(preview_tab);
282 } 287 }
283 288
284 TabContents* PrintPreviewTabController::GetInitiatorTab( 289 TabContentsWrapper* PrintPreviewTabController::GetInitiatorTab(
285 TabContents* preview_tab) { 290 TabContentsWrapper* preview_tab) {
286 PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab); 291 PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab);
287 if (it != preview_tab_map_.end()) 292 if (it != preview_tab_map_.end())
288 return preview_tab_map_[preview_tab]; 293 return preview_tab_map_[preview_tab];
289 return NULL; 294 return NULL;
290 } 295 }
291 296
292 TabContents* PrintPreviewTabController::CreatePrintPreviewTab( 297 TabContentsWrapper* PrintPreviewTabController::CreatePrintPreviewTab(
293 TabContents* initiator_tab) { 298 TabContentsWrapper* initiator_tab) {
294 // TODO: this should be converted to TabContentsWrapper.
295 TabContentsWrapper* tab =
296 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab);
297 DCHECK(tab);
298 Browser* current_browser = BrowserList::FindBrowserWithID( 299 Browser* current_browser = BrowserList::FindBrowserWithID(
299 tab->restore_tab_helper()->window_id().id()); 300 initiator_tab->restore_tab_helper()->window_id().id());
300 if (!current_browser) { 301 if (!current_browser) {
301 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeFrame)) { 302 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeFrame)) {
302 Profile* profile = 303 Profile* profile = Profile::FromBrowserContext(
303 Profile::FromBrowserContext(initiator_tab->browser_context()); 304 initiator_tab->tab_contents()->browser_context());
304 current_browser = Browser::CreateForType(Browser::TYPE_POPUP, profile); 305 current_browser = Browser::CreateForType(Browser::TYPE_POPUP, profile);
305 if (!current_browser) { 306 if (!current_browser) {
306 NOTREACHED() << "Failed to create popup browser window"; 307 NOTREACHED() << "Failed to create popup browser window";
307 return NULL; 308 return NULL;
308 } 309 }
309 } else { 310 } else {
310 return NULL; 311 return NULL;
311 } 312 }
312 } 313 }
313 314
314 // Add a new tab next to initiator tab. 315 // Add a new tab next to initiator tab.
315 browser::NavigateParams params(current_browser, 316 browser::NavigateParams params(current_browser,
316 GURL(chrome::kChromeUIPrintURL), 317 GURL(chrome::kChromeUIPrintURL),
317 PageTransition::LINK); 318 PageTransition::LINK);
318 params.disposition = NEW_FOREGROUND_TAB; 319 params.disposition = NEW_FOREGROUND_TAB;
319 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeFrame)) 320 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kChromeFrame))
320 params.disposition = NEW_POPUP; 321 params.disposition = NEW_POPUP;
321 params.tabstrip_index = current_browser->tabstrip_model()-> 322 params.tabstrip_index = current_browser->tabstrip_model()->
322 GetWrapperIndex(initiator_tab) + 1; 323 GetIndexOfTabContents(initiator_tab) + 1;
323 browser::Navigate(&params); 324 browser::Navigate(&params);
324 TabContentsWrapper* preview_tab = params.target_contents; 325 TabContentsWrapper* preview_tab = params.target_contents;
325 EnableInternalPDFPluginForTab(preview_tab); 326 EnableInternalPDFPluginForTab(preview_tab);
326 static_cast<RenderViewHostDelegate*>(preview_tab->tab_contents())->Activate(); 327 static_cast<RenderViewHostDelegate*>(preview_tab->tab_contents())->Activate();
327 328
328 // Add an entry to the map. 329 // Add an entry to the map.
329 preview_tab_map_[preview_tab->tab_contents()] = initiator_tab; 330 preview_tab_map_[preview_tab] = initiator_tab;
330 waiting_for_new_preview_page_ = true; 331 waiting_for_new_preview_page_ = true;
331 332
332 AddObservers(initiator_tab); 333 AddObservers(initiator_tab);
333 AddObservers(preview_tab->tab_contents()); 334 AddObservers(preview_tab);
334 335
335 return preview_tab->tab_contents(); 336 return preview_tab;
336 } 337 }
337 338
338 void PrintPreviewTabController::SetInitiatorTabURLAndTitle( 339 void PrintPreviewTabController::SetInitiatorTabURLAndTitle(
339 TabContents* preview_tab) { 340 TabContentsWrapper* preview_tab) {
340 TabContents* initiator_tab = GetInitiatorTab(preview_tab); 341 TabContentsWrapper* initiator_tab = GetInitiatorTab(preview_tab);
341 if (initiator_tab && preview_tab->web_ui()) { 342 if (initiator_tab && preview_tab->web_ui()) {
342 PrintPreviewUI* print_preview_ui = 343 PrintPreviewUI* print_preview_ui =
343 static_cast<PrintPreviewUI*>(preview_tab->web_ui()); 344 static_cast<PrintPreviewUI*>(preview_tab->web_ui());
344 TabContentsWrapper* wrapper =
345 TabContentsWrapper::GetCurrentWrapperForContents(initiator_tab);
346 print_preview_ui->SetInitiatorTabURLAndTitle( 345 print_preview_ui->SetInitiatorTabURLAndTitle(
347 initiator_tab->GetURL().spec(), 346 initiator_tab->tab_contents()->GetURL().spec(),
348 wrapper->print_view_manager()->RenderSourceName()); 347 initiator_tab->print_view_manager()->RenderSourceName());
349 } 348 }
350 } 349 }
351 350
352 void PrintPreviewTabController::AddObservers(TabContents* tab) { 351 void PrintPreviewTabController::AddObservers(TabContentsWrapper* tab) {
352 TabContents* contents = tab->tab_contents();
353 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, 353 registrar_.Add(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
354 Source<TabContents>(tab)); 354 Source<TabContents>(contents));
355 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 355 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
356 Source<NavigationController>(&tab->controller())); 356 Source<NavigationController>(&contents->controller()));
357 357
358 // Multiple sites may share the same RenderProcessHost, so check if this 358 // Multiple sites may share the same RenderProcessHost, so check if this
359 // notification has already been added. 359 // notification has already been added.
360 RenderProcessHost* rph = tab->render_view_host()->process(); 360 RenderProcessHost* rph = tab->render_view_host()->process();
361 if (!registrar_.IsRegistered(this, 361 if (!registrar_.IsRegistered(this,
362 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 362 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
363 Source<RenderProcessHost>(rph))) { 363 Source<RenderProcessHost>(rph))) {
364 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 364 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
365 Source<RenderProcessHost>(rph)); 365 Source<RenderProcessHost>(rph));
366 } 366 }
367 } 367 }
368 368
369 void PrintPreviewTabController::RemoveObservers(TabContents* tab) { 369 void PrintPreviewTabController::RemoveObservers(TabContentsWrapper* tab) {
370 TabContents* contents = tab->tab_contents();
370 registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED, 371 registrar_.Remove(this, content::NOTIFICATION_TAB_CONTENTS_DESTROYED,
371 Source<TabContents>(tab)); 372 Source<TabContents>(contents));
372 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 373 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
373 Source<NavigationController>(&tab->controller())); 374 Source<NavigationController>(&contents->controller()));
374 375
375 // Multiple sites may share the same RenderProcessHost, so check if this 376 // Multiple sites may share the same RenderProcessHost, so check if this
376 // notification has already been added. 377 // notification has already been added.
377 RenderProcessHost* rph = tab->render_view_host()->process(); 378 RenderProcessHost* rph = tab->render_view_host()->process();
378 if (registrar_.IsRegistered(this, 379 if (registrar_.IsRegistered(this,
379 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 380 content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
380 Source<RenderProcessHost>(rph))) { 381 Source<RenderProcessHost>(rph))) {
381 registrar_.Remove(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED, 382 registrar_.Remove(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSED,
382 Source<RenderProcessHost>(rph)); 383 Source<RenderProcessHost>(rph));
383 } 384 }
384 } 385 }
385 386
386 } // namespace printing 387 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698