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

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

Issue 10353007: Extract a minimal subset of WebDialogUI/WebDialogDelegate from src/chrome -> src/ui/web_dialogs Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 7 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
11 #include "base/auto_reset.h" 11 #include "base/auto_reset.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chrome_plugin_service_filter.h" 15 #include "chrome/browser/chrome_plugin_service_filter.h"
16 #include "chrome/browser/printing/print_view_manager.h" 16 #include "chrome/browser/printing/print_view_manager.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/tabs/tab_strip_model.h" 18 #include "chrome/browser/tabs/tab_strip_model.h"
19 #include "chrome/browser/ui/browser.h" 19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_list.h" 20 #include "chrome/browser/ui/browser_list.h"
21 #include "chrome/browser/ui/browser_navigator.h" 21 #include "chrome/browser/ui/browser_navigator.h"
22 #include "chrome/browser/ui/browser_window.h" 22 #include "chrome/browser/ui/browser_window.h"
23 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 23 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
24 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" 24 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
25 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h" 25 #include "chrome/browser/ui/webui/print_preview/print_preview_ui.h"
26 #include "chrome/browser/ui/webui/web_dialog_web_contents_delegate.h" 26 #include "chrome/browser/ui/webui/chrome_web_dialog_web_contents_delegate.h"
mazda 2012/05/03 22:56:22 Please sort alphabetically by running tools/sort-h
27 #include "chrome/browser/ui/webui/web_dialog_ui.h" 27 #include "ui/web_dialogs/web_dialog_ui.h"
28 #include "chrome/common/chrome_content_client.h" 28 #include "chrome/common/chrome_content_client.h"
29 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/url_constants.h" 30 #include "chrome/common/url_constants.h"
31 #include "content/public/browser/navigation_controller.h" 31 #include "content/public/browser/navigation_controller.h"
32 #include "content/public/browser/navigation_details.h" 32 #include "content/public/browser/navigation_details.h"
33 #include "content/public/browser/navigation_entry.h" 33 #include "content/public/browser/navigation_entry.h"
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 "content/public/browser/render_process_host.h" 37 #include "content/public/browser/render_process_host.h"
(...skipping 12 matching lines...) Expand all
50 // Always enable the internal PDF plugin for the print preview page. 50 // Always enable the internal PDF plugin for the print preview page.
51 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab( 51 ChromePluginServiceFilter::GetInstance()->OverridePluginForTab(
52 preview_tab->web_contents()->GetRenderProcessHost()->GetID(), 52 preview_tab->web_contents()->GetRenderProcessHost()->GetID(),
53 preview_tab->web_contents()->GetRenderViewHost()->GetRoutingID(), 53 preview_tab->web_contents()->GetRenderViewHost()->GetRoutingID(),
54 GURL(), 54 GURL(),
55 ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName)); 55 ASCIIToUTF16(chrome::ChromeContentClient::kPDFPluginName));
56 } 56 }
57 57
58 // WebDialogDelegate that specifies what the print preview dialog 58 // WebDialogDelegate that specifies what the print preview dialog
59 // will look like. 59 // will look like.
60 class PrintPreviewTabDelegate : public WebDialogDelegate { 60 class PrintPreviewTabDelegate : public views::WebDialogDelegate {
61 public: 61 public:
62 explicit PrintPreviewTabDelegate(TabContentsWrapper* initiator_tab); 62 explicit PrintPreviewTabDelegate(TabContentsWrapper* initiator_tab);
63 virtual ~PrintPreviewTabDelegate(); 63 virtual ~PrintPreviewTabDelegate();
64 64
65 // Overridden from WebDialogDelegate: 65 // Overridden from WebDialogDelegate:
66 virtual ui::ModalType GetDialogModalType() const OVERRIDE; 66 virtual ui::ModalType GetDialogModalType() const OVERRIDE;
67 virtual string16 GetDialogTitle() const OVERRIDE; 67 virtual string16 GetDialogTitle() const OVERRIDE;
68 virtual GURL GetDialogContentURL() const OVERRIDE; 68 virtual GURL GetDialogContentURL() const OVERRIDE;
69 virtual void GetWebUIMessageHandlers( 69 virtual void GetWebUIMessageHandlers(
70 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE; 70 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 } 142 }
143 143
144 bool PrintPreviewTabDelegate::ShouldShowDialogTitle() const { 144 bool PrintPreviewTabDelegate::ShouldShowDialogTitle() const {
145 // Not used, returning dummy value. 145 // Not used, returning dummy value.
146 NOTREACHED(); 146 NOTREACHED();
147 return false; 147 return false;
148 } 148 }
149 149
150 // WebContentsDelegate that forwards shortcut keys in the print preview 150 // WebContentsDelegate that forwards shortcut keys in the print preview
151 // renderer to the browser. 151 // renderer to the browser.
152 class PrintPreviewWebContentDelegate : public WebDialogWebContentsDelegate { 152 class PrintPreviewWebContentDelegate
153 : public ChromeWebDialogWebContentsDelegate {
153 public: 154 public:
154 PrintPreviewWebContentDelegate(Profile* profile, 155 PrintPreviewWebContentDelegate(Profile* profile,
155 TabContentsWrapper* initiator_tab); 156 TabContentsWrapper* initiator_tab);
156 virtual ~PrintPreviewWebContentDelegate(); 157 virtual ~PrintPreviewWebContentDelegate();
157 158
158 virtual bool CanReloadContents(WebContents* source) const OVERRIDE; 159 virtual bool CanReloadContents(WebContents* source) const OVERRIDE;
159 virtual void HandleKeyboardEvent( 160 virtual void HandleKeyboardEvent(
160 const NativeWebKeyboardEvent& event) OVERRIDE; 161 const NativeWebKeyboardEvent& event) OVERRIDE;
161 162
162 private: 163 private:
163 TabContentsWrapper* tab_; 164 TabContentsWrapper* tab_;
164 165
165 DISALLOW_COPY_AND_ASSIGN(PrintPreviewWebContentDelegate); 166 DISALLOW_COPY_AND_ASSIGN(PrintPreviewWebContentDelegate);
166 }; 167 };
167 168
168 PrintPreviewWebContentDelegate::PrintPreviewWebContentDelegate( 169 PrintPreviewWebContentDelegate::PrintPreviewWebContentDelegate(
169 Profile* profile, 170 Profile* profile,
170 TabContentsWrapper* initiator_tab) 171 TabContentsWrapper* initiator_tab)
171 : WebDialogWebContentsDelegate(profile), 172 : ChromeWebDialogWebContentsDelegate(profile),
172 tab_(initiator_tab) {} 173 tab_(initiator_tab) {}
173 174
174 PrintPreviewWebContentDelegate::~PrintPreviewWebContentDelegate() {} 175 PrintPreviewWebContentDelegate::~PrintPreviewWebContentDelegate() {}
175 176
176 bool PrintPreviewWebContentDelegate::CanReloadContents( 177 bool PrintPreviewWebContentDelegate::CanReloadContents(
177 WebContents* source) const { 178 WebContents* source) const {
178 return false; 179 return false;
179 } 180 }
180 181
181 void PrintPreviewWebContentDelegate::HandleKeyboardEvent( 182 void PrintPreviewWebContentDelegate::HandleKeyboardEvent(
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 NOTREACHED() << "Failed to create popup browser window"; 422 NOTREACHED() << "Failed to create popup browser window";
422 return NULL; 423 return NULL;
423 } 424 }
424 } else { 425 } else {
425 return NULL; 426 return NULL;
426 } 427 }
427 } 428 }
428 429
429 // |web_dialog_ui_delegate| deletes itself in 430 // |web_dialog_ui_delegate| deletes itself in
430 // PrintPreviewTabDelegate::OnDialogClosed(). 431 // PrintPreviewTabDelegate::OnDialogClosed().
431 WebDialogDelegate* web_dialog_delegate = 432 views::WebDialogDelegate* web_dialog_delegate =
432 new PrintPreviewTabDelegate(initiator_tab); 433 new PrintPreviewTabDelegate(initiator_tab);
433 // |web_tab_content_delegate|'s owner is |constrained_web_ui_delegate|. 434 // |web_tab_content_delegate|'s owner is |constrained_web_ui_delegate|.
434 PrintPreviewWebContentDelegate* pp_wcd = 435 PrintPreviewWebContentDelegate* pp_wcd =
435 new PrintPreviewWebContentDelegate(current_browser->profile(), 436 new PrintPreviewWebContentDelegate(current_browser->profile(),
436 initiator_tab); 437 initiator_tab);
437 ConstrainedWebDialogDelegate* constrained_delegate = 438 ConstrainedWebDialogDelegate* constrained_delegate =
438 ConstrainedWebDialogUI::CreateConstrainedWebDialog( 439 ConstrainedWebDialogUI::CreateConstrainedWebDialog(
439 current_browser->profile(), 440 current_browser->profile(),
440 web_dialog_delegate, 441 web_dialog_delegate,
441 pp_wcd, 442 pp_wcd,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>( 542 PrintPreviewUI* print_preview_ui = static_cast<PrintPreviewUI*>(
542 preview_tab->web_contents()->GetWebUI()->GetController()); 543 preview_tab->web_contents()->GetWebUI()->GetController());
543 if (print_preview_ui) 544 if (print_preview_ui)
544 print_preview_ui->OnTabDestroyed(); 545 print_preview_ui->OnTabDestroyed();
545 546
546 preview_tab_map_.erase(preview_tab); 547 preview_tab_map_.erase(preview_tab);
547 RemoveObservers(preview_tab); 548 RemoveObservers(preview_tab);
548 } 549 }
549 550
550 } // namespace printing 551 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698