| OLD | NEW |
| 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 Loading... |
| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 PrintPreviewWebContentDelegate* pp_wcd = | 429 PrintPreviewWebContentDelegate* pp_wcd = |
| 428 new PrintPreviewWebContentDelegate(profile, initiator_tab); | 430 new PrintPreviewWebContentDelegate(profile, initiator_tab); |
| 429 ConstrainedWebDialogDelegate* constrained_delegate = | 431 ConstrainedWebDialogDelegate* constrained_delegate = |
| 430 ui::CreateConstrainedWebDialog( | 432 ui::CreateConstrainedWebDialog( |
| 431 profile, | 433 profile, |
| 432 web_dialog_delegate, | 434 web_dialog_delegate, |
| 433 pp_wcd, | 435 pp_wcd, |
| 434 initiator_tab); | 436 initiator_tab); |
| 435 TabContents* preview_tab = constrained_delegate->tab(); | 437 TabContents* preview_tab = constrained_delegate->tab(); |
| 436 EnableInternalPDFPluginForTab(preview_tab); | 438 EnableInternalPDFPluginForTab(preview_tab); |
| 437 preview_tab->core_tab_helper()->set_delegate(pp_wcd); | 439 CoreTabHelper::FromWebContents(preview_tab->web_contents())-> |
| 440 set_delegate(pp_wcd); |
| 438 | 441 |
| 439 // Add an entry to the map. | 442 // Add an entry to the map. |
| 440 preview_tab_map_[preview_tab] = initiator_tab; | 443 preview_tab_map_[preview_tab] = initiator_tab; |
| 441 waiting_for_new_preview_page_ = true; | 444 waiting_for_new_preview_page_ = true; |
| 442 | 445 |
| 443 AddObservers(initiator_tab); | 446 AddObservers(initiator_tab); |
| 444 AddObservers(preview_tab); | 447 AddObservers(preview_tab); |
| 445 | 448 |
| 446 return preview_tab; | 449 return preview_tab; |
| 447 } | 450 } |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( | 531 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( |
| 529 preview_tab->web_contents()->GetWebUI()->GetController()); | 532 preview_tab->web_contents()->GetWebUI()->GetController()); |
| 530 if (print_preview_ui) | 533 if (print_preview_ui) |
| 531 print_preview_ui->OnTabDestroyed(); | 534 print_preview_ui->OnTabDestroyed(); |
| 532 | 535 |
| 533 preview_tab_map_.erase(preview_tab); | 536 preview_tab_map_.erase(preview_tab); |
| 534 RemoveObservers(preview_tab); | 537 RemoveObservers(preview_tab); |
| 535 } | 538 } |
| 536 | 539 |
| 537 } // namespace printing | 540 } // namespace printing |
| OLD | NEW |