text:
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/accelerators/accelerator_controller.h"

#include <algorithm>
#include <cmath>
#include <string>

#include "ash/accelerators/accelerator_commands.h"
#include "ash/accelerators/debug_commands.h"
#include "ash/ash_switches.h"
#include "ash/debug.h"
#include "ash/display/display_controller.h"
#include "ash/display/display_manager.h"
#include "ash/display/display_util.h"
#include "ash/focus_cycler.h"
#include "ash/gpu_support.h"
#include "ash/ime_control_delegate.h"
#include "ash/magnifier/magnification_controller.h"
#include "ash/magnifier/partial_magnification_controller.h"
#include "ash/media_delegate.h"
#include "ash/multi_profile_uma.h"
#include "ash/new_window_delegate.h"
#include "ash/root_window_controller.h"
#include "ash/rotator/screen_rotation_animator.h"
#include "ash/rotator/window_rotation.h"
#include "ash/screenshot_delegate.h"
#include "ash/session/session_state_delegate.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_delegate.h"
#include "ash/shelf/shelf_model.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
#include "ash/system/brightness_control_delegate.h"
#include "ash/system/keyboard_brightness/keyboard_brightness_control_delegate.h"
#include "ash/system/status_area_widget.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/system/tray/system_tray_notifier.h"
#include "ash/system/web_notification/web_notification_tray.h"
#include "ash/touch/touch_hud_debug.h"
#include "ash/utility/partial_screenshot_controller.h"
#include "ash/volume_control_delegate.h"
#include "ash/wm/maximize_mode/maximize_mode_controller.h"
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/overview/window_selector_controller.h"
#include "ash/wm/power_button_controller.h"
#include "ash/wm/window_cycle_controller.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_util.h"
#include "ash/wm/wm_event.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/metrics/user_metrics.h"
#include "ui/aura/env.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/accelerators/accelerator_manager.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_sequence.h"
#include "ui/compositor/layer_animator.h"
#include "ui/events/event.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/screen.h"
#include "ui/views/controls/webview/webview.h"

#if defined(OS_CHROMEOS)
#include "ash/system/chromeos/keyboard_brightness_controller.h"
#include "base/sys_info.h"
#include "ui/base/ime/chromeos/ime_keyboard.h"
#include "ui/base/ime/chromeos/input_method_manager.h"
#endif  // defined(OS_CHROMEOS)

