summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/gtk/password_menu_model.cc
blob: 3e0c77323768a759cacae3b0ba24d984ae5082df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2013 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 "chrome/browser/ui/gtk/password_menu_model.h"

#include "chrome/browser/ui/content_settings/content_setting_bubble_model.h"
#include "chrome/browser/ui/gtk/content_setting_bubble_gtk.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"

PasswordMenuModel::PasswordMenuModel(
    ContentSettingBubbleModel* bubble_model,
    ContentSettingBubbleGtk* bubble_contents)
    : ui::SimpleMenuModel(this),
      media_bubble_model_(bubble_model),
      media_bubble_contents_(bubble_contents) {
  AddItem(COMMAND_ID_NOPE,
          l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CANCEL_DROP_DOWN));
  AddItem(COMMAND_ID_NEVER_FOR_THIS_SITE,
          l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BLACKLIST_DROP_DOWN));
}

PasswordMenuModel::~PasswordMenuModel() {}

bool PasswordMenuModel::IsCommandIdChecked(int command_id) const {
  return false;
}

bool PasswordMenuModel::IsCommandIdEnabled(int command_id) const {
  return true;
}

bool PasswordMenuModel::GetAcceleratorForCommandId(
    int command_id,
    ui::Accelerator* accelerator) {
  return false;
}

void PasswordMenuModel::ExecuteCommand(int command_id,
                                       int event_flags) {
  switch (static_cast<CommandID>(command_id)) {
    case COMMAND_ID_NOPE:
      media_bubble_model_->OnDoneClicked();
      media_bubble_contents_->Close();
      break;
    case COMMAND_ID_NEVER_FOR_THIS_SITE: {
      media_bubble_model_->OnCancelClicked();
      media_bubble_contents_->Close();
      break;
    }
  }
}