Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: chrome/browser/tab_contents/spelling_menu_observer.cc

Issue 12222003: Rebase ConfirmBubbleViews on DialogDelegateView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and rebase to retry CQ. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/tab_contents/spelling_menu_observer.h" 5 #include "chrome/browser/tab_contents/spelling_menu_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/i18n/case_conversion.h" 9 #include "base/i18n/case_conversion.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/app/chrome_command_ids.h" 12 #include "chrome/app/chrome_command_ids.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/spellchecker/spellcheck_factory.h" 14 #include "chrome/browser/spellchecker/spellcheck_factory.h"
15 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" 15 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h"
16 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" 16 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h"
17 #include "chrome/browser/spellchecker/spellcheck_service.h" 17 #include "chrome/browser/spellchecker/spellcheck_service.h"
18 #include "chrome/browser/spellchecker/spelling_service_client.h" 18 #include "chrome/browser/spellchecker/spelling_service_client.h"
19 #include "chrome/browser/tab_contents/render_view_context_menu.h" 19 #include "chrome/browser/tab_contents/render_view_context_menu.h"
20 #include "chrome/browser/tab_contents/spelling_bubble_model.h" 20 #include "chrome/browser/tab_contents/spelling_bubble_model.h"
21 #include "chrome/browser/ui/confirm_bubble.h" 21 #include "chrome/browser/ui/confirm_bubble.h"
22 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
24 #include "chrome/common/spellcheck_result.h" 24 #include "chrome/common/spellcheck_result.h"
25 #include "content/public/browser/render_view_host.h" 25 #include "content/public/browser/render_view_host.h"
26 #include "content/public/browser/render_widget_host_view.h" 26 #include "content/public/browser/render_widget_host_view.h"
27 #include "content/public/browser/web_contents.h"
28 #include "content/public/browser/web_contents_view.h"
27 #include "content/public/common/context_menu_params.h" 29 #include "content/public/common/context_menu_params.h"
28 #include "grit/generated_resources.h" 30 #include "grit/generated_resources.h"
29 #include "ui/base/l10n/l10n_util.h" 31 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/gfx/rect.h" 32 #include "ui/gfx/rect.h"
31 33
32 using content::BrowserThread; 34 using content::BrowserThread;
33 35
34 SpellingMenuObserver::SpellingMenuObserver(RenderViewContextMenuProxy* proxy) 36 SpellingMenuObserver::SpellingMenuObserver(RenderViewContextMenuProxy* proxy)
35 : proxy_(proxy), 37 : proxy_(proxy),
36 loading_frame_(0), 38 loading_frame_(0),
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // The spelling service can be toggled by the user only if it is not managed. 260 // The spelling service can be toggled by the user only if it is not managed.
259 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_TOGGLE && 261 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_TOGGLE &&
260 integrate_spelling_service_.IsUserModifiable()) { 262 integrate_spelling_service_.IsUserModifiable()) {
261 // When a user enables the "Ask Google for spelling suggestions" item, we 263 // When a user enables the "Ask Google for spelling suggestions" item, we
262 // show a bubble to confirm it. On the other hand, when a user disables this 264 // show a bubble to confirm it. On the other hand, when a user disables this
263 // item, we directly update/ the profile and stop integrating the spelling 265 // item, we directly update/ the profile and stop integrating the spelling
264 // service immediately. 266 // service immediately.
265 if (!integrate_spelling_service_.GetValue()) { 267 if (!integrate_spelling_service_.GetValue()) {
266 content::RenderViewHost* rvh = proxy_->GetRenderViewHost(); 268 content::RenderViewHost* rvh = proxy_->GetRenderViewHost();
267 gfx::Rect rect = rvh->GetView()->GetViewBounds(); 269 gfx::Rect rect = rvh->GetView()->GetViewBounds();
268 chrome::ShowConfirmBubble(rvh->GetView()->GetNativeView(), 270 chrome::ShowConfirmBubble(
269 gfx::Point(rect.CenterPoint().x(), rect.y()), 271 #if defined(TOOLKIT_VIEWS)
270 new SpellingBubbleModel( 272 proxy_->GetWebContents()->GetView()->GetTopLevelNativeWindow(),
271 proxy_->GetProfile(), 273 #else
272 proxy_->GetWebContents(), 274 rvh->GetView()->GetNativeView(),
273 false)); 275 #endif
276 gfx::Point(rect.CenterPoint().x(), rect.y()),
277 new SpellingBubbleModel(proxy_->GetProfile(),
278 proxy_->GetWebContents(),
279 false));
274 } else { 280 } else {
275 Profile* profile = proxy_->GetProfile(); 281 Profile* profile = proxy_->GetProfile();
276 if (profile) 282 if (profile)
277 profile->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, 283 profile->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService,
278 false); 284 false);
279 profile->GetPrefs()->SetBoolean(prefs::kEnableAutoSpellCorrect, 285 profile->GetPrefs()->SetBoolean(prefs::kEnableAutoSpellCorrect,
280 false); 286 false);
281 } 287 }
282 } 288 }
283 // Autocorrect requires use of the spelling service and the spelling service 289 // Autocorrect requires use of the spelling service and the spelling service
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 void SpellingMenuObserver::OnAnimationTimerExpired() { 358 void SpellingMenuObserver::OnAnimationTimerExpired() {
353 // Append '.' characters to the end of "Checking". 359 // Append '.' characters to the end of "Checking".
354 loading_frame_ = (loading_frame_ + 1) & 3; 360 loading_frame_ = (loading_frame_ + 1) & 3;
355 string16 loading_message = loading_message_ + string16(loading_frame_,'.'); 361 string16 loading_message = loading_message_ + string16(loading_frame_,'.');
356 362
357 // Update the menu item with the text. We disable this item to prevent users 363 // Update the menu item with the text. We disable this item to prevent users
358 // from selecting it. 364 // from selecting it.
359 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, 365 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false,
360 loading_message); 366 loading_message);
361 } 367 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/spelling_bubble_model.cc ('k') | chrome/browser/ui/views/confirm_bubble_views.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698