namespace ash {
namespace {

using base::UserMetricsAction;

void HandleCycleBackwardMRU(const ui::Accelerator& accelerator) {
  if (accelerator.key_code() == ui::VKEY_TAB)
    base::RecordAction(base::UserMetricsAction("Accel_PrevWindow_Tab"));

  Shell::GetInstance()->window_cycle_controller()->HandleCycleWindow(
      WindowCycleController::BACKWARD);
}

void HandleCycleForwardMRU(const ui::Accelerator& accelerator) {
  if (accelerator.key_code() == ui::VKEY_TAB)
    base::RecordAction(base::UserMetricsAction("Accel_NextWindow_Tab"));

  Shell::GetInstance()->window_cycle_controller()->HandleCycleWindow(
      WindowCycleController::FORWARD);
}

void HandleRotatePaneFocus(Shell::Direction direction) {
  Shell* shell = Shell::GetInstance();
  switch (direction) {
    // TODO(stevet): Not sure if this is the same as IDC_FOCUS_NEXT_PANE.
    case Shell::FORWARD: {
      base::RecordAction(UserMetricsAction("Accel_Focus_Next_Pane"));
      shell->focus_cycler()->RotateFocus(FocusCycler::FORWARD);
      break;
    }
    case Shell::BACKWARD: {
      base::RecordAction(UserMetricsAction("Accel_Focus_Previous_Pane"));
      shell->focus_cycler()->RotateFocus(FocusCycler::BACKWARD);
      break;
    }
  }
}

void HandleFocusShelf() {
  Shell* shell = Shell::GetInstance();
  base::RecordAction(base::UserMetricsAction("Accel_Focus_Shelf"));
  shell->focus_cycler()->FocusWidget(
      Shelf::ForPrimaryDisplay()->shelf_widget());
}

void HandleLaunchAppN(int n) {
  base::RecordAction(UserMetricsAction("Accel_Launch_App"));
  Shelf::ForPrimaryDisplay()->LaunchAppIndexAt(n);
}

void HandleLaunchLastApp() {
  base::RecordAction(UserMetricsAction("Accel_Launch_Last_App"));
  Shelf::ForPrimaryDisplay()->LaunchAppIndexAt(-1);
}

bool CanHandleMagnifyScreen() {
  Shell* shell = Shell::GetInstance();
  return shell->magnification_controller()->IsEnabled() ||
      shell->partial_magnification_controller()->is_enabled();
}

// Magnify the screen
void HandleMagnifyScreen(int delta_index) {
  if (ash::Shell::GetInstance()->magnification_controller()->IsEnabled()) {
    // TODO(yoshiki): Move the following logic to MagnificationController.
    float scale =
        ash::Shell::GetInstance()->magnification_controller()->GetScale();
    // Calculate rounded logarithm (base kMagnificationScaleFactor) of scale.
    int scale_index = std::floor(
        std::log(scale) / std::log(ui::kMagnificationScaleFactor) + 0.5);

    int new_scale_index = std::max(0, std::min(8, scale_index + delta_index));

    ash::Shell::GetInstance()->magnification_controller()->SetScale(
        std::pow(ui::kMagnificationScaleFactor, new_scale_index), true);
  } else if (ash::Shell::GetInstance()->
             partial_magnification_controller()->is_enabled()) {
    float scale = delta_index > 0 ? kDefaultPartialMagnifiedScale : 1;
    ash::Shell::GetInstance()->partial_magnification_controller()->
        SetScale(scale);
  }
}

void HandleMediaNextTrack() {
  Shell::GetInstance()->media_delegate()->HandleMediaNextTrack();
}

void HandleMediaPlayPause() {
  Shell::GetInstance()->media_delegate()->HandleMediaPlayPause();
}

void HandleMediaPrevTrack() {
  Shell::GetInstance()->media_delegate()->HandleMediaPrevTrack();
}

bool CanHandleNewIncognitoWindow() {
  return Shell::GetInstance()->delegate()->IsIncognitoAllowed();
}

void HandleNewIncognitoWindow() {
  base::RecordAction(UserMetricsAction("Accel_New_Incognito_Window"));
  Shell::GetInstance()->new_window_delegate()->NewWindow(
      true /* is_incognito */);
}

void HandleNewTab(const ui::Accelerator& accelerator) {
  if (accelerator.key_code() == ui::VKEY_T)
    base::RecordAction(base::UserMetricsAction("Accel_NewTab_T"));
  Shell::GetInstance()->new_window_delegate()->NewTab();
}

void HandleNewWindow() {
  base::RecordAction(base::UserMetricsAction("Accel_New_Window"));
  Shell::GetInstance()->new_window_delegate()->NewWindow(
      false /* is_incognito */);
}

bool CanHandleNextIme(ImeControlDelegate* ime_control_delegate,
                      const ui::Accelerator& previous_accelerator) {
  // This check is necessary e.g. not to process the Shift+Alt+
  // ET_KEY_RELEASED accelerator for Chrome OS (see ash/accelerators/
  // accelerator_controller.cc) when Shift+Alt+Tab is pressed and then Tab
  // is released.
  ui::KeyboardCode previous_key_code = previous_accelerator.key_code();
  if (previous_accelerator.type() == ui::ET_KEY_RELEASED &&
      // Workaround for crbug.com/139556. CJK IME users tend to press
      // Enter (or Space) and Shift+Alt almost at the same time to commit
      // an IME string and then switch from the IME to the English layout.
      // This workaround allows the user to trigger NEXT_IME even if the
      // user presses Shift+Alt before releasing Enter.
      // TODO(nona|mazda): Fix crbug.com/139556 in a cleaner way.
      previous_key_code != ui::VKEY_RETURN &&
      previous_key_code != ui::VKEY_SPACE) {
    // We totally ignore this accelerator.
    // TODO(mazda): Fix crbug.com/158217
    return false;
  }
  return ime_control_delegate && ime_control_delegate->CanCycleIme();
}

void HandleNextIme(ImeControlDelegate* ime_control_delegate) {
  base::RecordAction(UserMetricsAction("Accel_Next_Ime"));
  ime_control_delegate->HandleNextIme();
}

void HandleOpenFeedbackPage() {
  base::RecordAction(UserMetricsAction("Accel_Open_Feedback_Page"));
  ash::Shell::GetInstance()->new_window_delegate()->OpenFeedbackPage();
}

bool CanHandlePreviousIme(ImeControlDelegate* ime_control_delegate) {
  return ime_control_delegate && ime_control_delegate->CanCycleIme();
}

void HandlePreviousIme(ImeControlDelegate* ime_control_delegate,
                       const ui::Accelerator& accelerator) {
  base::RecordAction(UserMetricsAction("Accel_Previous_Ime"));
  if (accelerator.type() == ui::ET_KEY_PRESSED)
    ime_control_delegate->HandlePreviousIme();
  // Else: consume the Ctrl+Space ET_KEY_RELEASED event but do not do anything.
}

void HandleRestoreTab() {
  base::RecordAction(base::UserMetricsAction("Accel_Restore_Tab"));
  Shell::GetInstance()->new_window_delegate()->RestoreTab();
}

gfx::Display::Rotation GetNextRotation(gfx::Display::Rotation current) {
  switch (current) {
    case gfx::Display::ROTATE_0:
      return gfx::Display::ROTATE_90;
    case gfx::Display::ROTATE_90:
      return gfx::Display::ROTATE_180;
    case gfx::Display::ROTATE_180:
      return gfx::Display::ROTATE_270;
    case gfx::Display::ROTATE_270:
      return gfx::Display::ROTATE_0;
  }
  NOTREACHED() << "Unknown rotation:" << current;
  return gfx::Display::ROTATE_0;
}

// Rotates the screen.
void HandleRotateScreen() {
  if (Shell::GetInstance()->display_manager()->IsInUnifiedMode())
    return;

  base::RecordAction(UserMetricsAction("Accel_Rotate_Window"));
  gfx::Point point = Shell::GetScreen()->GetCursorScreenPoint();
  gfx::Display display = Shell::GetScreen()->GetDisplayNearestPoint(point);
  const DisplayInfo& display_info =
      Shell::GetInstance()->display_manager()->GetDisplayInfo(display.id());
  ash::ScreenRotationAnimator(display.id())
      .Rotate(GetNextRotation(display_info.GetActiveRotation()),
              gfx::Display::ROTATION_SOURCE_USER);
}

// Rotate the active window.
void HandleRotateActiveWindow() {
  base::RecordAction(UserMetricsAction("Accel_Rotate_Window"));
  aura::Window* active_window = wm::GetActiveWindow();
  if (active_window) {
    // The rotation animation bases its target transform on the current
    // rotation and position. Since there could be an animation in progress
    // right now, queue this animation so when it starts it picks up a neutral
    // rotation and position. Use replace so we only enqueue one at a time.
    active_window->layer()->GetAnimator()->
        set_preemption_strategy(ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
    active_window->layer()->GetAnimator()->StartAnimation(
        new ui::LayerAnimationSequence(
            new ash::WindowRotation(360, active_window->layer())));
  }
}

bool CanHandleScaleReset() {
  DisplayManager* display_manager = Shell::GetInstance()->display_manager();
  int64 display_id = display_manager->GetDisplayIdForUIScaling();
  return (display_id != gfx::Display::kInvalidDisplayID &&
          display_manager->GetDisplayInfo(display_id).configured_ui_scale() !=
              1.0f);
}

void HandleScaleReset() {
  base::RecordAction(UserMetricsAction("Accel_Scale_Ui_Reset"));
  DisplayManager* display_manager = Shell::GetInstance()->display_manager();
  int64 display_id = display_manager->GetDisplayIdForUIScaling();
  display_manager->SetDisplayUIScale(display_id, 1.0f);
}

bool CanHandleScaleUI() {
  return Shell::GetInstance()->display_manager()->IsDisplayUIScalingEnabled();
}

void HandleScaleUI(bool up) {
  DisplayManager* display_manager = Shell::GetInstance()->display_manager();
  int64 display_id = display_manager->GetDisplayIdForUIScaling();

  if (up) {
    base::RecordAction(UserMetricsAction("Accel_Scale_Ui_Up"));
  } else {
    base::RecordAction(UserMetricsAction("Accel_Scale_Ui_Down"));
  }

  const DisplayInfo& display_info = display_manager->GetDisplayInfo(display_id);
  float next_scale = GetNextUIScale(display_info, up);
  display_manager->SetDisplayUIScale(display_id, next_scale);
}

void HandleShowKeyboardOverlay() {
  base::RecordAction(UserMetricsAction("Accel_Show_Keyboard_Overlay"));
  ash::Shell::GetInstance()->new_window_delegate()->ShowKeyboardOverlay();
}

bool CanHandleShowMessageCenterBubble() {
  RootWindowController* controller =
      RootWindowController::ForTargetRootWindow();
  StatusAreaWidget* status_area_widget =
      controller->shelf()->status_area_widget();
  return status_area_widget &&
         status_area_widget->web_notification_tray()->visible();
}

void HandleShowMessageCenterBubble() {
  base::RecordAction(UserMetricsAction("Accel_Show_Message_Center_Bubble"));
  RootWindowController* controller =
      RootWindowController::ForTargetRootWindow();
  StatusAreaWidget* status_area_widget =
      controller->shelf()->status_area_widget();
  if (status_area_widget) {
    WebNotificationTray* notification_tray =
        status_area_widget->web_notification_tray();
    if (notification_tray->visible())
      notification_tray->ShowMessageCenterBubble();
  }
}

void HandleShowSystemTrayBubble() {
  base::RecordAction(UserMetricsAction("Accel_Show_System_Tray_Bubble"));
  RootWindowController* controller =
      RootWindowController::ForTargetRootWindow();
  if (!controller->GetSystemTray()->HasSystemBubble())
    controller->GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
}

void HandleShowTaskManager() {
  base::RecordAction(UserMetricsAction("Accel_Show_Task_Manager"));
  Shell::GetInstance()->new_window_delegate()->ShowTaskManager();
}

bool CanHandleSwitchIme(ImeControlDelegate* ime_control_delegate,
                        const ui::Accelerator& accelerator) {
  return ime_control_delegate &&
      ime_control_delegate->CanSwitchIme(accelerator);
}

void HandleSwitchIme(ImeControlDelegate* ime_control_delegate,
                     const ui::Accelerator& accelerator) {
  base::RecordAction(UserMetricsAction("Accel_Switch_Ime"));
  ime_control_delegate->HandleSwitchIme(accelerator);
}

void HandleTakePartialScreenshot(ScreenshotDelegate* screenshot_delegate) {
  base::RecordAction(UserMetricsAction("Accel_Take_Partial_Screenshot"));
  DCHECK(screenshot_delegate);
  Shell::GetInstance()
      ->partial_screenshot_controller()
      ->StartPartialScreenshotSession(screenshot_delegate);
}

void HandleTakeScreenshot(ScreenshotDelegate* screenshot_delegate) {
  base::RecordAction(UserMetricsAction("Accel_Take_Screenshot"));
  DCHECK(screenshot_delegate);
  if (screenshot_delegate->CanTakeScreenshot())
    screenshot_delegate->HandleTakeScreenshotForAllRootWindows();
}

bool CanHandleToggleAppList(const ui::Accelerator& accelerator,
                            const ui::Accelerator& previous_accelerator) {
  if (accelerator.key_code() == ui::VKEY_LWIN) {
    // If something else was pressed between the Search key (LWIN)
    // being pressed and released, then ignore the release of the
    // Search key.
    if (previous_accelerator.type() != ui::ET_KEY_PRESSED ||
        previous_accelerator.key_code() != ui::VKEY_LWIN) {
      return false;
    }

    // When spoken feedback is enabled, we should neither toggle the list nor
    // consume the key since Search+Shift is one of the shortcuts the a11y
    // feature uses. crbug.com/132296
    if (Shell::GetInstance()
            ->accessibility_delegate()
            ->IsSpokenFeedbackEnabled()) {
      return false;
    }
  }
  return true;
}

void HandleToggleAppList(const ui::Accelerator& accelerator) {
  if (accelerator.key_code() == ui::VKEY_LWIN)
    base::RecordAction(base::UserMetricsAction("Accel_Search_LWin"));
  ash::Shell::GetInstance()->ToggleAppList(NULL);
}

void HandleToggleFullscreen(const ui::Accelerator& accelerator) {
  if (accelerator.key_code() == ui::VKEY_MEDIA_LAUNCH_APP2)
    base::RecordAction(UserMetricsAction("Accel_Fullscreen_F4"));
  accelerators::ToggleFullscreen();
}

void HandleToggleOverview() {
  base::RecordAction(base::UserMetricsAction("Accel_Overview_F5"));
  Shell::GetInstance()->window_selector_controller()->ToggleOverview();
}

bool CanHandleWindowSnapOrDock() {
  wm::WindowState* window_state = wm::GetActiveWindowState();
  // Disable window snapping shortcut key for full screen window due to
  // http://crbug.com/135487.
  return (window_state && window_state->IsUserPositionable() &&
          !window_state->IsFullscreen());
}

void HandleWindowSnapOrDock(AcceleratorAction action) {
  if (action == WINDOW_CYCLE_SNAP_DOCK_LEFT)
    base::RecordAction(UserMetricsAction("Accel_Window_Snap_Left"));
  else
    base::RecordAction(UserMetricsAction("Accel_Window_Snap_Right"));

  const wm::WMEvent event(action == WINDOW_CYCLE_SNAP_DOCK_LEFT ?
                          wm::WM_EVENT_CYCLE_SNAP_DOCK_LEFT :
                          wm::WM_EVENT_CYCLE_SNAP_DOCK_RIGHT);
  wm::GetActiveWindowState()->OnWMEvent(&event);
}

void HandleWindowMinimize() {
  base::RecordAction(
      base::UserMetricsAction("Accel_Toggle_Minimized_Minus"));
  accelerators::ToggleMinimized();
}

bool CanHandlePositionCenter() {
  // Docked windows do not support centering.
  wm::WindowState* window_state = wm::GetActiveWindowState();
  return (window_state && !window_state->IsDocked());
}

void HandlePositionCenter() {
  base::RecordAction(UserMetricsAction("Accel_Window_Position_Center"));
  wm::CenterWindow(wm::GetActiveWindow());
}

#if defined(OS_CHROMEOS)
void HandleBrightnessDown(BrightnessControlDelegate* delegate,
                          const ui::Accelerator& accelerator) {
  if (delegate)
    delegate->HandleBrightnessDown(accelerator);
}

void HandleBrightnessUp(BrightnessControlDelegate* delegate,
                        const ui::Accelerator& accelerator) {
  if (delegate)
    delegate->HandleBrightnessUp(accelerator);
}

bool CanHandleDisableCapsLock(const ui::Accelerator& previous_accelerator) {
  ui::KeyboardCode previous_key_code = previous_accelerator.key_code();
  if (previous_accelerator.type() == ui::ET_KEY_RELEASED ||
      (previous_key_code != ui::VKEY_LSHIFT &&
       previous_key_code != ui::VKEY_SHIFT &&
       previous_key_code != ui::VKEY_RSHIFT)) {
    // If something else was pressed between the Shift key being pressed
    // and released, then ignore the release of the Shift key.
    return false;
  }
  chromeos::input_method::InputMethodManager* ime =
      chromeos::input_method::InputMethodManager::Get();
  chromeos::input_method::ImeKeyboard* keyboard =
      ime ? ime->GetImeKeyboard() : NULL;
  return (keyboard && keyboard->CapsLockIsEnabled());
}

void HandleDisableCapsLock() {
  base::RecordAction(UserMetricsAction("Accel_Disable_Caps_Lock"));
  chromeos::input_method::InputMethodManager* ime =
      chromeos::input_method::InputMethodManager::Get();
  ime->GetImeKeyboard()->SetCapsLockEnabled(false);
}

void HandleKeyboardBrightnessDown(KeyboardBrightnessControlDelegate* delegate,
                                  const ui::Accelerator& accelerator) {
  if (delegate)
    delegate->HandleKeyboardBrightnessDown(accelerator);
}

void HandleKeyboardBrightnessUp(KeyboardBrightnessControlDelegate* delegate,
                                const ui::Accelerator& accelerator) {
  if (delegate)
    delegate->HandleKeyboardBrightnessUp(accelerator);
}

void HandleLock() {
  base::RecordAction(UserMetricsAction("Accel_LockScreen_L"));
  Shell::GetInstance()->session_state_delegate()->LockScreen();
}

void HandleCrosh() {
  base::RecordAction(UserMetricsAction("Accel_Open_Crosh"));

  Shell::GetInstance()->new_window_delegate()->OpenCrosh();
}

void HandleFileManager() {
  base::RecordAction(UserMetricsAction("Accel_Open_File_Manager"));

  Shell::GetInstance()->new_window_delegate()->OpenFileManager();
}

void HandleGetHelp() {
  Shell::GetInstance()->new_window_delegate()->OpenGetHelp();
}

bool CanHandleSilenceSpokenFeedback() {
  AccessibilityDelegate* delegate =
      Shell::GetInstance()->accessibility_delegate();
  return delegate->IsSpokenFeedbackEnabled();
}

void HandleSilenceSpokenFeedback() {
  base::RecordAction(UserMetricsAction("Accel_Silence_Spoken_Feedback"));
  Shell::GetInstance()->accessibility_delegate()->SilenceSpokenFeedback();
}

void HandleSwapPrimaryDisplay() {
  base::RecordAction(UserMetricsAction("Accel_Swap_Primary_Display"));
  Shell::GetInstance()->display_controller()->SwapPrimaryDisplay();
}

bool CanHandleCycleUser() {
  Shell* shell = Shell::GetInstance();
  return shell->delegate()->IsMultiProfilesEnabled() &&
      shell->session_state_delegate()->NumberOfLoggedInUsers() > 1;
}

void HandleCycleUser(SessionStateDelegate::CycleUser cycle_user) {
  MultiProfileUMA::RecordSwitchActiveUser(
      MultiProfileUMA::SWITCH_ACTIVE_USER_BY_ACCELERATOR);
  switch (cycle_user) {
    case SessionStateDelegate::CYCLE_TO_NEXT_USER:
      base::RecordAction(UserMetricsAction("Accel_Switch_To_Next_User"));
      break;
    case SessionStateDelegate::CYCLE_TO_PREVIOUS_USER:
      base::RecordAction(UserMetricsAction("Accel_Switch_To_Previous_User"));
      break;
  }
  Shell::GetInstance()->session_state_delegate()->CycleActiveUser(cycle_user);
}

bool CanHandleToggleCapsLock(const ui::Accelerator& accelerator,
                             const ui::Accelerator& previous_accelerator) {
  if (accelerator.key_code() == ui::VKEY_LWIN) {
    // If something else was pressed between the Search key (LWIN)
    // being pressed and released, then ignore the release of the
    // Search key.
    // TODO(danakj): Releasing Alt first breaks this: crbug.com/166495
    if (previous_accelerator.type() == ui::ET_KEY_RELEASED ||
        previous_accelerator.key_code() != ui::VKEY_LWIN)
      return false;
  }
  chromeos::input_method::InputMethodManager* ime =
      chromeos::input_method::InputMethodManager::Get();
  return ime && ime->GetImeKeyboard();
}

void HandleToggleCapsLock() {
  base::RecordAction(UserMetricsAction("Accel_Toggle_Caps_Lock"));
  chromeos::input_method::InputMethodManager* ime =
      chromeos::input_method::InputMethodManager::Get();
  chromeos::input_method::ImeKeyboard* keyboard = ime->GetImeKeyboard();
  keyboard->SetCapsLockEnabled(!keyboard->CapsLockIsEnabled());
}

void HandleToggleMirrorMode() {
  base::RecordAction(UserMetricsAction("Accel_Toggle_Mirror_Mode"));
  Shell::GetInstance()->display_controller()->ToggleMirrorMode();
}

void HandleToggleSpokenFeedback() {
  base::RecordAction(UserMetricsAction("Accel_Toggle_Spoken_Feedback"));

  Shell::GetInstance()->accessibility_delegate()->
      ToggleSpokenFeedback(ui::A11Y_NOTIFICATION_SHOW);
}

bool CanHandleToggleTouchViewTesting() {
  return base::CommandLine::ForCurrentProcess()->HasSwitch(
      switches::kAshEnableTouchViewTesting);
}

void HandleToggleTouchViewTesting() {
  // TODO(skuhne): This is only temporary! Remove this!
  MaximizeModeController* controller = Shell::GetInstance()->
      maximize_mode_controller();
  controller->EnableMaximizeModeWindowManager(
      !controller->IsMaximizeModeWindowManagerEnabled());
}

bool CanHandleTouchHud() {
  return RootWindowController::ForTargetRootWindow()->touch_hud_debug();
}

void HandleTouchHudClear() {
  RootWindowController::ForTargetRootWindow()->touch_hud_debug()->Clear();
}

void HandleTouchHudModeChange() {
  RootWindowController* controller =
      RootWindowController::ForTargetRootWindow();
  controller->touch_hud_debug()->ChangeToNextMode();
}

void HandleVolumeDown(const ui::Accelerator& accelerator) {
  VolumeControlDelegate* volume_delegate =
      Shell::GetInstance()->system_tray_delegate()->GetVolumeControlDelegate();
  if (volume_delegate)
    volume_delegate->HandleVolumeDown(accelerator);
}

void HandleVolumeMute(const ui::Accelerator& accelerator) {
  VolumeControlDelegate* volume_delegate =
      Shell::GetInstance()->system_tray_delegate()->GetVolumeControlDelegate();
  if (volume_delegate)
    volume_delegate->HandleVolumeMute(accelerator);
}

void HandleVolumeUp(const ui::Accelerator& accelerator) {
  VolumeControlDelegate* volume_delegate =
      Shell::GetInstance()->system_tray_delegate()->GetVolumeControlDelegate();
  if (volume_delegate)
    volume_delegate->HandleVolumeUp(accelerator);
}

#endif  // defined(OS_CHROMEOS)

}  // namespace

////////////////////////////////////////////////////////////////////////////////
// AcceleratorController, public:

AcceleratorController::AcceleratorController()
    : accelerator_manager_(new ui::AcceleratorManager),
      accelerator_history_(new ui::AcceleratorHistory) {
  Init();
}

AcceleratorController::~AcceleratorController() {
}

void AcceleratorController::Register(const ui::Accelerator& accelerator,
                                     ui::AcceleratorTarget* target) {
  accelerator_manager_->Register(accelerator,
                                 ui::AcceleratorManager::kNormalPriority,
                                 target);
}

void AcceleratorController::Unregister(const ui::Accelerator& accelerator,
                                       ui::AcceleratorTarget* target) {
  accelerator_manager_->Unregister(accelerator, target);
}

void AcceleratorController::UnregisterAll(ui::AcceleratorTarget* target) {
  accelerator_manager_->UnregisterAll(target);
}

bool AcceleratorController::Process(const ui::Accelerator& accelerator) {
  if (ime_control_delegate_) {
    return accelerator_manager_->Process(
        ime_control_delegate_->RemapAccelerator(accelerator));
  }
  return accelerator_manager_->Process(accelerator);
}

bool AcceleratorController::IsRegistered(
    const ui::Accelerator& accelerator) const {
  return accelerator_manager_->GetCurrentTarget(accelerator) != NULL;
}

bool AcceleratorController::IsPreferred(
    const ui::Accelerator& accelerator) const {
  const ui::Accelerator remapped_accelerator = ime_control_delegate_.get() ?
      ime_control_delegate_->RemapAccelerator(accelerator) : accelerator;

  std::map<ui::Accelerator, AcceleratorAction>::const_iterator iter =
      accelerators_.find(remapped_accelerator);
  if (iter == accelerators_.end())
    return false;  // not an accelerator.

  return preferred_actions_.find(iter->second) != preferred_actions_.end();
}

bool AcceleratorController::IsReserved(
    const ui::Accelerator& accelerator) const {
  const ui::Accelerator remapped_accelerator = ime_control_delegate_.get() ?
      ime_control_delegate_->RemapAccelerator(accelerator) : accelerator;

  std::map<ui::Accelerator, AcceleratorAction>::const_iterator iter =
      accelerators_.find(remapped_accelerator);
  if (iter == accelerators_.end())
    return false;  // not an accelerator.

  return reserved_actions_.find(iter->second) != reserved_actions_.end();
}

bool AcceleratorController::PerformActionIfEnabled(AcceleratorAction action) {
  if (CanPerformAction(action, ui::Accelerator())) {
    PerformAction(action, ui::Accelerator());
    return true;
  }
  return false;
}

AcceleratorController::AcceleratorProcessingRestriction
AcceleratorController::GetCurrentAcceleratorRestriction() {
  return GetAcceleratorProcessingRestriction(-1);
}

void AcceleratorController::SetBrightnessControlDelegate(
    scoped_ptr<BrightnessControlDelegate> brightness_control_delegate) {
  brightness_control_delegate_ = brightness_control_delegate.Pass();
}

void AcceleratorController::SetImeControlDelegate(
    scoped_ptr<ImeControlDelegate> ime_control_delegate) {
  ime_control_delegate_ = ime_control_delegate.Pass();
}

void AcceleratorController::SetScreenshotDelegate(
    scoped_ptr<ScreenshotDelegate> screenshot_delegate) {
  screenshot_delegate_ = screenshot_delegate.Pass();
}

////////////////////////////////////////////////////////////////////////////////
// AcceleratorController, ui::AcceleratorTarget implementation:

bool AcceleratorController::AcceleratorPressed(
    const ui::Accelerator& accelerator) {
  std::map<ui::Accelerator, AcceleratorAction>::const_iterator it =
      accelerators_.find(accelerator);
  DCHECK(it != accelerators_.end());
  AcceleratorAction action = it->second;
  if (CanPerformAction(action, accelerator)) {
    PerformAction(action, accelerator);
    return ShouldActionConsumeKeyEvent(action);
  }
  return false;
}

bool AcceleratorController::CanHandleAccelerators() const {
  return true;
}

///////////////////////////////////////////////////////////////////////////////
// AcceleratorController, private:

void AcceleratorController::Init() {
  for (size_t i = 0; i < kActionsAllowedAtLoginOrLockScreenLength; ++i) {
    actions_allowed_at_login_screen_.insert(
        kActionsAllowedAtLoginOrLockScreen[i]);
    actions_allowed_at_lock_screen_.insert(
        kActionsAllowedAtLoginOrLockScreen[i]);
  }
  for (size_t i = 0; i < kActionsAllowedAtLockScreenLength; ++i)
    actions_allowed_at_lock_screen_.insert(kActionsAllowedAtLockScreen[i]);
  for (size_t i = 0; i < kActionsAllowedAtModalWindowLength; ++i)
    actions_allowed_at_modal_window_.insert(kActionsAllowedAtModalWindow[i]);
  for (size_t i = 0; i < kPreferredActionsLength; ++i)
    preferred_actions_.insert(kPreferredActions[i]);
  for (size_t i = 0; i < kReservedActionsLength; ++i)
    reserved_actions_.insert(kReservedActions[i]);
  for (size_t i = 0; i < kNonrepeatableActionsLength; ++i)
    nonrepeatable_actions_.insert(kNonrepeatableActions[i]);
  for (size_t i = 0; i < kActionsAllowedInAppModeLength; ++i)
    actions_allowed_in_app_mode_.insert(kActionsAllowedInAppMode[i]);
  for (size_t i = 0; i < kActionsNeedingWindowLength; ++i)
    actions_needing_window_.insert(kActionsNeedingWindow[i]);

  RegisterAccelerators(kAcceleratorData, kAcceleratorDataLength);

  if (debug::DebugAcceleratorsEnabled()) {
    RegisterAccelerators(kDebugAcceleratorData, kDebugAcceleratorDataLength);
    // All debug accelerators are reserved.
    for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i)
      reserved_actions_.insert(kDebugAcceleratorData[i].action);
  }

#if defined(OS_CHROMEOS)
  keyboard_brightness_control_delegate_.reset(
      new KeyboardBrightnessController());
#endif
}

void AcceleratorController::RegisterAccelerators(
    const AcceleratorData accelerators[],
    size_t accelerators_length) {
  for (size_t i = 0; i < accelerators_length; ++i) {
    ui::Accelerator accelerator(accelerators[i].keycode,
                                accelerators[i].modifiers);
    accelerator.set_type(accelerators[i].trigger_on_press ?
                         ui::ET_KEY_PRESSED : ui::ET_KEY_RELEASED);
    Register(accelerator, this);
    accelerators_.insert(
        std::make_pair(accelerator, accelerators[i].action));
  }
}

bool AcceleratorController::CanPerformAction(
    AcceleratorAction action,
    const ui::Accelerator& accelerator) {
  if (nonrepeatable_actions_.find(action) != nonrepeatable_actions_.end() &&
      accelerator.IsRepeat()) {
    return false;
  }

  AcceleratorProcessingRestriction restriction =
      GetAcceleratorProcessingRestriction(action);
  if (restriction != RESTRICTION_NONE)
    return restriction == RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION;

  const ui::Accelerator& previous_accelerator =
      accelerator_history_->previous_accelerator();

  // True should be returned if running |action| does something. Otherwise,
  // false should be returned to give the web contents a chance at handling the
  // accelerator.
  switch (action) {
    case DEBUG_PRINT_LAYER_HIERARCHY:
    case DEBUG_PRINT_VIEW_HIERARCHY:
    case DEBUG_PRINT_WINDOW_HIERARCHY:
    case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE:
    case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR:
    case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN:
    case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS:
    case DEBUG_TOGGLE_SHOW_FPS_COUNTER:
    case DEBUG_TOGGLE_SHOW_PAINT_RECTS:
      return debug::DebugAcceleratorsEnabled();
    case MAGNIFY_SCREEN_ZOOM_IN:
    case MAGNIFY_SCREEN_ZOOM_OUT:
      return CanHandleMagnifyScreen();
    case NEW_INCOGNITO_WINDOW:
      return CanHandleNewIncognitoWindow();
    case NEXT_IME:
      return CanHandleNextIme(ime_control_delegate_.get(),
                              previous_accelerator);
    case PREVIOUS_IME:
      return CanHandlePreviousIme(ime_control_delegate_.get());
    case SCALE_UI_RESET:
      return CanHandleScaleReset();
    case SCALE_UI_UP:
    case SCALE_UI_DOWN:
      return CanHandleScaleUI();
    case SHOW_MESSAGE_CENTER_BUBBLE:
      return CanHandleShowMessageCenterBubble();
    case SWITCH_IME:
      return CanHandleSwitchIme(ime_control_delegate_.get(), accelerator);
    case TOGGLE_APP_LIST:
      return CanHandleToggleAppList(accelerator, previous_accelerator);
    case WINDOW_CYCLE_SNAP_DOCK_LEFT:
    case WINDOW_CYCLE_SNAP_DOCK_RIGHT:
      return CanHandleWindowSnapOrDock();
    case WINDOW_POSITION_CENTER:
      return CanHandlePositionCenter();
#if defined(OS_CHROMEOS)
    case DEBUG_ADD_REMOVE_DISPLAY:
      return debug::DebugAcceleratorsEnabled();
    case DISABLE_CAPS_LOCK:
      return CanHandleDisableCapsLock(previous_accelerator);
    case SILENCE_SPOKEN_FEEDBACK:
      return CanHandleSilenceSpokenFeedback();
    case SWITCH_TO_PREVIOUS_USER:
    case SWITCH_TO_NEXT_USER:
      return CanHandleCycleUser();
    case TOGGLE_CAPS_LOCK:
      return CanHandleToggleCapsLock(accelerator, previous_accelerator);
    case TOGGLE_TOUCH_VIEW_TESTING:
      return CanHandleToggleTouchViewTesting();
    case TOUCH_HUD_CLEAR:
    case TOUCH_HUD_MODE_CHANGE:
      return CanHandleTouchHud();
#endif

    case CYCLE_BACKWARD_MRU:
    case CYCLE_FORWARD_MRU:
    case EXIT:
    case FOCUS_NEXT_PANE:
    case FOCUS_PREVIOUS_PANE:
    case FOCUS_SHELF:
    case LAUNCH_APP_0:
    case LAUNCH_APP_1:
    case LAUNCH_APP_2:
    case LAUNCH_APP_3:
    case LAUNCH_APP_4:
    case LAUNCH_APP_5:
    case LAUNCH_APP_6:
    case LAUNCH_APP_7:
    case LAUNCH_LAST_APP:
    case MEDIA_NEXT_TRACK:
    case MEDIA_PLAY_PAUSE:
    case MEDIA_PREV_TRACK:
    case NEW_TAB:
    case NEW_WINDOW:
    case OPEN_FEEDBACK_PAGE:
    case PRINT_UI_HIERARCHIES:
    case RESTORE_TAB:
    case ROTATE_SCREEN:
    case ROTATE_WINDOW:
    case SHOW_KEYBOARD_OVERLAY:
    case SHOW_SYSTEM_TRAY_BUBBLE:
    case SHOW_TASK_MANAGER:
    case TAKE_PARTIAL_SCREENSHOT:
    case TAKE_SCREENSHOT:
    case TOGGLE_FULLSCREEN:
    case TOGGLE_MAXIMIZED:
    case TOGGLE_OVERVIEW:
    case WINDOW_MINIMIZE:
#if defined(OS_CHROMEOS)
    case BRIGHTNESS_DOWN:
    case BRIGHTNESS_UP:
    case DISABLE_GPU_WATCHDOG:
    case KEYBOARD_BRIGHTNESS_DOWN:
    case KEYBOARD_BRIGHTNESS_UP:
    case LOCK_PRESSED:
    case LOCK_RELEASED:
    case LOCK_SCREEN:
    case OPEN_CROSH:
    case OPEN_FILE_MANAGER:
    case OPEN_GET_HELP:
    case POWER_PRESSED:
    case POWER_RELEASED:
    case SWAP_PRIMARY_DISPLAY:
    case TOGGLE_MIRROR_MODE:
    case TOGGLE_SPOKEN_FEEDBACK:
    case TOGGLE_WIFI:
    case TOUCH_HUD_PROJECTION_TOGGLE:
    case VOLUME_DOWN:
    case VOLUME_MUTE:
    case VOLUME_UP:
#else
    case DUMMY_FOR_RESERVED:
#endif
      return true;
  }
  return false;
}

void AcceleratorController::PerformAction(AcceleratorAction action,
                                          const ui::Accelerator& accelerator) {
  AcceleratorProcessingRestriction restriction =
      GetAcceleratorProcessingRestriction(action);
  if (restriction != RESTRICTION_NONE)
    return;

  // If your accelerator invokes more than one line of code, please either
  // implement it in your module's controller code (like TOGGLE_MIRROR_MODE
  // below) or pull it into a HandleFoo() function above.
  switch (action) {
    case CYCLE_BACKWARD_MRU:
      HandleCycleBackwardMRU(accelerator);
      break;
    case CYCLE_FORWARD_MRU:
      HandleCycleForwardMRU(accelerator);
      break;
    case DEBUG_PRINT_LAYER_HIERARCHY:
    case DEBUG_PRINT_VIEW_HIERARCHY:
    case DEBUG_PRINT_WINDOW_HIERARCHY:
    case DEBUG_TOGGLE_DESKTOP_BACKGROUND_MODE:
    case DEBUG_TOGGLE_DEVICE_SCALE_FACTOR:
    case DEBUG_TOGGLE_ROOT_WINDOW_FULL_SCREEN:
    case DEBUG_TOGGLE_SHOW_DEBUG_BORDERS:
    case DEBUG_TOGGLE_SHOW_FPS_COUNTER:
    case DEBUG_TOGGLE_SHOW_PAINT_RECTS:
      debug::PerformDebugActionIfEnabled(action);
      break;
    case EXIT:
      // UMA metrics are recorded in the handler.
      exit_warning_handler_.HandleAccelerator();
      break;
    case FOCUS_NEXT_PANE:
      HandleRotatePaneFocus(Shell::FORWARD);
      break;
    case FOCUS_PREVIOUS_PANE:
      HandleRotatePaneFocus(Shell::BACKWARD);
      break;
    case FOCUS_SHELF:
      HandleFocusShelf();
      break;
    case LAUNCH_APP_0:
      HandleLaunchAppN(0);
      break;
    case LAUNCH_APP_1:
      HandleLaunchAppN(1);
      break;
    case LAUNCH_APP_2:
      HandleLaunchAppN(2);
      break;
    case LAUNCH_APP_3:
      HandleLaunchAppN(3);
      break;
    case LAUNCH_APP_4:
      HandleLaunchAppN(4);
      break;
    case LAUNCH_APP_5:
      HandleLaunchAppN(5);
      break;
    case LAUNCH_APP_6:
      HandleLaunchAppN(6);
      break;
    case LAUNCH_APP_7:
      HandleLaunchAppN(7);
      break;
    case LAUNCH_LAST_APP:
      HandleLaunchLastApp();
      break;
    case MAGNIFY_SCREEN_ZOOM_IN:
      HandleMagnifyScreen(1);
      break;
    case MAGNIFY_SCREEN_ZOOM_OUT:
      HandleMagnifyScreen(-1);
      break;
    case MEDIA_NEXT_TRACK:
      HandleMediaNextTrack();
      break;
    case MEDIA_PLAY_PAUSE:
      HandleMediaPlayPause();
      break;
    case MEDIA_PREV_TRACK:
      HandleMediaPrevTrack();
      break;
    case NEW_INCOGNITO_WINDOW:
      HandleNewIncognitoWindow();
      break;
    case NEW_TAB:
      HandleNewTab(accelerator);
      break;
    case NEW_WINDOW:
      HandleNewWindow();
      break;
    case NEXT_IME:
      HandleNextIme(ime_control_delegate_.get());
      break;
    case OPEN_FEEDBACK_PAGE:
      HandleOpenFeedbackPage();
      break;
    case PREVIOUS_IME:
      HandlePreviousIme(ime_control_delegate_.get(), accelerator);
      break;
    case PRINT_UI_HIERARCHIES:
      debug::PrintUIHierarchies();
      break;
    case RESTORE_TAB:
      HandleRestoreTab();
      break;
    case ROTATE_SCREEN:
      HandleRotateScreen();
      break;
    case ROTATE_WINDOW:
      HandleRotateActiveWindow();
      break;
    case SCALE_UI_DOWN:
      HandleScaleUI(false /* down */);
      break;
    case SCALE_UI_RESET:
      HandleScaleReset();
      break;
    case SCALE_UI_UP:
      HandleScaleUI(true /* up */);
      break;
    case SHOW_KEYBOARD_OVERLAY:
      HandleShowKeyboardOverlay();
      break;
    case SHOW_MESSAGE_CENTER_BUBBLE:
      HandleShowMessageCenterBubble();
      break;
    case SHOW_SYSTEM_TRAY_BUBBLE:
      HandleShowSystemTrayBubble();
      break;
    case SHOW_TASK_MANAGER:
      HandleShowTaskManager();
      break;
    case SWITCH_IME:
      HandleSwitchIme(ime_control_delegate_.get(), accelerator);
      break;
    case TAKE_PARTIAL_SCREENSHOT:
      HandleTakePartialScreenshot(screenshot_delegate_.get());
      break;
    case TAKE_SCREENSHOT:
      HandleTakeScreenshot(screenshot_delegate_.get());
      break;
    case TOGGLE_APP_LIST:
      HandleToggleAppList(accelerator);
      break;
    case TOGGLE_FULLSCREEN:
      HandleToggleFullscreen(accelerator);
      break;
    case TOGGLE_MAXIMIZED:
      accelerators::ToggleMaximized();
      break;
    case TOGGLE_OVERVIEW:
      HandleToggleOverview();
      break;
    case WINDOW_CYCLE_SNAP_DOCK_LEFT:
    case WINDOW_CYCLE_SNAP_DOCK_RIGHT:
      HandleWindowSnapOrDock(action);
      break;
    case WINDOW_MINIMIZE:
      HandleWindowMinimize();
      break;
    case WINDOW_POSITION_CENTER:
      HandlePositionCenter();
      break;
#if defined(OS_CHROMEOS)
    case BRIGHTNESS_DOWN:
      HandleBrightnessDown(brightness_control_delegate_.get(), accelerator);
      break;
    case BRIGHTNESS_UP:
      HandleBrightnessUp(brightness_control_delegate_.get(), accelerator);
      break;
    case DEBUG_ADD_REMOVE_DISPLAY:
      debug::PerformDebugActionIfEnabled(action);
      break;
    case DISABLE_CAPS_LOCK:
      HandleDisableCapsLock();
      break;
    case DISABLE_GPU_WATCHDOG:
      Shell::GetInstance()->gpu_support()->DisableGpuWatchdog();
      break;
    case KEYBOARD_BRIGHTNESS_DOWN:
      HandleKeyboardBrightnessDown(keyboard_brightness_control_delegate_.get(),
                                   accelerator);
      break;
    case KEYBOARD_BRIGHTNESS_UP:
      HandleKeyboardBrightnessUp(keyboard_brightness_control_delegate_.get(),
                                 accelerator);
      break;
    case LOCK_PRESSED:
    case LOCK_RELEASED:
      Shell::GetInstance()->power_button_controller()->
          OnLockButtonEvent(action == LOCK_PRESSED, base::TimeTicks());
      break;
    case LOCK_SCREEN:
      HandleLock();
      break;
    case OPEN_CROSH:
      HandleCrosh();
      break;
    case OPEN_FILE_MANAGER:
      HandleFileManager();
      break;
    case OPEN_GET_HELP:
      HandleGetHelp();
      break;
    case POWER_PRESSED:  // fallthrough
    case POWER_RELEASED:
      if (!base::SysInfo::IsRunningOnChromeOS()) {
        // There is no powerd, the Chrome OS power manager, in linux desktop,
        // so call the PowerButtonController here.
        Shell::GetInstance()->power_button_controller()->
            OnPowerButtonEvent(action == POWER_PRESSED, base::TimeTicks());
      }
      // We don't do anything with these at present on the device,
      // (power button events are reported to us from powerm via
      // D-BUS), but we consume them to prevent them from getting
      // passed to apps -- see http://crbug.com/146609.
      break;
    case SILENCE_SPOKEN_FEEDBACK:
      HandleSilenceSpokenFeedback();
      break;
    case SWAP_PRIMARY_DISPLAY:
      HandleSwapPrimaryDisplay();
      break;
    case SWITCH_TO_NEXT_USER:
      HandleCycleUser(SessionStateDelegate::CYCLE_TO_NEXT_USER);
      break;
    case SWITCH_TO_PREVIOUS_USER:
      HandleCycleUser(SessionStateDelegate::CYCLE_TO_PREVIOUS_USER);
      break;
    case TOGGLE_CAPS_LOCK:
      HandleToggleCapsLock();
      break;
    case TOGGLE_MIRROR_MODE:
      HandleToggleMirrorMode();
      break;
    case TOGGLE_SPOKEN_FEEDBACK:
      HandleToggleSpokenFeedback();
      break;
    case TOGGLE_TOUCH_VIEW_TESTING:
      HandleToggleTouchViewTesting();
      break;
    case TOGGLE_WIFI:
      Shell::GetInstance()->system_tray_notifier()->NotifyRequestToggleWifi();
      break;
    case TOUCH_HUD_CLEAR:
      HandleTouchHudClear();
      break;
    case TOUCH_HUD_MODE_CHANGE:
      HandleTouchHudModeChange();
      break;
    case TOUCH_HUD_PROJECTION_TOGGLE:
      accelerators::ToggleTouchHudProjection();
      break;
    case VOLUME_DOWN:
      HandleVolumeDown(accelerator);
      break;
    case VOLUME_MUTE:
      HandleVolumeMute(accelerator);
      break;
    case VOLUME_UP:
      HandleVolumeUp(accelerator);
      break;
#else
    case DUMMY_FOR_RESERVED:
      NOTREACHED();
      break;
#endif
  }
}

bool AcceleratorController::ShouldActionConsumeKeyEvent(
    AcceleratorAction action) {
#if defined(OS_CHROMEOS)
  if (action == SILENCE_SPOKEN_FEEDBACK)
    return false;
#endif

  // Adding new exceptions is *STRONGLY* discouraged.
  return true;
}

AcceleratorController::AcceleratorProcessingRestriction
AcceleratorController::GetAcceleratorProcessingRestriction(int action) {
  ash::Shell* shell = ash::Shell::GetInstance();
  if (!shell->session_state_delegate()->IsActiveUserSessionStarted() &&
      actions_allowed_at_login_screen_.find(action) ==
          actions_allowed_at_login_screen_.end()) {
    return RESTRICTION_PREVENT_PROCESSING;
  }
  if (shell->session_state_delegate()->IsScreenLocked() &&
      actions_allowed_at_lock_screen_.find(action) ==
          actions_allowed_at_lock_screen_.end()) {
    return RESTRICTION_PREVENT_PROCESSING;
  }
  if (shell->delegate()->IsRunningInForcedAppMode() &&
      actions_allowed_in_app_mode_.find(action) ==
          actions_allowed_in_app_mode_.end()) {
    return RESTRICTION_PREVENT_PROCESSING;
  }
  if (shell->IsSystemModalWindowOpen() &&
      actions_allowed_at_modal_window_.find(action) ==
          actions_allowed_at_modal_window_.end()) {
    // Note we prevent the shortcut from propagating so it will not
    // be passed to the modal window. This is important for things like
    // Alt+Tab that would cause an undesired effect in the modal window by
    // cycling through its window elements.
    return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION;
  }
  if (shell->mru_window_tracker()->BuildMruWindowList().empty() &&
      actions_needing_window_.find(action) != actions_needing_window_.end()) {
    Shell::GetInstance()->accessibility_delegate()->TriggerAccessibilityAlert(
        ui::A11Y_ALERT_WINDOW_NEEDED);
    return RESTRICTION_PREVENT_PROCESSING_AND_PROPAGATION;
  }
  return RESTRICTION_NONE;
}

void AcceleratorController::SetKeyboardBrightnessControlDelegate(
    scoped_ptr<KeyboardBrightnessControlDelegate>
    keyboard_brightness_control_delegate) {
  keyboard_brightness_control_delegate_ =
      keyboard_brightness_control_delegate.Pass();
}

}  // namespace ash


