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

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

Issue 5529004: Revert 68228 - Disable printing context menus on the print preview page.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/tab_contents/tab_contents.h" 8 #include "chrome/browser/tab_contents/tab_contents.h"
9 #include "chrome/browser/tabs/tab_strip_model.h" 9 #include "chrome/browser/tabs/tab_strip_model.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 29
30 PrintPreviewTabController::~PrintPreviewTabController() { 30 PrintPreviewTabController::~PrintPreviewTabController() {
31 preview_tab_map_.clear(); 31 preview_tab_map_.clear();
32 } 32 }
33 33
34 TabContents* PrintPreviewTabController::GetOrCreatePreviewTab( 34 TabContents* PrintPreviewTabController::GetOrCreatePreviewTab(
35 TabContents* initiator_tab, int browser_window_id ) { 35 TabContents* initiator_tab, int browser_window_id ) {
36 DCHECK(initiator_tab); 36 DCHECK(initiator_tab);
37 37
38 if (IsPrintPreviewTab(initiator_tab))
39 return initiator_tab;
40
38 // Get the print preview tab for |initiator_tab|. 41 // Get the print preview tab for |initiator_tab|.
39 TabContents* preview_tab = GetPrintPreviewForTab(initiator_tab); 42 TabContents* preview_tab = GetPrintPreviewForTab(initiator_tab);
40 if (preview_tab) { 43 if (preview_tab) {
41 // Show current preview tab. 44 // Show current preview tab.
42 preview_tab->Activate(); 45 preview_tab->Activate();
43 return preview_tab; 46 return preview_tab;
44 } 47 }
45 return CreatePrintPreviewTab(initiator_tab, browser_window_id); 48 return CreatePrintPreviewTab(initiator_tab, browser_window_id);
46 } 49 }
47 50
48 // static
49 bool PrintPreviewTabController::IsPrintPreviewTab(TabContents* tab) { 51 bool PrintPreviewTabController::IsPrintPreviewTab(TabContents* tab) {
50 const GURL& url = tab->GetURL(); 52 const GURL& url = tab->GetURL();
51 return (url.SchemeIs(chrome::kChromeUIScheme) && 53 return (url.SchemeIs(chrome::kChromeUIScheme) &&
52 url.host() == chrome::kChromeUIPrintHost); 54 url.host() == chrome::kChromeUIPrintHost);
53 } 55 }
54 56
55 TabContents* PrintPreviewTabController::GetInitiatorTab( 57 TabContents* PrintPreviewTabController::GetInitiatorTab(
56 TabContents* preview_tab) { 58 TabContents* preview_tab) {
57 PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab); 59 PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab);
58 if (it != preview_tab_map_.end()) 60 if (it != preview_tab_map_.end())
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // If |source_tab| is |preview_tab|, erase the map entry. 185 // If |source_tab| is |preview_tab|, erase the map entry.
184 if (source_tab == preview_tab) { 186 if (source_tab == preview_tab) {
185 preview_tab_map_.erase(preview_tab); 187 preview_tab_map_.erase(preview_tab);
186 RemoveObservers(preview_tab); 188 RemoveObservers(preview_tab);
187 } 189 }
188 190
189 if (initiator_tab) 191 if (initiator_tab)
190 RemoveObservers(initiator_tab); 192 RemoveObservers(initiator_tab);
191 } 193 }
192 194
193 } // namespace printing 195 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_preview_tab_controller.h ('k') | chrome/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698