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

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

Issue 801043003: Change ShowConfirmBubble() to take model by scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« 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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 // The spelling service can be toggled by the user only if it is not managed. 296 // The spelling service can be toggled by the user only if it is not managed.
297 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_TOGGLE && 297 if (command_id == IDC_CONTENT_CONTEXT_SPELLING_TOGGLE &&
298 integrate_spelling_service_.IsUserModifiable()) { 298 integrate_spelling_service_.IsUserModifiable()) {
299 // When a user enables the "Ask Google for spelling suggestions" item, we 299 // When a user enables the "Ask Google for spelling suggestions" item, we
300 // show a bubble to confirm it. On the other hand, when a user disables this 300 // show a bubble to confirm it. On the other hand, when a user disables this
301 // item, we directly update/ the profile and stop integrating the spelling 301 // item, we directly update/ the profile and stop integrating the spelling
302 // service immediately. 302 // service immediately.
303 if (!integrate_spelling_service_.GetValue()) { 303 if (!integrate_spelling_service_.GetValue()) {
304 content::RenderViewHost* rvh = proxy_->GetRenderViewHost(); 304 content::RenderViewHost* rvh = proxy_->GetRenderViewHost();
305 gfx::Rect rect = rvh->GetView()->GetViewBounds(); 305 gfx::Rect rect = rvh->GetView()->GetViewBounds();
306 scoped_ptr<SpellingBubbleModel> model(
307 new SpellingBubbleModel(profile, proxy_->GetWebContents(), false));
306 chrome::ShowConfirmBubble( 308 chrome::ShowConfirmBubble(
307 proxy_->GetWebContents()->GetTopLevelNativeWindow(), 309 proxy_->GetWebContents()->GetTopLevelNativeWindow(),
308 rvh->GetView()->GetNativeView(), 310 rvh->GetView()->GetNativeView(),
309 gfx::Point(rect.CenterPoint().x(), rect.y()), 311 gfx::Point(rect.CenterPoint().x(), rect.y()),
310 new SpellingBubbleModel(profile, proxy_->GetWebContents(), false)); 312 model.Pass());
311 } else { 313 } else {
312 if (profile) { 314 if (profile) {
313 profile->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService, 315 profile->GetPrefs()->SetBoolean(prefs::kSpellCheckUseSpellingService,
314 false); 316 false);
315 profile->GetPrefs()->SetBoolean(prefs::kEnableAutoSpellCorrect, 317 profile->GetPrefs()->SetBoolean(prefs::kEnableAutoSpellCorrect,
316 false); 318 false);
317 } 319 }
318 } 320 }
319 } 321 }
320 // Autocorrect requires use of the spelling service and the spelling service 322 // Autocorrect requires use of the spelling service and the spelling service
321 // can be toggled by the user only if it is not managed. 323 // can be toggled by the user only if it is not managed.
322 if (command_id == IDC_CONTENT_CONTEXT_AUTOCORRECT_SPELLING_TOGGLE && 324 if (command_id == IDC_CONTENT_CONTEXT_AUTOCORRECT_SPELLING_TOGGLE &&
323 integrate_spelling_service_.IsUserModifiable()) { 325 integrate_spelling_service_.IsUserModifiable()) {
324 // When the user enables autocorrect, we'll need to make sure that we can 326 // 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 327 // ask Google for suggestions since that service is required. So we show
326 // the bubble and just make sure to enable autocorrect as well. 328 // the bubble and just make sure to enable autocorrect as well.
327 if (!integrate_spelling_service_.GetValue()) { 329 if (!integrate_spelling_service_.GetValue()) {
328 content::RenderViewHost* rvh = proxy_->GetRenderViewHost(); 330 content::RenderViewHost* rvh = proxy_->GetRenderViewHost();
329 gfx::Rect rect = rvh->GetView()->GetViewBounds(); 331 gfx::Rect rect = rvh->GetView()->GetViewBounds();
332 scoped_ptr<SpellingBubbleModel> model(
333 new SpellingBubbleModel(profile, proxy_->GetWebContents(), true));
330 chrome::ShowConfirmBubble( 334 chrome::ShowConfirmBubble(
331 proxy_->GetWebContents()->GetTopLevelNativeWindow(), 335 proxy_->GetWebContents()->GetTopLevelNativeWindow(),
332 rvh->GetView()->GetNativeView(), 336 rvh->GetView()->GetNativeView(),
333 gfx::Point(rect.CenterPoint().x(), rect.y()), 337 gfx::Point(rect.CenterPoint().x(), rect.y()),
334 new SpellingBubbleModel(profile, proxy_->GetWebContents(), true)); 338 model.Pass());
335 } else { 339 } else {
336 if (profile) { 340 if (profile) {
337 bool current_value = autocorrect_spelling_.GetValue(); 341 bool current_value = autocorrect_spelling_.GetValue();
338 profile->GetPrefs()->SetBoolean(prefs::kEnableAutoSpellCorrect, 342 profile->GetPrefs()->SetBoolean(prefs::kEnableAutoSpellCorrect,
339 !current_value); 343 !current_value);
340 } 344 }
341 } 345 }
342 } 346 }
343 } 347 }
344 348
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 // Append '.' characters to the end of "Checking". 403 // Append '.' characters to the end of "Checking".
400 loading_frame_ = (loading_frame_ + 1) & 3; 404 loading_frame_ = (loading_frame_ + 1) & 3;
401 base::string16 loading_message = 405 base::string16 loading_message =
402 loading_message_ + base::string16(loading_frame_,'.'); 406 loading_message_ + base::string16(loading_frame_,'.');
403 407
404 // Update the menu item with the text. We disable this item to prevent users 408 // Update the menu item with the text. We disable this item to prevent users
405 // from selecting it. 409 // from selecting it.
406 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, 410 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false,
407 loading_message); 411 loading_message);
408 } 412 }
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