Q: What is your in-game-name?
Q: What rank are you going for?
Q: What is your current rank?
Q: What have you done, as your current rank, to deserve the next one?
A: I have become very well adapted to the server by: talking and associating with the staff and other members. I have also built a building in one of the towns (Code town) and have also actively played for three days.
(06-19-2016, 05:10 PM)IIRoyalBloodII Wrote: Q: What is your in-game-name?
Way to adapt to our mahem! You've learned well these couple of days!


Sal & Samson go on the road to Arcade Expo 3.0 and a wild Laura of DEATHstination™ appears! We interview the walking talking Internet Pinball Database herself Imoto Arcade! Plus a bonus interview with Nico of the vg metal band – Super MADNES! The Museum of Pinball hosts Arcade Expo each year, with over 1,100(and growing) combined pinball and arcade machines on free play for 3 straight days, in the middle of nowhere (Banning, CA – a.k.a. Bumshart Nebrafornia). Trust us when we say this is retro barcade heaven.


Buenos Aires: Letras del Sur Editora, 2018. First Edition. Paperback. 159p., wrps. "El íntimo traidor" takes place in two towns south of Buenos Aires, centering around Ramón and Lario, two half-brothers separated in childhood and reunited many years later. The mystery of their lives involves a man imprisoned at the..... More about El íntimo traidor.
Item Details for El íntimo traidor.
Ask a Question about El íntimo traidor.
En el cuerpo una voz.
Mexico, D.F. Almadía Ediciones, 2017. First edition. Paperback. 219p., wrps. "En el cuerpo una voz" is a novel that centers around two brothers fleeing from the hitmen of El General, a former military officer known to practive cannibalism, after the dissolution of Boliva's government and laws. Amid the chaos, brigades..... More about En el cuerpo una voz.
Item Details for En el cuerpo una voz.
Ask a Question about En el cuerpo una voz.


