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

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

Issue 393763002: MacViews: Refactor ShowConfirmBubble to also take a gfx::NativeWindow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: new approach: extra argument Created 6 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/confirm_bubble_cocoa.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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/renderer_context_menu/spelling_menu_observer.h" 5 #include "chrome/browser/renderer_context_menu/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"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_TOGGLE && 291 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_TOGGLE &&
292 integrate_spelling_service_.IsUserModifiable()) { 292 integrate_spelling_service_.IsUserModifiable()) {
293 // When a user enables the "Ask Google for spelling suggestions" item, we 293 // When a user enables the "Ask Google for spelling suggestions" item, we
294 // show a bubble to confirm it. On the other hand, when a user disables this 294 // show a bubble to confirm it. On the other hand, when a user disables this
295 // item, we directly update/ the profile and stop integrating the spelling 295 // item, we directly update/ the profile and stop integrating the spelling
296 // service immediately. 296 // service immediately.
297 if (!integrate_spelling_service_.GetValue()) { 297 if (!integrate_spelling_service_.GetValue()) {
298 content::RenderViewHost* rvh = proxy_->GetRenderViewHost(); 298 content::RenderViewHost* rvh = proxy_->GetRenderViewHost();
299 gfx::Rect rect = rvh->GetView()->GetViewBounds(); 299 gfx::Rect rect = rvh->GetView()->GetViewBounds();
300 chrome::ShowConfirmBubble( 300 chrome::ShowConfirmBubble(
301 #if defined(TOOLKIT_VIEWS)
302 proxy_->GetWebContents()->GetTopLevelNativeWindow(), 301 proxy_->GetWebContents()->GetTopLevelNativeWindow(),
303 #else
304 rvh->GetView()->GetNativeView(), 302 rvh->GetView()->GetNativeView(),
305 #endif
306 gfx::Point(rect.CenterPoint().x(), rect.y()), 303 gfx::Point(rect.CenterPoint().x(), rect.y()),
307 new SpellingBubbleModel(proxy_->GetProfile(), 304 new SpellingBubbleModel(proxy_->GetProfile(),
308 proxy_->GetWebContents(), 305 proxy_->GetWebContents(),
309 false)); 306 false));
310 } else { 307 } else {
311 Profile* profile = proxy_->GetProfile(); 308 Profile* profile = proxy_->GetProfile();
312 if (profile) { 309 if (profile) {
313 profile->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, 310 profile->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService,
314 false); 311 false);
315 profile->GetPrefs()->SetBoolean(prefs::kEnableAutoSpellCorrect, 312 profile->GetPrefs()->SetBoolean(prefs::kEnableAutoSpellCorrect,
316 false); 313 false);
317 } 314 }
318 } 315 }
319 } 316 }
320 // Autocorrect requires use of the spelling service and the spelling service 317 // Autocorrect requires use of the spelling service and the spelling service
321 // can be toggled by the user only if it is not managed. 318 // can be toggled by the user only if it is not managed.
322 if (command_id == IDC_CONTENT_CONTEXT_AUTOCORRECT_SPELLING_TOGGLE && 319 if (command_id == IDC_CONTENT_CONTEXT_AUTOCORRECT_SPELLING_TOGGLE &&
323 integrate_spelling_service_.IsUserModifiable()) { 320 integrate_spelling_service_.IsUserModifiable()) {
324 // When the user enables autocorrect, we'll need to make sure that we can 321 // When the user enables autocorrect, we'll need to make sure that we can
325 // ask Google for suggestions since that service is required. So we show 322 // ask Google for suggestions since that service is required. So we show
326 // the bubble and just make sure to enable autocorrect as well. 323 // the bubble and just make sure to enable autocorrect as well.
327 if (!integrate_spelling_service_.GetValue()) { 324 if (!integrate_spelling_service_.GetValue()) {
328 content::RenderViewHost* rvh = proxy_->GetRenderViewHost(); 325 content::RenderViewHost* rvh = proxy_->GetRenderViewHost();
329 gfx::Rect rect = rvh->GetView()->GetViewBounds(); 326 gfx::Rect rect = rvh->GetView()->GetViewBounds();
330 chrome::ShowConfirmBubble(rvh->GetView()->GetNativeView(), 327 chrome::ShowConfirmBubble(
331 gfx::Point(rect.CenterPoint().x(), rect.y()), 328 proxy_->GetWebContents()->GetTopLevelNativeWindow(),
332 new SpellingBubbleModel( 329 rvh->GetView()->GetNativeView(),
333 proxy_->GetProfile(), 330 gfx::Point(rect.CenterPoint().x(), rect.y()),
334 proxy_->GetWebContents(), 331 new SpellingBubbleModel(proxy_->GetProfile(),
335 true)); 332 proxy_->GetWebContents(),
333 true));
336 } else { 334 } else {
337 Profile* profile = proxy_->GetProfile(); 335 Profile* profile = proxy_->GetProfile();
338 if (profile) { 336 if (profile) {
339 bool current_value = autocorrect_spelling_.GetValue(); 337 bool current_value = autocorrect_spelling_.GetValue();
340 profile->GetPrefs()->SetBoolean(prefs::kEnableAutoSpellCorrect, 338 profile->GetPrefs()->SetBoolean(prefs::kEnableAutoSpellCorrect,
341 !current_value); 339 !current_value);
342 } 340 }
343 } 341 }
344 } 342 }
345 } 343 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 // Append '.' characters to the end of "Checking". 399 // Append '.' characters to the end of "Checking".
402 loading_frame_ = (loading_frame_ + 1) & 3; 400 loading_frame_ = (loading_frame_ + 1) & 3;
403 base::string16 loading_message = 401 base::string16 loading_message =
404 loading_message_ + base::string16(loading_frame_,'.'); 402 loading_message_ + base::string16(loading_frame_,'.');
405 403
406 // Update the menu item with the text. We disable this item to prevent users 404 // Update the menu item with the text. We disable this item to prevent users
407 // from selecting it. 405 // from selecting it.
408 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, 406 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false,
409 loading_message); 407 loading_message);
410 } 408 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/confirm_bubble_cocoa.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698