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

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

Issue 5320001: Disable printing context menus on the print preview page. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix test in a less hacky manner 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
41 // Get the print preview tab for |initiator_tab|. 38 // Get the print preview tab for |initiator_tab|.
42 TabContents* preview_tab = GetPrintPreviewForTab(initiator_tab); 39 TabContents* preview_tab = GetPrintPreviewForTab(initiator_tab);
43 if (preview_tab) { 40 if (preview_tab) {
44 // Show current preview tab. 41 // Show current preview tab.
45 preview_tab->Activate(); 42 preview_tab->Activate();
46 return preview_tab; 43 return preview_tab;
47 } 44 }
48 return CreatePrintPreviewTab(initiator_tab, browser_window_id); 45 return CreatePrintPreviewTab(initiator_tab, browser_window_id);
49 } 46 }
50 47
48 // static
51 bool PrintPreviewTabController::IsPrintPreviewTab(TabContents* tab) { 49 bool PrintPreviewTabController::IsPrintPreviewTab(TabContents* tab) {
52 const GURL& url = tab->GetURL(); 50 const GURL& url = tab->GetURL();
53 return (url.SchemeIs(chrome::kChromeUIScheme) && 51 return (url.SchemeIs(chrome::kChromeUIScheme) &&
54 url.host() == chrome::kChromeUIPrintHost); 52 url.host() == chrome::kChromeUIPrintHost);
55 } 53 }
56 54
57 TabContents* PrintPreviewTabController::GetInitiatorTab( 55 TabContents* PrintPreviewTabController::GetInitiatorTab(
58 TabContents* preview_tab) { 56 TabContents* preview_tab) {
59 PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab); 57 PrintPreviewTabMap::iterator it = preview_tab_map_.find(preview_tab);
60 if (it != preview_tab_map_.end()) 58 if (it != preview_tab_map_.end())
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // If |source_tab| is |preview_tab|, erase the map entry. 183 // If |source_tab| is |preview_tab|, erase the map entry.
186 if (source_tab == preview_tab) { 184 if (source_tab == preview_tab) {
187 preview_tab_map_.erase(preview_tab); 185 preview_tab_map_.erase(preview_tab);
188 RemoveObservers(preview_tab); 186 RemoveObservers(preview_tab);
189 } 187 }
190 188
191 if (initiator_tab) 189 if (initiator_tab)
192 RemoveObservers(initiator_tab); 190 RemoveObservers(initiator_tab);
193 } 191 }
194 192
195 } // namespace printing 193 } // 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