text:
VLS Presents 'New Economy Law and Policy Forum: A Speaker Series on Building a Sustainable, Just and Democratic Future'
SOUTH ROYALTON, Vt., Sept. 28, 2017––The New Economy Law Center at Vermont Law School will launch a "New Economy Law and Policy Forum: A Speaker Series on Building a Sustainable, Just and Democratic Future" at 5:15 p.m. Thursday, Oct. 5, in Chase Community Center at VLS. The forum, comprised of four sessions scheduled through October and November, is designed for members of the public who seek long-term change to the current political economy and covers topics ranging from campaign finance reform to accelerating localization movements. Forum sessions, open to the public and press, will be streamed live at vermontlaw.edu/live.
"People are demanding change—a change to our politics, a change to our economy, and a change to our environment," said forum producer Professor Melissa Scanlan, director and co-founder of the New Economy Law Center. "The New Economy Law and Policy Forum will encourage participants to do more than simply resist the current system, which is characterized by large environmental costs, a fixation on GDP growth as our measure of success, and runaway consumerism. Participants will be encouraged to make meaningful change—work to energize their local economy, share wealth more equitably, or run for office. The forum is a unique opportunity for anyone to become involved in the new economy movement and learn best practices to realize their goals."
The 2017 New Economy Law and Policy Forum includes:
Session One: "The New Economy and the Quietly Emerging Next System"
5:15 p.m. Thursday, Oct. 5, Chase Community Center, VLS
What is the new economy? Just beneath the surface of media reporting a new economy is quietly emerging. It includes cooperatives, public banks, new clean energy strategies, successful campaigns to turn polluting utilities into ecologically sustainable municipal systems, along with an explosion of related developments at different levels of scale.
Session One will feature Gar Alperovitz, former Lionel R. Bauman Professor of Political Economy at the University of Maryland, co-chair of The Next System Project, and co-founder of The Democracy Collaborative, an organization devoted to developing community wealth-building approaches to local and national democratic reconstruction. Gus Speth, co-founder of the New Economy Law Center, will moderate.
Session Two: "Localize It: What Resilience Looks Like"
8:30 a.m. to 9 p.m. Saturday, Oct. 21, Chase Community Center, VLS
8:30 a.m. to 4:30 p.m. Sunday, Oct. 22, Chase Community Center, VLS
BALE (Building A Local Economy) will lead this two-day, solutions-focused gathering for leaders and community members engaged in accelerating a localizing movement in our region. BALE is working on systemic renewal in an age of climate crisis, economic injustice, and frayed democratic systems. This convening will forge new relationships and pathways toward improved localization of our economy, culture, democratic institutions, systems of energy, health and education, movements for justice, and other areas of intersection. Featured guests include Frances Moore Lappé of Small Planet Institute and Jonathan Rosenthal of New Economy Coalition.
Session Three: "Energize Democracy: How to Run for Office"
9:30 a.m. to 3 p.m. Saturday, Nov. 11, Chase Community Center, VLS
Whether you are thinking of the U.S. Senate or a local school board, come learn the basics of running for elected office: Motivation, Message, Money, and Mechanics. This nonpartisan workshop will feature former Vermont Gov. Madeleine Kunin; Kathleen Falk, who served with the United States Department of Health and Human Services under the Obama administration; Randy Brock, former state auditor for Vermont; and other leaders in public service.
Session Four: "Transform Politics: Reform Campaign Finance"
5:15 p.m. Monday, Nov. 20, Chase Community Center, VLS
Foreign money and corporate money in American politics have long threatened American democracy, but in recent years, the threat has become overwhelming. Citizens United, the Supreme Court case that redefined corruption, has had a massive impact on our politics in just seven years. Is Donald Trump taking foreign money in direct violation of the U.S. Constitution? Join us for a discussion with scholar and political activist Zephyr Teachout and moderator Melissa Scanlan of the New Economy Law Center.
For more information about the forum, including registration, visit go.vermontlaw.edu/new-economy-forum.
The New Economy Law Center at Vermont Law School explores the role of law and policy change in transitioning to a new economy. The center, the first virtual community of its kind, includes fellows who work across disciplines, states, and countries. Center co-founders Melissa Scanlan and Gus Speth collaborate with law professors, economists, writers, entrepreneurs, religious leaders, and activists. Together they engage students and scholars around the world with symposia and investigations focused on law and policy for a new economy, prioritizing ecological integrity, vibrant democracy, and social justice. For more information about the New Economy Law Center, visit vermontlaw.edu/nelc.
Vermont Law School, a private, independent institution, is home to the nation's largest and deepest environmental law program. VLS offers a Juris Doctor curriculum that emphasizes public service; three Master's Degrees—Master of Environmental Law and Policy, Master of Energy Regulation and Law, and Master of Food and Agriculture Law and Policy; and four post-JD degrees —LLM in American Legal Studies (for foreign-trained lawyers), LLM in Energy Law, LLM in Environmental Law, and LLM in Food and Agriculture Law. The school features innovative experiential programs and is home to the Environmental Law Center, South Royalton Legal Clinic, Environmental and Natural Resources Law Clinic, Energy Clinic, Food and Agriculture Clinic, and Center for Applied Human Rights. For more information, visit vermontlaw.edu, find us on Facebook, and follow us on Twitter and Instagram.
October 4, 2017 | News |
Special Olympics Vermont Announces New President and CEO
Vermont Law School Installs President and Dean McHenry, Presents 'Environmental Law for the Community and the World' Panel Oct. 13

