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

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

Issue 10905301: Switch CoreTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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) 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_tab_controller.h" 5 #include "chrome/browser/printing/print_preview_tab_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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 public: 158 public:
159 PrintPreviewWebContentDelegate(Profile* profile, TabContents* initiator_tab); 159 PrintPreviewWebContentDelegate(Profile* profile, TabContents* initiator_tab);
160 virtual ~PrintPreviewWebContentDelegate(); 160 virtual ~PrintPreviewWebContentDelegate();
161 161
162 // Overridden from WebDialogWebContentsDelegate: 162 // Overridden from WebDialogWebContentsDelegate:
163 virtual void HandleKeyboardEvent( 163 virtual void HandleKeyboardEvent(
164 WebContents* source, 164 WebContents* source,
165 const NativeWebKeyboardEvent& event) OVERRIDE; 165 const NativeWebKeyboardEvent& event) OVERRIDE;
166 166
167 // Overridden from CoreTabHelperDelegate: 167 // Overridden from CoreTabHelperDelegate:
168 virtual bool CanReloadContents(TabContents* source) const OVERRIDE; 168 virtual bool CanReloadContents(
169 virtual bool CanSaveContents(TabContents* source) const OVERRIDE; 169 content::WebContents* web_contents) const OVERRIDE;
170 virtual bool CanSaveContents(
171 content::WebContents* web_contents) const OVERRIDE;
170 172
171 private: 173 private:
172 TabContents* tab_; 174 TabContents* tab_;
173 175
174 DISALLOW_COPY_AND_ASSIGN(PrintPreviewWebContentDelegate); 176 DISALLOW_COPY_AND_ASSIGN(PrintPreviewWebContentDelegate);
175 }; 177 };
176 178
177 PrintPreviewWebContentDelegate::PrintPreviewWebContentDelegate( 179 PrintPreviewWebContentDelegate::PrintPreviewWebContentDelegate(
178 Profile* profile, 180 Profile* profile,
179 TabContents* initiator_tab) 181 TabContents* initiator_tab)
180 : WebDialogWebContentsDelegate(profile, new ChromeWebContentsHandler), 182 : WebDialogWebContentsDelegate(profile, new ChromeWebContentsHandler),
181 tab_(initiator_tab) {} 183 tab_(initiator_tab) {}
182 184
183 PrintPreviewWebContentDelegate::~PrintPreviewWebContentDelegate() {} 185 PrintPreviewWebContentDelegate::~PrintPreviewWebContentDelegate() {}
184 186
185 bool PrintPreviewWebContentDelegate::CanReloadContents( 187 bool PrintPreviewWebContentDelegate::CanReloadContents(
186 TabContents* source) const { 188 content::WebContents* web_contents) const {
187 return false; 189 return false;
188 } 190 }
189 191
190 bool PrintPreviewWebContentDelegate::CanSaveContents( 192 bool PrintPreviewWebContentDelegate::CanSaveContents(
191 TabContents* source) const { 193 content::WebContents* web_contents) const {
192 return false; 194 return false;
193 } 195 }
194 196
195 void PrintPreviewWebContentDelegate::HandleKeyboardEvent( 197 void PrintPreviewWebContentDelegate::HandleKeyboardEvent(
196 WebContents* source, 198 WebContents* source,
197 const NativeWebKeyboardEvent& event) { 199 const NativeWebKeyboardEvent& event) {
198 // Disabled on Mac due to http://crbug.com/112173 200 // Disabled on Mac due to http://crbug.com/112173
199 #if !defined(OS_MACOSX) 201 #if !defined(OS_MACOSX)
200 Browser* current_browser = 202 Browser* current_browser =
201 browser::FindBrowserWithWebContents(tab_->web_contents()); 203 browser::FindBrowserWithWebContents(tab_->web_contents());
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 PrintPreviewWebContentDelegate* pp_wcd = 427 PrintPreviewWebContentDelegate* pp_wcd =
426 new PrintPreviewWebContentDelegate(profile, initiator_tab); 428 new PrintPreviewWebContentDelegate(profile, initiator_tab);
427 ConstrainedWebDialogDelegate* constrained_delegate = 429 ConstrainedWebDialogDelegate* constrained_delegate =
428 ui::CreateConstrainedWebDialog( 430 ui::CreateConstrainedWebDialog(
429 profile, 431 profile,
430 web_dialog_delegate, 432 web_dialog_delegate,
431 pp_wcd, 433 pp_wcd,
432 initiator_tab); 434 initiator_tab);
433 TabContents* preview_tab = constrained_delegate->tab(); 435 TabContents* preview_tab = constrained_delegate->tab();
434 EnableInternalPDFPluginForTab(preview_tab); 436 EnableInternalPDFPluginForTab(preview_tab);
435 preview_tab->core_tab_helper()->set_delegate(pp_wcd); 437 CoreTabHelper::FromWebContents(preview_tab->web_contents())->
438 set_delegate(pp_wcd);
436 439
437 // Add an entry to the map. 440 // Add an entry to the map.
438 preview_tab_map_[preview_tab] = initiator_tab; 441 preview_tab_map_[preview_tab] = initiator_tab;
439 waiting_for_new_preview_page_ = true; 442 waiting_for_new_preview_page_ = true;
440 443
441 AddObservers(initiator_tab); 444 AddObservers(initiator_tab);
442 AddObservers(preview_tab); 445 AddObservers(preview_tab);
443 446
444 return preview_tab; 447 return preview_tab;
445 } 448 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( 526 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
524 preview_tab->web_contents()->GetWebUI()->GetController()); 527 preview_tab->web_contents()->GetWebUI()->GetController());
525 if (print_preview_ui) 528 if (print_preview_ui)
526 print_preview_ui->OnTabDestroyed(); 529 print_preview_ui->OnTabDestroyed();
527 530
528 preview_tab_map_.erase(preview_tab); 531 preview_tab_map_.erase(preview_tab);
529 RemoveObservers(preview_tab); 532 RemoveObservers(preview_tab);
530 } 533 }
531 534
532 } // namespace printing 535 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698