| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/chromeos/printer_detector/printer_detector.h" | 5 #include "chrome/browser/chromeos/printer_detector/printer_detector.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
| 17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 20 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 21 #include "chrome/browser/notifications/notification.h" | 21 #include "chrome/browser/notifications/notification.h" |
| 22 #include "chrome/browser/notifications/notification_delegate.h" | 22 #include "chrome/browser/notifications/notification_delegate.h" |
| 23 #include "chrome/browser/notifications/notification_ui_manager.h" | 23 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 24 #include "chrome/browser/ui/browser_navigator.h" | 24 #include "chrome/browser/ui/browser_navigator.h" |
| 25 #include "chrome/browser/ui/browser_navigator_params.h" | 25 #include "chrome/browser/ui/browser_navigator_params.h" |
| 26 #include "chrome/common/chrome_features.h" | |
| 27 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/common/extensions/api/webstore_widget_private.h" | 27 #include "chrome/common/extensions/api/webstore_widget_private.h" |
| 29 #include "chrome/common/extensions/extension_constants.h" | 28 #include "chrome/common/extensions/extension_constants.h" |
| 30 #include "chrome/common/url_constants.cc" | 29 #include "chrome/common/url_constants.cc" |
| 31 #include "chrome/grit/generated_resources.h" | 30 #include "chrome/grit/generated_resources.h" |
| 32 #include "chrome/grit/theme_resources.h" | 31 #include "chrome/grit/theme_resources.h" |
| 33 #include "components/user_manager/user.h" | 32 #include "components/user_manager/user.h" |
| 34 #include "components/user_manager/user_manager.h" | 33 #include "components/user_manager/user_manager.h" |
| 35 #include "device/base/device_client.h" | 34 #include "device/base/device_client.h" |
| 36 #include "device/usb/usb_device.h" | 35 #include "device/usb/usb_device.h" |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 profile_id); | 378 profile_id); |
| 380 | 379 |
| 381 if (command_ == ButtonCommand::SETUP) { | 380 if (command_ == ButtonCommand::SETUP) { |
| 382 OnSetUpUSBPrinterStarted(); | 381 OnSetUpUSBPrinterStarted(); |
| 383 // TODO(skau/xdai): call the CUPS backend to set up the USB printer and | 382 // TODO(skau/xdai): call the CUPS backend to set up the USB printer and |
| 384 // then call OnSetUpPrinterDone() or OnSetUpPrinterError() depending on | 383 // then call OnSetUpPrinterDone() or OnSetUpPrinterError() depending on |
| 385 // the setup result. | 384 // the setup result. |
| 386 } else if (command_ == ButtonCommand::CANCEL_SETUP) { | 385 } else if (command_ == ButtonCommand::CANCEL_SETUP) { |
| 387 // TODO(skau/xdai): call the CUPS backend to cancel the printer setup. | 386 // TODO(skau/xdai): call the CUPS backend to cancel the printer setup. |
| 388 } else if (command_ == ButtonCommand::GET_HELP) { | 387 } else if (command_ == ButtonCommand::GET_HELP) { |
| 389 if (base::FeatureList::IsEnabled(features::kMaterialDesignSettings)) { | 388 chrome::NavigateParams params(profile_, |
| 390 chrome::NavigateParams params(profile_, | 389 GURL(chrome::kChromeUIMdCupsSettingsURL), |
| 391 GURL(chrome::kChromeUIMdCupsSettingsURL), | 390 ui::PAGE_TRANSITION_LINK); |
| 392 ui::PAGE_TRANSITION_LINK); | 391 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 393 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; | 392 params.window_action = chrome::NavigateParams::SHOW_WINDOW; |
| 394 params.window_action = chrome::NavigateParams::SHOW_WINDOW; | 393 chrome::Navigate(¶ms); |
| 395 chrome::Navigate(¶ms); | |
| 396 } | |
| 397 } | 394 } |
| 398 } | 395 } |
| 399 | 396 |
| 400 void PrinterDetector::OnSetUpUSBPrinterStarted() { | 397 void PrinterDetector::OnSetUpUSBPrinterStarted() { |
| 401 notification_->set_title(l10n_util::GetStringUTF16( | 398 notification_->set_title(l10n_util::GetStringUTF16( |
| 402 IDS_PRINTER_DETECTED_NOTIFICATION_SET_UP_IN_PROGRESS_TITLE)); | 399 IDS_PRINTER_DETECTED_NOTIFICATION_SET_UP_IN_PROGRESS_TITLE)); |
| 403 notification_->set_type(message_center::NOTIFICATION_TYPE_PROGRESS); | 400 notification_->set_type(message_center::NOTIFICATION_TYPE_PROGRESS); |
| 404 notification_->set_progress(-1); | 401 notification_->set_progress(-1); |
| 405 std::vector<message_center::ButtonInfo> buttons; | 402 std::vector<message_center::ButtonInfo> buttons; |
| 406 buttons.push_back(message_center::ButtonInfo(l10n_util::GetStringUTF16( | 403 buttons.push_back(message_center::ButtonInfo(l10n_util::GetStringUTF16( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 428 notification_->set_type(message_center::NOTIFICATION_TYPE_SIMPLE); | 425 notification_->set_type(message_center::NOTIFICATION_TYPE_SIMPLE); |
| 429 std::vector<message_center::ButtonInfo> buttons; | 426 std::vector<message_center::ButtonInfo> buttons; |
| 430 buttons.push_back(message_center::ButtonInfo(l10n_util::GetStringUTF16( | 427 buttons.push_back(message_center::ButtonInfo(l10n_util::GetStringUTF16( |
| 431 IDS_PRINTER_DETECTED_NOTIFICATION_SET_UP_GET_HELP_BUTTON))); | 428 IDS_PRINTER_DETECTED_NOTIFICATION_SET_UP_GET_HELP_BUTTON))); |
| 432 notification_->set_buttons(buttons); | 429 notification_->set_buttons(buttons); |
| 433 command_ = ButtonCommand::GET_HELP; | 430 command_ = ButtonCommand::GET_HELP; |
| 434 notification_ui_manager_->Add(*notification_, profile_); | 431 notification_ui_manager_->Add(*notification_, profile_); |
| 435 } | 432 } |
| 436 | 433 |
| 437 } // namespace chromeos | 434 } // namespace chromeos |
| OLD | NEW |