redpajama_set_name: RedPajamaCommonCrawl


Fancy the Kim K look? Well it's now a reality for you, and a hugely profitable one for the popular selfie Queen.
Younger sister Kylie Jenner who also launched her own makeup line recently, is being given a tough run for her money by her older sister.
Kim Kardashian's makeup line is a huge hit with buyers and about 300,000 kits of it sold out in less than hour!
A great success for the 36-year-old reality star's new beauty line earned her millions in sales just minutes after launching on Wednesday. The KKW beauty line is looking very much like the next big thing.
Just minutes after her contour kits went on sale, Kardashian West announced that the makeup kits were sold out, raking in an estimated $14.4 million in sales in under an hour.
The mother of two who is turning out to be an excellent entrepreneur launched an impressive new makeup line which included Crème Contour and Highlight Kits— a bestseller which she promised will give fans her sought after signature look in just five minutes. But it's whopping price tag of $48 didn't stop it from flying off the shelves. The high quality kits come in four colors (Light, Medium, Dark and Deep Dark), and come with a dual-ended contour stick, highlighter and blending brush and sponge.
Before the launch she described how to use some of the makeup to get her look. And after the super successful sale she excitedly took to social media to express her joy and answer questions from fans and followers.
A complete package to get the truly amazing Kim Kardashian makeup look.


In one continuous movement from resource to finished end product.Our two production lines process pure steel in rolls to complete and precise tubing and profiles. Thanks to a continuous supply and automated production, we switch easily and flexibly between different processes. We do that according to your planning and timing. Each product can be followed and traced easily using an individual number.
The state-of-the-art technological machine complex, an example in the sector, produces profiles and tubing perfectly to size. With computerised precision. Regardless of amount, every length is possible – also shorter than three metres or combinations of lengths. This also applies to shape, distance between pre-drilled holes, finishing of welds or wall size. We love standards at brt, but we love changing them even more, including for packaging. This is how we make a difference in service and bespoke work.
Brt coatings have been proving their reliability for 35 years. Thanks to a robust treatment and three in-house powder coating facilities, we are proud of our great expertise. Whatever coating is required: we choose the best solution for maximum strength and lifespan.
Take advantage of an expansive and permanent inventory of tubing and profiles in standard sizes. No waiting times, no production times and always a wide array of finished products available to you. Ready for delivery. Your steel supply is uninterrupted and your production process is always smooth. Even when it's urgent.
We are proud of our products. That's why we only use steel with the iso 9001- standard and high quality galvanisation. We also apply strict checks in every phase. Every tube and profile meets the din standards nl10.204-2.2 and en10204-3. The surface, weld, wall thickness, straightness and length: each component is carefully examined and tested. Only products that meet our requirements are allowed to leave the factory.
Cold rolled steel DC01, DC02, etc.
Hot rolled steel DD11, S235JR, etc.
Galvanised steel DX51D, S220, S250GD, S355, etc.


