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
3 // found in the LICENSE file.
5 #include "chrome/browser/printing/print_preview_context_menu_observer.h"
7 #include "base/logging.h"
8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/printing/print_preview_dialog_controller.h"
11 PrintPreviewContextMenuObserver::PrintPreviewContextMenuObserver(
12 content::WebContents
* contents
) : contents_(contents
) {
15 PrintPreviewContextMenuObserver::~PrintPreviewContextMenuObserver() {
18 bool PrintPreviewContextMenuObserver::IsPrintPreviewDialog() {
19 printing::PrintPreviewDialogController
* controller
=
20 printing::PrintPreviewDialogController::GetInstance();
23 return (controller
->GetPrintPreviewForContents(contents_
) != nullptr);
26 bool PrintPreviewContextMenuObserver::IsCommandIdSupported(int command_id
) {
30 case IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE
:
31 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO
:
32 case IDC_CONTENT_CONTEXT_SEARCHWEBFOR
:
33 return IsPrintPreviewDialog();
40 bool PrintPreviewContextMenuObserver::IsCommandIdEnabled(int command_id
) {
44 case IDC_CONTENT_CONTEXT_VIEWFRAMESOURCE
:
45 case IDC_CONTENT_CONTEXT_VIEWPAGEINFO
:
46 case IDC_CONTENT_CONTEXT_SEARCHWEBFOR
: