Remove aura enum from DesktopMediaID to fix desktop mirroring audio (CrOS).
[chromium-blink-merge.git] / chrome / browser / renderer_context_menu / spelling_bubble_model.cc
blob3c179d0c6cef79b28f168c765f0ec30c419583d2
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/renderer_context_menu/spelling_bubble_model.h"
7 #include "base/logging.h"
8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/pref_names.h"
11 #include "chrome/common/url_constants.h"
12 #include "chrome/grit/chromium_strings.h"
13 #include "chrome/grit/generated_resources.h"
14 #include "content/public/browser/web_contents.h"
15 #include "grit/components_strings.h"
16 #include "grit/theme_resources.h"
17 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/base/resource/resource_bundle.h"
19 #include "ui/gfx/image/image.h"
21 using content::OpenURLParams;
22 using content::Referrer;
23 using content::WebContents;
25 SpellingBubbleModel::SpellingBubbleModel(Profile* profile,
26 WebContents* web_contents,
27 bool include_autocorrect)
28 : profile_(profile),
29 web_contents_(web_contents),
30 include_autocorrect_(include_autocorrect) {
33 SpellingBubbleModel::~SpellingBubbleModel() {
36 base::string16 SpellingBubbleModel::GetTitle() const {
37 return l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_SPELLING_ASK_GOOGLE);
40 base::string16 SpellingBubbleModel::GetMessageText() const {
41 return l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_SPELLING_BUBBLE_TEXT);
44 base::string16 SpellingBubbleModel::GetButtonLabel(BubbleButton button) const {
45 return l10n_util::GetStringUTF16(button == BUTTON_OK ?
46 IDS_CONTENT_CONTEXT_SPELLING_BUBBLE_ENABLE :
47 IDS_CONTENT_CONTEXT_SPELLING_BUBBLE_DISABLE);
50 void SpellingBubbleModel::Accept() {
51 SetPref(true);
54 void SpellingBubbleModel::Cancel() {
55 SetPref(false);
58 base::string16 SpellingBubbleModel::GetLinkText() const {
59 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
62 void SpellingBubbleModel::LinkClicked() {
63 OpenURLParams params(
64 GURL(chrome::kPrivacyLearnMoreURL), Referrer(), NEW_FOREGROUND_TAB,
65 ui::PAGE_TRANSITION_LINK, false);
66 web_contents_->OpenURL(params);
69 void SpellingBubbleModel::SetPref(bool enabled) {
70 PrefService* pref = profile_->GetPrefs();
71 DCHECK(pref);
72 pref->SetBoolean(prefs::kSpellCheckUseSpellingService, enabled);
73 if (include_autocorrect_)
74 pref->SetBoolean(prefs::kEnableAutoSpellCorrect, enabled);