text:
Jabal Rumḩ är ett berg i Förenade Arabemiraten.   Det ligger i emiratet Fujairah, i den nordöstra delen av landet,  kilometer öster om huvudstaden Abu Dhabi. Toppen på Jabal Rumḩ är  meter över havet, eller  meter över den omgivande terrängen. Bredden vid basen är  km.

Terrängen runt Jabal Rumḩ är kuperad åt sydväst, men åt nordost är den platt. Terrängen runt Jabal Rumḩ sluttar österut. Den högsta punkten i närheten är  meter över havet,  kilometer väster om Jabal Rumḩ. Närmaste större samhälle är Fujairah,  kilometer nordost om Jabal Rumḩ.

Trakten runt Jabal Rumḩ är ofruktbar med lite eller ingen växtlighet.  Trakten runt Jabal Rumḩ är ganska glesbefolkad, med  invånare per kvadratkilometer.  I trakten råder ett hett ökenklimat. Årsmedeltemperaturen i trakten är  °C. Den varmaste månaden är juni, då medeltemperaturen är  °C, och den kallaste är januari, med  °C. Genomsnittlig årsnederbörd är  millimeter. Den regnigaste månaden är november, med i genomsnitt  mm nederbörd, och den torraste är december, med  mm nederbörd.

Kommentarer

Källor

Berg i Fujairah
Berg i Förenade arabemiraten 200 meter över havet eller högre

redpajama_set_name: RedPajamaWikipedia


text:
Bahçe Wind Farm or Gökçedağ Wind Farm is an onshore wind power plant in the Bahçe district of Osmaniye Province, in the eastern Mediterranean Region of Turkey. Consisting of 54 wind turbines with an installed output power of 135 MW in total, the wind farm was the country's largest one when it was commissioned in 2009.

The licence for the wind farm was obtained in 2003 and will expire in 2033. Construction works at the site began in 2008. It was constructed on Gökçedağ, a mountain between Bahçe and Hasanbeyli, south of the Osmaniye-Gaziantep highway . It is operated by Rotor Co., a subsidiary of Zorlu Holding. The wind farm cost €200 million.

Technical details

Each of the 54 wind turbines of type GE 2.5 XL, manufactured by GE Wind Energy, has an installed power capacity of 2.5 MW generated by  rotor diameter at  hub height. The electricity is fed into the grid by a  long overhead transmission line.

References

Buildings and structures in Osmaniye Province
Wind farms in Turkey
Energy infrastructure completed in 2009
2009 establishments in Turkey
21st-century architecture in Turkey


text:
layout:     post
title:      Tweets
date:       2018-03-12
summary:    These are the tweets for March 12, 2018.
categories:
---

redpajama_set_name: RedPajamaGithub


text:
Enantioselective nitro-Michael reactions catalyzed by short peptides on water.
Org Biomol Chem. 2009 Oct 21; 7(20):4279-84.OB
Simple unmodified N-proline-based di- and tripeptides in combination with sodium hydroxide additive catalyze the asymmetric Michael reaction of ketones with nitroolefins to furnish the corresponding gamma-nitroketones with up to 99% yield, 99:1 dr and 70% ee at room temperature and on water without any organic cosolvent.
Publisher Full Text (DOI)
Freund M
Department of Chemistry and Pharmacy, Institute of Organic Chemistry 1, University of Erlangen-Nuremberg, Henkestrasse 42, 91054, Erlangen, Germany.
Schenker S
Tsogoeva SB
CatalysisKetonesOligopeptidesProlineStereoisomerismStyreneSubstrate SpecificityWater
Freund, Matthias, et al. "Enantioselective nitro-Michael Reactions Catalyzed By Short Peptides On Water." Organic & Biomolecular Chemistry, vol. 7, no. 20, 2009, pp. 4279-84.
Freund M, Schenker S, Tsogoeva SB. Enantioselective nitro-Michael reactions catalyzed by short peptides on water. Org Biomol Chem. 2009;7(20):4279-84.
Freund, M., Schenker, S., & Tsogoeva, S. B. (2009). Enantioselective nitro-Michael reactions catalyzed by short peptides on water. Organic & Biomolecular Chemistry, 7(20), 4279-84. https://doi.org/10.1039/b910249c
Freund M, Schenker S, Tsogoeva SB. Enantioselective nitro-Michael Reactions Catalyzed By Short Peptides On Water. Org Biomol Chem. 2009 Oct 21;7(20):4279-84. PubMed PMID: 19795068.
TY - JOUR T1 - Enantioselective nitro-Michael reactions catalyzed by short peptides on water. AU - Freund,Matthias, AU - Schenker,Sebastian, AU - Tsogoeva,Svetlana B, Y1 - 2009/08/14/ PY - 2009/10/2/entrez PY - 2009/10/2/pubmed PY - 2010/1/6/medline SP - 4279 EP - 84 JF - Organic & biomolecular chemistry JO - Org Biomol Chem VL - 7 IS - 20 N2 - Simple unmodified N-proline-based di- and tripeptides in combination with sodium hydroxide additive catalyze the asymmetric Michael reaction of ketones with nitroolefins to furnish the corresponding gamma-nitroketones with up to 99% yield, 99:1 dr and 70% ee at room temperature and on water without any organic cosolvent. SN - 1477-0539 UR - https://www.unboundmedicine.com/medline/citation/19795068/Enantioselective_nitro_Michael_reactions_catalyzed_by_short_peptides_on_water_ L2 - https://doi.org/10.1039/b910249c DB - PRIME DP - Unbound Medicine ER -
Oligopeptides
Stereoisomerism
Substrate Specificity
The small peptide-catalyzed direct asymmetric aldol reaction in water.
Chiral phosphoproline-catalyzed asymmetric Michael addition of ketones to nitroolefins: an experimental and theoretical study.
Antibody-catalyzed asymmetric intramolecular Michael addition of aldehydes and ketones to yield the disfavored cis-product.
Water-compatible iminium activation: highly enantioselective organocatalytic Michael addition of malonates to α,β-unsaturated enones.
Proline-based reduced dipeptides as recyclable and highly enantioselective organocatalysts for asymmetric Michael addition.
Highly enantioselective Michael addition of aromatic ketones to nitroolefins promoted by chiral bifunctional primary amine-thiourea catalysts based on saccharides.
Chiral Sc-catalyzed asymmetric Michael reactions of thiols with enones in water.
Phosphoramidites are efficient, green organocatalysts for the Michael reaction. Mechanistic insights into the phosphorus-catalyzed Michael reaction of alkynones and implications for asymmetric catalysis.
Organic co-solvents in aqueous DNA-based asymmetric catalysis.
Functionalized chiral ionic liquid catalyzed enantioselective desymmetrizations of prochiral ketones via asymmetric Michael addition reaction.


text:
Rick van der Meer (born 14 June 1997) is a Dutch footballer who plays for Katwijk in the Dutch Tweede Divisie.

Club career
He made his professional debut in the Eerste Divisie for Jong FC Utrecht on 5 August 2016 in a game against NAC Breda.

International
He was on the roster of the Netherlands national under-17 football team for the 2014 UEFA European Under-17 Championship, where Netherlands came as the runners-up. However, he was an unused substitute for every game in the tournament.

References

External links

1997 births
Living people
Dutch footballers
Feyenoord players
Jong FC Utrecht players
VV Katwijk players
Eerste Divisie players
Tweede Divisie players
Netherlands youth international footballers
Association football defenders
Footballers from Schiedam


Posted in Bracelets, Straps, & Accessories.
This signed Vollmer 18mm rivet trimmed, brown leather strap has an unsigned, bead blasted 18mm titanium tang type buckle. This strap should fit almost any watch with 18mm lugs. It is eight and a half inches long, and should comfortably fit even the largest wrist when mounted on a watch. This strap is new and unworn, with slight staining on the back obtained during shipping from the manufacturer. We have this strap signed by both Vollmer and Aristo, as well as unsigned.


text:
Q: ModelChoiceField invalid literal for int() with base 10: '' So I've spent the day trying to chase down a custom thing that I wanted to achieve using FormView.  When I use FormView with HTML form method="POST", I am able to get the desired result, mostly.
If a user clicks to submit a form and an empty field exists, they get an error message telling them the form is required.  I'm aware that I can make the ModelChoiceField required on the form, but was trying to implement my own logic for this.
I found through my searching that if I'm not updating anything via the form, form method="GET" may be more appropriate.  So I switched to that, and basically got this method working, but my error logic still doesn't quite work the way I'd expect.
Long story short, I can use the form method="GET", but when I try to do validation on the form, it doesn't work.  Worse yet, if I try to include an empty label, that creates an invalid literal message, because based on this SO...In a Django template, how to specify a dictionary key which is itself an attribute?  It doesn't seem possible to specify error logic/validation if the first field is essentially empty, which it is in order to create a blank first choice on ModelChoiceField.
Here's my code...
The Form...
dropdown = forms.ModelChoiceField(queryset=Author.objects.filter(is_active=True),required=False)

def __init__(self, *args, **kwargs):
    # q = kwargs.pop('dropdown', None)
    dropdown = kwargs.pop('dropdown', None)
    super(AuthorByNameForm, self).__init__(*args, **kwargs)
    self.fields['dropdown'].empty_label = ''

The HTML...
<form method="GET" action="{% url 'Main:author_detail' %}">

View By Author

    {{ form.dropdown }}

The Views...FORMVIEW
class AuthorByNameView(LoginRequiredMixin,FormView):
    form_class = AuthorNameForm
    template_name = 'author_by_name.html'

 def get_form_kwargs(self):
     kwargs = super(AuthorByNameView, self).get_form_kwargs()
     kwargs['dropdown'] = self.request.GET.get("dropdown")
     return kwargs

DetailView....
class AuthorDetailView(LoginRequiredMixin,DetailView):
    model = Author
    template_name = 'author_detail.html'

def get_object(self, queryset=None):
    return get_object_or_404(Author, id=self.request.GET.get("dropdown"))
    return get_object_or_404

Model...
Essentially just User...with a One to One with UserProfile...
class UserProfile(models.Model):
    user = models.OneToOneField(User,on_delete=models.CASCADE)

Essentially, if I removed the empty_label line from my form, the form validates, provided that the queryset isn't empty.  If I include the empty_label line of code and the user clicks on the submit button without selecting anything, they get an invalid literal for int() with base 10: '' message.  It seems the only way to work around this is to make the ModelChoiceField required=True, with the empty_label reference.
Using the request.GET appears to behave differently than the POST for good reason, I'm aware.  When I used the POST instead, everything works exactly as I want it to, except there doesn't appear to be a way to prevent the error message that I'm using to show up if the user clicks on the BACK button.
I explored some Javascript solutions today that were recommeneded via this SO,
How To Clear self.add_error in Django if user clicks on browser back button? but to no avail.
Has anyone else encountered this struggle?  Based on my knowledge up until this point, in this case since I'm not updating the records in question and just displaying them, form method="GET" would seem to make the most sense, but I seem to be pretty limited as to my options on how I can keep a blank first position in my ModelChoiceField and also do any kind of my own validation on the field in question without encountered the invalid literal message.
Thanks in advance for any thoughts.

A: def get_object(self, queryset=None):
    foo = get_object_or_404(Author, id=self.request.GET.get("dropdown"))
    return foo

Um, I'm a little baffled myself, but this doesn't look right, the two return statements. Try something like above. Also:
  self.fields['dropdown'].empty_label = None

A: Leveraging this SO....How to prevent submitting the HTML form's input field value if it empty  I was able to determine that the best way to go about this was to add the following Javascript to by my code...
$('form').submit(function() {
  var dropdown = $('#id_dropdown').val();
  if (dropdown === undefined || dropdown === "") {
    $('#id_dropdown').attr('name', '' );
  } else {
    $('#id_dropdown').attr('name', 'dropdown');
  }
});
  });

