cros: Remove default pinned apps trial.
[chromium-blink-merge.git] / chrome / browser / tab_contents / spelling_bubble_model.cc
blobb1d4b54763544f4edc2aa6e09359620c7c0cbb91
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/tab_contents/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 "content/public/browser/web_contents.h"
13 #include "grit/generated_resources.h"
14 #include "grit/theme_resources.h"
15 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/image/image.h"
19 using content::OpenURLParams;
20 using content::Referrer;
21 using content::WebContents;
23 SpellingBubbleModel::SpellingBubbleModel(Profile* profile,
24 WebContents* web_contents,
25 bool include_autocorrect)
26 : profile_(profile),
27 web_contents_(web_contents),
28 include_autocorrect_(include_autocorrect) {
31 SpellingBubbleModel::~SpellingBubbleModel() {
34 base::string16 SpellingBubbleModel::GetTitle() const {
35 return l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_SPELLING_ASK_GOOGLE);
38 base::string16 SpellingBubbleModel::GetMessageText() const {
39 return l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_SPELLING_BUBBLE_TEXT);
42 gfx::Image* SpellingBubbleModel::GetIcon() const {
43 return &ResourceBundle::GetSharedInstance().GetImageNamed(
44 IDR_PRODUCT_LOGO_16);
47 base::string16 SpellingBubbleModel::GetButtonLabel(BubbleButton button) const {
48 return l10n_util::GetStringUTF16(button == BUTTON_OK ?
49 IDS_CONTENT_CONTEXT_SPELLING_BUBBLE_ENABLE :
50 IDS_CONTENT_CONTEXT_SPELLING_BUBBLE_DISABLE);
53 void SpellingBubbleModel::Accept() {
54 SetPref(true);
57 void SpellingBubbleModel::Cancel() {
58 SetPref(false);
61 base::string16 SpellingBubbleModel::GetLinkText() const {
62 return l10n_util::GetStringUTF16(IDS_LEARN_MORE);
65 void SpellingBubbleModel::LinkClicked() {
66 OpenURLParams params(
67 GURL(chrome::kPrivacyLearnMoreURL), Referrer(), NEW_FOREGROUND_TAB,
68 content::PAGE_TRANSITION_LINK, false);
69 web_contents_->OpenURL(params);
72 void SpellingBubbleModel::SetPref(bool enabled) {
73 PrefService* pref = profile_->GetPrefs();
74 DCHECK(pref);
75 pref->SetBoolean(prefs::kSpellCheckUseSpellingService, enabled);
76 if (include_autocorrect_)
77 pref->SetBoolean(prefs::kEnableAutoSpellCorrect, enabled);