The code above forces a 404 instead of the invalid literal message that I was getting before.

redpajama_set_name: RedPajamaStackExchange


Jesus is accused before Pilate and sent to Herod, 1-7. Herod mocks him, 8-11. Herod and Pilate are made friends, 12. Barabbas is desired of the people and is released by Pilate, and Jesus is given to be crucified, 13-25. He tells the women who lament him of the destruction of Jerusalem, 26-33; prays for his enemies, 34-38. Two evildoers are crucified with him, 39-45. His death, 46-49. His burial, 50-56.
1 And the whole multitude of them arose and led him to Pilate. 2 And they began to accuse him, saying, "We found this man perverting the nation and forbidding to give tribute to Caesar, saying, that he himself is Christ a king." 3 And Pilate asked him, saying, "Are you the King of the Jews?" And he answered him and said, "You say it." 4 Then Pilate said to the chief priests and to the people, "I find no fault in this man." 5 And they were the more fierce, saying, "He stirs up the people, teaching throughout all Judea, beginning from Galilee to this place."
6 When Pilate heard of Galilee, he asked whether the man was a Galilean. 7 And as soon as he knew that he belonged to Herod's jurisdiction, he sent him to Herod, who himself was also at Jerusalem at that time.
8 And when Herod saw Jesus, he was exceedingly glad. For he had been for a long time desirous to see him, because he had heard many things of him, and he hoped to see some miracle done by him. 9 Then he questioned with him in many words, but he answered him nothing. 10 And the chief priests and scribes stood and vehemently accused him. 11 And Herod with his troops set him at nothing, mocked him, arrayed him in a gorgeous robe, and sent him back to Pilate. 12 And the same day Pilate and Herod were made friends together, for before they were at enmity between themselves.
18 And they cried out all at once, saying, "Away with this man. Release Barabbas to us." 19 (He was cast into prison for a certain sedition made in the city and for murder.) 20 Pilate therefore, willing to release Jesus, spoke again to them. 21 But they cried, saying, "Crucify, crucify him." 22 And he said to them the third time, "Why? What evil has he done? I have found no cause of death in him. I will therefore chastise him and let him go." 23 And they were urgent with loud voices, requiring that he might be crucified. And their voices and the voices of the chief priests prevailed. 24 And Pilate gave sentence that it should be as they required. 25 And he released to them him who had been cast into prison for sedition and murder, whom they had desired, but he delivered Jesus to their will.
26 And as they led him away, they laid hold upon one Simon, a Cyrenian, coming out of the country, and on him they laid the cross so that he might bear it after Jesus.
27 And there followed him a great company of people, and of women who also bewailed and lamented him. 28 But Jesus, turning to them, said, "Daughters of Jerusalem, do not weep for me, but weep for yourselves and for your children. 29 For behold, the days are coming in which they shall say, 'Blessed are the barren, the wombs that never bore, and the breasts which never nourished infants.' 30 Then ' they shall begin to say to the mountains, "Fall on us," and to the hills, "Cover us." ' 31 For if they do these things in a green tree, what will be done in the dry?"
32 And two others, who were malefactors, were led with him to be put to death.
33 And when they had come to the place which is called Calvary, there they crucified him and the malefactors, one on the right hand and the other on the left. 34 Then Jesus said, "Father, forgive them, for they do not know what they do." And they parted his clothing and cast lots. 35 And the people stood beholding. And the rulers also with them derided him, saying, "He saved others. Let him save himself, if he is Christ the chosen of God." 36 And the soldiers also mocked him, coming to him and offering him vinegar, 37 And saying, "If you are the King of the Jews, save yourself." 38 And also a superscription was written over him in letters of Greek, Latin, and Hebrew, "THIS IS THE KING OF THE JEWS."
39 And one of the malefactors who were hanged railed on him, saying, "If you are Christ, save yourself and us." 40 But the other, answering, rebuked him, saying, "Do you not fear God, seeing you are in the same condemnation? 41 And we indeed justly, for we receive the due reward of our deeds. But this man has done nothing amiss." 42 And he said to Jesus, "Lord, remember me when you come into your kingdom." 43 And Jesus said to him, "Truly I say to you, this day you shall be with me in paradise."
44 And it was about the sixth hour, and there was a darkness over all the land until the ninth hour. 45 And the sun was darkened and the veil of the temple was rent in the midst. 46 And when Jesus had cried with a loud voice, he said, "Father, ' into your hands I commend my spirit. '" And having said this, he expired. 47 Now when the centurion saw what was done, he glorified God, saying, "Certainly this was a righteous man." 48 And all the people who came together to that sight, beholding the things which were done, smote their breasts and returned. 49 And all his acquaintances and the women who followed him from Galilee stood afar off beholding these things.
50 And behold, there was a man named Joseph, a counselor. And he was a good and just man 51 (The same had not consented to the counsel and deed of them) from Arimathea, a city of the Jews, who also himself waited for the kingdom of God. 52 This man went to Pilate and petitioned for the body of Jesus. 53 And he took it down, wrapped it in linen, and laid it in a sepulcher that was hewn in stone, in which no man had ever laid before. 54 And that day was the preparation, and the sabbath drew on. 55 And the women who came with him from Galilee followed and beheld the sepulcher and how his body was laid. 56 And they returned and prepared spices and ointments. And they rested on the sabbath according to the commandment.
[v.1] - Gospel Link: Matthew 27:1-2; Mark 15:1; John 18:28.
[v.2-3] - Gospel Link: Matthew 27:11-12; Mark 15:2-3.
[v.3-4] - Gospel Link: John 18:33, 37-38.
[v.17-23] - Gospel Link: Matthew 27:15-23; Mark 15:6-14; John 18:39-40, 19:6, 15.
[v.24-25] - Gospel Link: Matthew 27:24-26; Mark 15:15; John 19:1-3, 24.
[v.26] - Gospel Link: Matthew 27:32; Mark 15:21.
[v.30] - Quoting Hosea 10:8.
[v.33-34] - Gospel Link: Matthew 27:33-36, 38; Mark 15:22-25, 27; John 19:17-18, 23-24.
[v.35-37] - Gospel Link: Matthew 27:39-43; Mark 15:29-32; John 19:29.
[v.38] - Gospel Link: Matthew 27:37; Mark 15:26; John 19:19-20.
[v.39] - Gospel Link: Matthew 27:44; Mark 15:32.
[v.41] - "And we indeed justly" - In other words, "And we indeed justly deserve our condemnation..." Implied from the question asked in verse 40.
[v.44] - Gospel Link: Matthew 27:45; Mark 15:33.
[v.45-49] - Gospel Link: Matthew 27:50-56; Mark 15:37-41.
[v.46a] - Quoting Psalm 31:5 (LXX).
[v.46b] - Gospel Link: John 19:30.
[v.49] - Gospel Link: John 19:25.
[v.50-55] - Gospel Link: Matthew 27:57-61; Mark 15:42-47; John 19:38-42.
[v.56] - "according to the commandment" - Reference, Exodus 20:8-11. See also, Genesis 2:2-3; Deuteronomy 5:12-15.


Have you driven a 1980 Porsche 911?
Displaying all 5 1980 Porsche 911 reviews.
Perfect 10+ There Is No Better Car Then Modified 930 Like I Had. — There is NO better car then modified 930 like I had if you take all in account: Looks, performance, handling, reliability etc. Just make sure you know how to drive very well to take full advantage of the car has to offer.! It's not for people who "think" they know how to drive. BTW: I am talking about my modify 930, I would not drive stock ugly version. Problem is with agency and local mechanics.
Your Mom Lives This Car — I Love the 911! It's a classic car, though. You can't race it. Well, you could, but thats bad. You gotta take car of it. Only take it out on sunny days and clean it all the time. High maintenance costs, as most classic cars do hace. And it requires a gigantic amount of time to take care of it properly. But its worth it.
Don't Know If I Can Ever Get Rid Of This Car... Well, Besides The 'cold, Dead Fingers' Time... — Hmmm... wasn't sure how to put the appearance. Out of the box, it's one of my favorites - the Weissach Edition colors, the tail is my all-time favorite of all the tails, etc. etc. However, it now having 160k+ miles on it, some of which were not so tender, the peeling paint and such mean cosmetically it needs work. I still love it, its seen me through so much by now!
Great Fun And Usually Inexpensive. — For a car that's 29 years old it's incredibly solid, fun to drive and quick. Steering feel is incredible and nothing sounds like an air cooled flat 6. In the midst of a complete suspension rehab, which is pricey for these cars but it's all original and worn out.


We have been making sock monsters this week and then I suddenly had the idea to make these little fellows. All you need is a worn out kids sock and a cone. If you use a big pine cone you might need a grown up sock.
You need to cut the cap of a sock and then half it. Turn it inside out and sew the long side closed. Turn it back right side out and pull it over the cone. Cut another straight piece of the sock, thick enough that it fits as a scarf for the size of cone you use. In our case it was roughly a centimetre. Cut the loop open and tie it around the cone. If you want to you can use a permanent marker to make hime two eyes. Tada, you are done. See how fast this was?
If you have an old red sock you could easily turn this into a Santa with some added cotton wool for a beard.
LOL, Thanks for stopping by Jinzo!
Hey Jinzo, I was actually thinking of the two of you! How are you and the cheetah? 24h per day are just not enough at the moment to bring all my ideas here, but I hope I will be back some time as I miss this spot! Please give the Cheetah some gentle chin scritches from me.
The cheetah and I still reviewing a lot of fun movies,I did Thanksgiving this year and the cheetah killed his second mouse. Winter is trying to impose its way here but no serious snow as of yet.
The cheetah and I are missing you!!


text:
The UPS Foundation Adds Nutrition To Initiative To Alleviate Hunger
Submitted by: UPS
Categories: Philanthropy & Corporate Contributions
Posted: Jan 18, 2005 – 11:00 PM EST
Jan. 18 /CSRwire/ - ATLANTA, Jan. 19, 2005 - Do hunger and obesity go together?
To a surprising extent, say nutrition experts, hunger often leads to obesity. Families unable to afford nutritious food often end up developing unhealthy eating habits, setting the stage for obesity and a variety of other health problems. The UPS Foundation, which for 15 years has pursued a major initiative to alleviate hunger in America, today announced it was broadening that effort to address nutrition and obesity issues.
The UPS Foundation's new initiative, "The National Collaboration to Reduce Hunger and Improve Nutrition," has been launched with the award of $2 million in grants to eight different organizations.
The organizations are based across the country from California and Ohio to Illinois, Virginia and Washington, D.C., and already are involved in various aspects of the fights against hunger and obesity. The Society of Saint Andrew in Big Island, Va., for example, is working to expand distribution of otherwise wasted fresh produce from local farms to local food banks. The Children's Hunger Alliance in Columbus, Ohio, is expanding access to and improving the quality of school meals.
"Millions of Americans look hunger in the face every day. They feel the consequences of poor nutrition and in many cases suffer from the effects of obesity," said Evern Cooper Epps, president of The UPS Foundation. "The connection between inadequate financial resources and poor nutrition is clear and compelling. We want to be instrumental in the fight against hunger by providing those individuals at risk with access to nutritious foods as well as information and resources."
Government reports show 36.3 million Americans - 13.3 million of whom are children - went hungry last year. Not surprisingly, there was a double-digit increase in requests for emergency food assistance even as medical evidence continues to mount showing America's children are facing serious health threats because of widespread obesity and inactivity.
"Obesity and hunger are major public health concerns facing our nation today," said Edward Cooney, executive director of the bipartisan Congressional Hunger Center in Washington, D.C., and a former Agriculture Department nutrition program director. "The announcement that The UPS Foundation is launching a new funding initiative to fight hunger centered on improving nutrition and decreasing obesity is of critical importance to the nation's nutritionally vulnerable children and adults."
In addition to the $2 million in new grants, The UPS Foundation since 1989 has supported food banks and local feeding programs through its Prepared and Perishable Food Rescue Initiative. UPS has helped local organizations by providing more than $10 million to help recover and distribute more than 300 million pounds of food to feed hungry Americans. UPS has not only contributed financially to the initiative, but also has provided technical, logistical and managerial expertise.
Founded in 1951 and based in Atlanta, Ga., The UPS Foundation identifies specific areas where its support will clearly impact social issues. The Foundation's major initiatives currently include programs that support increased nationwide volunteerism, family and workplace literacy and hunger relief. In 2003, The UPS Foundation donated more than US$39.8 million to charitable organizations worldwide. Visit community.ups.com for more information about UPS's community involvement.
UPS is the world's largest package delivery company and a global leader in supply chain services, offering an extensive range of options for synchronizing the movement of goods, information and funds. Headquartered in Atlanta, Ga., UPS serves more than 200 countries and territories worldwide. UPS's stock trades on the New York Stock Exchange (UPS), and the company can be found on the Web at UPS.com.
Editor's Note: A list of The UPS Foundation grants made to fight hunger and obesity is appended to this release.
Initial Grantees of The UPS Foundation's "National Collaboration to Reduce Hunger & Improve Nutrition"
The UPS Foundation National Collaboration to Reduce Hunger and Improve Nutrition provides resources to major national and regional organizations to address critical hunger, obesity and nutrition issues in communities across the country. The grantmaking program seeks to increase access to high-quality nutritious foods, increase nonprofit organizational capacity and increase collaboration among organizations fighting hunger and obesity. Since 1989, The UPS Foundation has invested more than $12 million in the fight against hunger in America.
The Society of Saint Andrew - Big Island, Va. - $250,000
To expand distribution of otherwise wasted fresh produce from local farms through gleaning to local food banks while increasing local volunteerism and organizational capacity.
Share Our Strength - Washington, D.C. - $250,000
To build the capacity and expand the reach of the Operation Frontline nutrition education program.
America's Second Harvest - Chicago, Ill. - $250,000
To develop a web-based allocation tool that will encourage local affiliates to maximize and share their local food resources and improve access to nutritional food products.
National Conference of State Legislatures - Washington, D.C. - $250,000
To educate state legislators on the challenges and opportunities to improve nutrition and fight obesity while connecting them with their federal counterparts and nonprofit community organizations.
Food Research and Action Center - Washington, D.C. - $250,000
To provide leadership and technical assistance to state and local anti-hunger organizations, schools and nutrition service providers to increase participation of families and schools in programs such as summer food, school breakfast and school wellness policies.
D.C. Central Kitchens, Inc. - Washington, D.C. - $250,000
To expand distribution of meals to the hungry, increase college campus volunteerism, increase nutrition education for the hungry and provide job training to low-income individuals through the national Campus Kitchens program.
Community Food Security Coalition - Venice, Calif. - $250,000
To provide targeted and strategic assistance to three regional community food security initiatives in the Southwest, Baltimore, Md. and New York.
Children's Hunger Alliance - Columbus, Ohio - $250,000
To expand access to school breakfasts, improve the quality of food offered to children during the school day and increase opportunities for youth to be involved in physical activity outside the regular school day in Ohio
Kristen Petrella
UPS is a global leader in logistics, offering a broad range of solutions including transporting packages and freight; facilitating international trade, and deploying advanced technology to more efficiently manage the world of business. Headquartered in Atlanta, UPS serves 10.6 million customer...
UPS Launches First-Of-Its-Kind Women Exporters Program Workshops in the U.S.
UPS Brings Commitment and Support to Pride Month
UPS Makes Largest Purchase of Renewable Natural Gas Ever in the U.S.
Innovative Technologies Driving Sustainability at UPS
UPS Commits to More Alternative Vehicles, Fuel and Renewable Power
UPS Drives 1 Billion Cleaner Miles, Achieves Goal One Year Early


text:
Hong Kong Startup News Round Up - 11 Nov 2018
5 in 5 Minutes
by WHub - - 11-11-2018
China overtakes US in number of new companies worth at least US$1 billion
According to Shanghai-based Hurun Report, China's sprawling network of start-ups worth at least US$1 billion expanded to 181 in the third quarter, overtaking the United States as home to greatest number of successful new ventures. The world's second-largest economy has added 34 "unicorns", or start-ups worth at least US$1 billion, in the third quarter, the publisher said in a release on Friday.
The start-ups are worth a combined 4.8 trillion yuan (US$696 billion), and the valuation of its biggest unicorn, Ant Financial, has exceeded its counterparts in the US – Uber and Airbnb, the report said. China's vast number of start-ups in industries spanning from e-commerce to fintech and artificial intelligence has transformed the way Chinese people eat, shop and entertain over the past decade, riding on a flood of enthusiastic early investment capital from within China and abroad.
WHub signs MoU with Y&Archer to build synergy among HK & Korean Startups
Karena Belin, Co-Founder and CEO of WHub has signed a Memorandum of Understanding (MoU) with Jino Shin, CEO of Y&Archer, a leading global accelerator that works closely with the Korean Government, during the A-Stream Asian Startup Conference on Tuesday. The aim of the MoU is to foster synergy and mutual growth in these two startup ecosystems, and to join forces to improve the Tech space in Asia.
Y&Archer will be exhibiting and speaking at the Startup Impact Summit on January 25 to provide visiting startups the possibility of connecting with the Korean Government, international Venture Capitalists and public institutions. Grab your tickets, and come meet them.
Social Media Content & Analytics Startup PressLogic raises $10M from Meitu
PressLogic, a Hong Kong-based social media content and data analytics startup, announced today that it has raised a $10 million Series A+ round from Meitu, developer of the popular Chinese selfie app. PressLogic will use the funds to launch its new lifestyle brand GirlStyle and enter e-commerce with its proprietary algorithms, which predict what topics will trend on social media among specific groups.
The new round brings PressLogic's total raised to $15 million. Meitu had acquired a minority stake in PressLogic last year. PressLogic hasn't revealed if Meitu's photo imaging technology will be integrated into its platform, but Cheung says it would like to extend MediaLens' analytics to images, too, as data from photos and videos shared on social media is potentially valuable.
Crypto Startup Ledger Expands to Asia Pacific in Hong Kong
Paris-based crypto security giant Ledger, has announced its expansion into Asia with the establishment of a Hong Kong office and the appointment of Benjamin Soong as Head of Asia Pacific (APAC). The launch into the new terrain will see Soong overseeing the entire Ledger's APAC operations as the company extends into fulfilling the growing demand for both Ledger Vault and the Ledger Nano S.
According to Soong, "APAC is a key market that has seen increased demand. We are confident we can deliver top security for both consumers and financial institutions to protect their crypto assets."
Mizuho to support startups via MoU with Cyberport and HKSTP
Mizuho Financial Group, Inc., a banking holding company from Tokyo, Cyberport, and Hong Kong Science & Technology Parks Corporation (HKSTP) have concluded a memorandum of understanding (MOU) for business cooperation for the purpose of supporting the growth of startup businesses in Japan and Hong Kong.
Based on the MOU, the 3 parties will support Japanese and Hong Kong startups in entering the two markets, participating in business demonstration events, and pursuing R&D in the abovementioned fields. They will work to contribute to the economic development of Japan and of the Greater Bay Area encompassing Hong Kong, Shenzhen, and Guangzhou.
Recently, the Hong Kong government has been increasing its support to startups and its efforts to develop an innovation-friendly environment. Hong Kong is fast becoming an innovation hub, leveraging its highly open financial market.
Sign Up to our Weekly Newsletter NOW
Next on your reading list
Hong Kong Startup News Roundup - 10 January 2021
Hopin buys livestreaming startup StreamYard for $250M as it looks to expand its product lineup This morning Hopin, a quickly growing startup that s...
WHub |
Hong Kong Startup News Roundup - 3 January 2021
New World's Impact Kommons Embarks On a New Phase to Nurture Global Green Technology Start-ups. Adrian Cheng: Green Tech Set to Redefine "New Norma...
Hong Kong Startup News Roundup - 27 December 2020
On-demand logistics company Lalamove gets $515 million Series E Lalamove will extend its network to cover more small Chinese cities after raising $...


text:
Tusk ist das zwölfte Studioalbum der Rockband Fleetwood Mac. Das Doppelalbum erschien 1979. In Großbritannien erreichte es den ersten Platz der Charts.

Geschichte
Mit Rumours hatte die Band 1977 ein Album vorgelegt, das zu den erfolgreichsten der Band- und Rockgeschichte gehörte. Sie gewannen Grammy Awards für dieses Album und gingen 1978 erneut ins Studio, um neue Songs aufzunehmen. Der finanzielle Erfolg von Rumours sorgte dafür, dass die Band ein Budget für die Aufnahmen von 1 Mio. $ erhielt.

Die Geldgeber von Warner erwarteten ein ähnlich kompaktes Mainstreamalbum wie Rumours es war. Das monumentale Doppelalbum Tusk wurde dann jedoch von musikalischen Experimenten Lindsey Buckinghams geprägt und kam weniger gut an als das Vorgängeralbum. Es erreichte nicht die erwartete Topplatzierung in den US-Charts und kam bis auf den 4. Platz. Dennoch wurden in den nächsten Jahren über zwei Millionen Alben von Tusk verkauft. In Großbritannien erreichte es ebenso wie Rumours den ersten Platz der Charts, und in Deutschland war es mit Platz 3 als höchste Platzierung sogar erfolgreicher als Rumours, das nur den 6. Platz erreicht hatte.

2001 wurde das Album von der Gruppe Camper Van Beethoven gecovert und 2002 über das Label Pitch-A-Tent veröffentlicht. 2004 erschien eine Neuauflage als Doppel-CD, die neben den 20 Original-Songs eine weitere CD mit Demo-, Live- und Remixversionen enthält.

2015 wurde das Album als Super Deluxe Edition wiederveröffentlicht. Die Box enthält eine remasterte Fassung des Originalalbums auf 2 Vinyl-LPs und CD, zwei weitere CDs mit zuvor unveröffentlichten Alternativ- und Demoversionen, zwei CDs mit Liveaufnahmen der 1980er Tusk-Tournee und eine DVD mit einer 5.1 Surround-Abmischung in den Tonformaten dts und Dolby Digital. Die Live-Aufnahmen, sowie die Alternativfassung des Albums wurden im Laufe des Jahres 2015 ebenfalls als 3-LP (In Concert) bzw. 2-LP (The Alternate Tusk) veröffentlicht.

Titelliste
 Over and Over (McVie) – 4:36
 The Ledge (Buckingham) – 2:02
 Think About Me (McVie) – 2:44
 Save Me a Place (Buckingham) – 2:40
 Sara (Nicks) – 6:26
 What Makes You Think You're the One (Buckingham) – 3:32
 Storms (Nicks) – 5:29
 That's All for Everyone (Buckingham) – 3:04
 Not That Funny (Buckingham) – 3:13
 Sisters of the Moon (Nicks) – 4:45
 Angel (Nicks) – 4:53
 That's Enough for Me (Buckingham) – 1:48
 Brown Eyes (McVie) – 4:30
 Never Make Me Cry (McVie) – 2:14
 I Know I'm Not Wrong (Buckingham) – 3:02
 Honey Hi (McVie) – 2:43
 Beautiful Child (Nicks) – 5:23
 Walk a Thin Line (Buckingham) – 3:48
 Tusk (Buckingham) – 3:36
 Never Forget (McVie) – 3:44

Weblinks

Album 1979
Album (Rock)
Fleetwood Mac
Nummer-eins-Album
Mehrfach-Platin-Album (Vereinigte Staaten)


text:
Q: Can log4j's error method print stack trace without string argument? In regards to Log4j v2, I'd like to call log.error(exceptionTypeObj) and have the stack trace printed to my logfile instead of exceptionTypeObj.toString(). Is that possible?
I'd rather write code like log.error(e) and be done with it.
It's error prone and redundant for me to keep writing something like log.error("error", exceptionTypeObj).

A: The String parameter is redundant because you are not using it for the correct purpose. An Exception will tell you what error occurred but it won't tell you what you were trying to do when it happened. That is why you should always provide the string. Provide a String that says something like "Error occurred while attempting to update the user profile for user {}", and then provide the user name or id.
Without the String parameter you are forcing your support staff to call engineering to find out what the exception means and what they should do about it.