OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/render_view_context_menu.h" | 5 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/clipboard.h" | 8 #include "base/clipboard.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/scoped_clipboard_writer.h" | 11 #include "base/scoped_clipboard_writer.h" |
12 #include "chrome/app/chrome_dll_resource.h" | 12 #include "chrome/app/chrome_dll_resource.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/download/download_manager.h" | 14 #include "chrome/browser/download/download_manager.h" |
15 #include "chrome/browser/profile.h" | 15 #include "chrome/browser/profile.h" |
16 #include "chrome/browser/search_engines/template_url_model.h" | 16 #include "chrome/browser/search_engines/template_url_model.h" |
17 #include "chrome/browser/spellchecker.h" | 17 #include "chrome/browser/spellchecker.h" |
18 #include "chrome/browser/tab_contents/navigation_entry.h" | 18 #include "chrome/browser/tab_contents/navigation_entry.h" |
19 #include "chrome/browser/tab_contents/tab_contents.h" | 19 #include "chrome/browser/tab_contents/tab_contents.h" |
20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/platform_util.h" | 21 #include "chrome/common/platform_util.h" |
22 #include "chrome/common/pref_service.h" | 22 #include "chrome/common/pref_service.h" |
23 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 25 #include "net/base/net_util.h" |
25 | 26 |
26 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
27 #include "chrome/browser/views/options/fonts_languages_window_view.h" | 28 #include "chrome/browser/views/options/fonts_languages_window_view.h" |
28 #include "chrome/browser/views/page_info_window.h" | 29 #include "chrome/browser/views/page_info_window.h" |
29 #endif | 30 #endif |
30 | 31 |
31 RenderViewContextMenu::RenderViewContextMenu( | 32 RenderViewContextMenu::RenderViewContextMenu( |
32 TabContents* tab_contents, | 33 TabContents* tab_contents, |
33 const ContextMenuParams& params) | 34 const ContextMenuParams& params) |
34 : params_(params), | 35 : params_(params), |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 AppendSeparator(); | 201 AppendSeparator(); |
201 AppendMenuItem(IDS_CONTENT_CONTEXT_SELECTALL); | 202 AppendMenuItem(IDS_CONTENT_CONTEXT_SELECTALL); |
202 } | 203 } |
203 | 204 |
204 // Menu delegate functions ----------------------------------------------------- | 205 // Menu delegate functions ----------------------------------------------------- |
205 | 206 |
206 bool RenderViewContextMenu::IsItemCommandEnabled(int id) const { | 207 bool RenderViewContextMenu::IsItemCommandEnabled(int id) const { |
207 // Allow Spell Check language items on sub menu for text area context menu. | 208 // Allow Spell Check language items on sub menu for text area context menu. |
208 if ((id >= IDC_SPELLCHECK_LANGUAGES_FIRST) && | 209 if ((id >= IDC_SPELLCHECK_LANGUAGES_FIRST) && |
209 (id < IDC_SPELLCHECK_LANGUAGES_LAST)) { | 210 (id < IDC_SPELLCHECK_LANGUAGES_LAST)) { |
210 return source_tab_contents_->profile()->GetPrefs()->GetBoolean( | 211 return profile_->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck); |
211 prefs::kEnableSpellCheck); | |
212 } | 212 } |
213 | 213 |
214 switch (id) { | 214 switch (id) { |
215 case IDS_CONTENT_CONTEXT_BACK: | 215 case IDS_CONTENT_CONTEXT_BACK: |
216 return source_tab_contents_->controller().CanGoBack(); | 216 return source_tab_contents_->controller().CanGoBack(); |
217 | 217 |
218 case IDS_CONTENT_CONTEXT_FORWARD: | 218 case IDS_CONTENT_CONTEXT_FORWARD: |
219 return source_tab_contents_->controller().CanGoForward(); | 219 return source_tab_contents_->controller().CanGoForward(); |
220 | 220 |
221 case IDS_CONTENT_CONTEXT_VIEWPAGESOURCE: | 221 case IDS_CONTENT_CONTEXT_VIEWPAGESOURCE: |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 case IDS_CONTENT_CONTEXT_PASTE: | 275 case IDS_CONTENT_CONTEXT_PASTE: |
276 return !!(params_.edit_flags & ContextNode::CAN_PASTE); | 276 return !!(params_.edit_flags & ContextNode::CAN_PASTE); |
277 | 277 |
278 case IDS_CONTENT_CONTEXT_DELETE: | 278 case IDS_CONTENT_CONTEXT_DELETE: |
279 return !!(params_.edit_flags & ContextNode::CAN_DELETE); | 279 return !!(params_.edit_flags & ContextNode::CAN_DELETE); |
280 | 280 |
281 case IDS_CONTENT_CONTEXT_SELECTALL: | 281 case IDS_CONTENT_CONTEXT_SELECTALL: |
282 return !!(params_.edit_flags & ContextNode::CAN_SELECT_ALL); | 282 return !!(params_.edit_flags & ContextNode::CAN_SELECT_ALL); |
283 | 283 |
284 case IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: | 284 case IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: |
285 return !source_tab_contents_->profile()->IsOffTheRecord() && | 285 return !profile_->IsOffTheRecord() && params_.link_url.is_valid(); |
286 params_.link_url.is_valid(); | |
287 | 286 |
288 case IDS_CONTENT_CONTEXT_OPENFRAMEOFFTHERECORD: | 287 case IDS_CONTENT_CONTEXT_OPENFRAMEOFFTHERECORD: |
289 return !source_tab_contents_->profile()->IsOffTheRecord() && | 288 return !profile_->IsOffTheRecord() && params_.frame_url.is_valid(); |
290 params_.frame_url.is_valid(); | |
291 | 289 |
292 case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY: | 290 case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY: |
293 return !params_.misspelled_word.empty(); | 291 return !params_.misspelled_word.empty(); |
294 | 292 |
295 case IDS_CONTENT_CONTEXT_RELOAD: | 293 case IDS_CONTENT_CONTEXT_RELOAD: |
296 case IDS_CONTENT_CONTEXT_COPYIMAGE: | 294 case IDS_CONTENT_CONTEXT_COPYIMAGE: |
297 case IDS_CONTENT_CONTEXT_PRINT: | 295 case IDS_CONTENT_CONTEXT_PRINT: |
298 case IDS_CONTENT_CONTEXT_SEARCHWEBFOR: | 296 case IDS_CONTENT_CONTEXT_SEARCHWEBFOR: |
299 case IDC_SPELLCHECK_SUGGESTION_0: | 297 case IDC_SPELLCHECK_SUGGESTION_0: |
300 case IDC_SPELLCHECK_SUGGESTION_1: | 298 case IDC_SPELLCHECK_SUGGESTION_1: |
301 case IDC_SPELLCHECK_SUGGESTION_2: | 299 case IDC_SPELLCHECK_SUGGESTION_2: |
302 case IDC_SPELLCHECK_SUGGESTION_3: | 300 case IDC_SPELLCHECK_SUGGESTION_3: |
303 case IDC_SPELLCHECK_SUGGESTION_4: | 301 case IDC_SPELLCHECK_SUGGESTION_4: |
304 case IDC_SPELLCHECK_MENU: | 302 case IDC_SPELLCHECK_MENU: |
305 case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS: | 303 case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS: |
306 case IDS_CONTENT_CONTEXT_VIEWFRAMEINFO: | 304 case IDS_CONTENT_CONTEXT_VIEWFRAMEINFO: |
307 return true; | 305 return true; |
308 | 306 |
309 case IDC_CHECK_SPELLING_OF_THIS_FIELD: | 307 case IDC_CHECK_SPELLING_OF_THIS_FIELD: |
310 return source_tab_contents_->profile()->GetPrefs()->GetBoolean( | 308 return profile_->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck); |
311 prefs::kEnableSpellCheck); | |
312 | 309 |
313 case IDS_CONTENT_CONTEXT_SAVEFRAMEAS: | 310 case IDS_CONTENT_CONTEXT_SAVEFRAMEAS: |
314 case IDS_CONTENT_CONTEXT_PRINTFRAME: | 311 case IDS_CONTENT_CONTEXT_PRINTFRAME: |
315 case IDS_CONTENT_CONTEXT_ADDSEARCHENGINE: // Not implemented. | 312 case IDS_CONTENT_CONTEXT_ADDSEARCHENGINE: // Not implemented. |
316 default: | 313 default: |
317 return false; | 314 return false; |
318 } | 315 } |
319 } | 316 } |
320 | 317 |
321 bool RenderViewContextMenu::ItemIsChecked(int id) const { | 318 bool RenderViewContextMenu::ItemIsChecked(int id) const { |
322 // Check box for 'Check the Spelling of this field'. | 319 // Check box for 'Check the Spelling of this field'. |
323 if (id == IDC_CHECK_SPELLING_OF_THIS_FIELD) { | 320 if (id == IDC_CHECK_SPELLING_OF_THIS_FIELD) { |
324 PrefService* prefs = source_tab_contents_->profile()->GetPrefs(); | |
325 return (params_.spellcheck_enabled && | 321 return (params_.spellcheck_enabled && |
326 prefs->GetBoolean(prefs::kEnableSpellCheck)); | 322 profile_->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck)); |
327 } | 323 } |
328 | 324 |
329 // Don't bother getting the display language vector if this isn't a spellcheck | 325 // Don't bother getting the display language vector if this isn't a spellcheck |
330 // language. | 326 // language. |
331 if ((id < IDC_SPELLCHECK_LANGUAGES_FIRST) || | 327 if ((id < IDC_SPELLCHECK_LANGUAGES_FIRST) || |
332 (id >= IDC_SPELLCHECK_LANGUAGES_LAST)) | 328 (id >= IDC_SPELLCHECK_LANGUAGES_LAST)) |
333 return false; | 329 return false; |
334 | 330 |
335 SpellChecker::Languages languages; | 331 SpellChecker::Languages languages; |
336 return SpellChecker::GetSpellCheckLanguages( | 332 return SpellChecker::GetSpellCheckLanguages(profile_, &languages) == |
337 source_tab_contents_->profile(), &languages) == | |
338 (id - IDC_SPELLCHECK_LANGUAGES_FIRST); | 333 (id - IDC_SPELLCHECK_LANGUAGES_FIRST); |
339 } | 334 } |
340 | 335 |
341 void RenderViewContextMenu::ExecuteItemCommand(int id) { | 336 void RenderViewContextMenu::ExecuteItemCommand(int id) { |
342 // Check to see if one of the spell check language ids have been clicked. | 337 // Check to see if one of the spell check language ids have been clicked. |
343 if (id >= IDC_SPELLCHECK_LANGUAGES_FIRST && | 338 if (id >= IDC_SPELLCHECK_LANGUAGES_FIRST && |
344 id < IDC_SPELLCHECK_LANGUAGES_LAST) { | 339 id < IDC_SPELLCHECK_LANGUAGES_LAST) { |
345 const size_t language_number = id - IDC_SPELLCHECK_LANGUAGES_FIRST; | 340 const size_t language_number = id - IDC_SPELLCHECK_LANGUAGES_FIRST; |
346 SpellChecker::Languages languages; | 341 SpellChecker::Languages languages; |
347 SpellChecker::GetSpellCheckLanguages( | 342 SpellChecker::GetSpellCheckLanguages(profile_, &languages); |
348 source_tab_contents_->profile(), &languages); | |
349 if (language_number < languages.size()) { | 343 if (language_number < languages.size()) { |
350 StringPrefMember dictionary_language; | 344 StringPrefMember dictionary_language; |
351 dictionary_language.Init(prefs::kSpellCheckDictionary, | 345 dictionary_language.Init(prefs::kSpellCheckDictionary, |
352 source_tab_contents_->profile()->GetPrefs(), NULL); | 346 profile_->GetPrefs(), NULL); |
353 dictionary_language.SetValue(ASCIIToWide(languages[language_number])); | 347 dictionary_language.SetValue(ASCIIToWide(languages[language_number])); |
354 } | 348 } |
355 | 349 |
356 return; | 350 return; |
357 } | 351 } |
358 | 352 |
359 switch (id) { | 353 switch (id) { |
360 case IDS_CONTENT_CONTEXT_OPENLINKNEWTAB: | 354 case IDS_CONTENT_CONTEXT_OPENLINKNEWTAB: |
361 OpenURL(params_.link_url, NEW_BACKGROUND_TAB, PageTransition::LINK); | 355 OpenURL(params_.link_url, NEW_BACKGROUND_TAB, PageTransition::LINK); |
362 break; | 356 break; |
363 | 357 |
364 case IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW: | 358 case IDS_CONTENT_CONTEXT_OPENLINKNEWWINDOW: |
365 OpenURL(params_.link_url, NEW_WINDOW, PageTransition::LINK); | 359 OpenURL(params_.link_url, NEW_WINDOW, PageTransition::LINK); |
366 break; | 360 break; |
367 | 361 |
368 case IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: | 362 case IDS_CONTENT_CONTEXT_OPENLINKOFFTHERECORD: |
369 OpenURL(params_.link_url, OFF_THE_RECORD, PageTransition::LINK); | 363 OpenURL(params_.link_url, OFF_THE_RECORD, PageTransition::LINK); |
370 break; | 364 break; |
371 | 365 |
372 // TODO(paulg): Prompt the user for file name when saving links and images. | 366 // TODO(paulg): Prompt the user for file name when saving links and images. |
373 case IDS_CONTENT_CONTEXT_SAVEIMAGEAS: | 367 case IDS_CONTENT_CONTEXT_SAVEIMAGEAS: |
374 case IDS_CONTENT_CONTEXT_SAVELINKAS: { | 368 case IDS_CONTENT_CONTEXT_SAVELINKAS: { |
375 const GURL& referrer = | 369 const GURL& referrer = |
376 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; | 370 params_.frame_url.is_empty() ? params_.page_url : params_.frame_url; |
377 const GURL& url = | 371 const GURL& url = |
378 (id == IDS_CONTENT_CONTEXT_SAVELINKAS ? params_.link_url : | 372 (id == IDS_CONTENT_CONTEXT_SAVELINKAS ? params_.link_url : |
379 params_.image_url); | 373 params_.image_url); |
380 DownloadManager* dlm = | 374 DownloadManager* dlm = profile_->GetDownloadManager(); |
381 source_tab_contents_->profile()->GetDownloadManager(); | |
382 dlm->DownloadUrl(url, referrer, params_.frame_charset, | 375 dlm->DownloadUrl(url, referrer, params_.frame_charset, |
383 source_tab_contents_); | 376 source_tab_contents_); |
384 break; | 377 break; |
385 } | 378 } |
386 | 379 |
387 case IDS_CONTENT_CONTEXT_COPYLINKLOCATION: | 380 case IDS_CONTENT_CONTEXT_COPYLINKLOCATION: |
388 WriteURLToClipboard(params_.unfiltered_link_url); | 381 WriteURLToClipboard(params_.unfiltered_link_url); |
389 break; | 382 break; |
390 | 383 |
391 case IDS_CONTENT_CONTEXT_COPYIMAGELOCATION: | 384 case IDS_CONTENT_CONTEXT_COPYIMAGELOCATION: |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 | 420 |
428 case IDS_CONTENT_CONTEXT_INSPECTELEMENT: | 421 case IDS_CONTENT_CONTEXT_INSPECTELEMENT: |
429 Inspect(params_.x, params_.y); | 422 Inspect(params_.x, params_.y); |
430 break; | 423 break; |
431 | 424 |
432 case IDS_CONTENT_CONTEXT_VIEWPAGEINFO: { | 425 case IDS_CONTENT_CONTEXT_VIEWPAGEINFO: { |
433 #if defined(OS_WIN) | 426 #if defined(OS_WIN) |
434 NavigationEntry* nav_entry = | 427 NavigationEntry* nav_entry = |
435 source_tab_contents_->controller().GetActiveEntry(); | 428 source_tab_contents_->controller().GetActiveEntry(); |
436 PageInfoWindow::CreatePageInfo( | 429 PageInfoWindow::CreatePageInfo( |
437 source_tab_contents_->profile(), | 430 profile_, |
438 nav_entry, | 431 nav_entry, |
439 source_tab_contents_->GetContentNativeView(), | 432 source_tab_contents_->GetContentNativeView(), |
440 PageInfoWindow::SECURITY); | 433 PageInfoWindow::SECURITY); |
441 #else | 434 #else |
442 // TODO(port): port PageInfoWindow. | 435 // TODO(port): port PageInfoWindow. |
443 NOTIMPLEMENTED() << "IDS_CONTENT_CONTEXT_VIEWPAGEINFO"; | 436 NOTIMPLEMENTED() << "IDS_CONTENT_CONTEXT_VIEWPAGEINFO"; |
444 #endif | 437 #endif |
445 break; | 438 break; |
446 } | 439 } |
447 | 440 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 SSLManager::DeserializeSecurityInfo(params_.security_info, | 473 SSLManager::DeserializeSecurityInfo(params_.security_info, |
481 &cert_id, | 474 &cert_id, |
482 &cert_status, | 475 &cert_status, |
483 &security_bits); | 476 &security_bits); |
484 ssl.set_cert_id(cert_id); | 477 ssl.set_cert_id(cert_id); |
485 ssl.set_cert_status(cert_status); | 478 ssl.set_cert_status(cert_status); |
486 ssl.set_security_bits(security_bits); | 479 ssl.set_security_bits(security_bits); |
487 } | 480 } |
488 #if defined(OS_WIN) | 481 #if defined(OS_WIN) |
489 PageInfoWindow::CreateFrameInfo( | 482 PageInfoWindow::CreateFrameInfo( |
490 source_tab_contents_->profile(), | 483 profile_, |
491 params_.frame_url, | 484 params_.frame_url, |
492 ssl, | 485 ssl, |
493 source_tab_contents_->GetContentNativeView(), | 486 source_tab_contents_->GetContentNativeView(), |
494 PageInfoWindow::SECURITY); | 487 PageInfoWindow::SECURITY); |
495 #else | 488 #else |
496 // TODO(port): port PageInfoWindow. | 489 // TODO(port): port PageInfoWindow. |
497 NOTIMPLEMENTED() << "IDS_CONTENT_CONTEXT_VIEWFRAMEINFO"; | 490 NOTIMPLEMENTED() << "IDS_CONTENT_CONTEXT_VIEWFRAMEINFO"; |
498 #endif | 491 #endif |
499 break; | 492 break; |
500 } | 493 } |
(...skipping 20 matching lines...) Expand all Loading... |
521 | 514 |
522 case IDS_CONTENT_CONTEXT_DELETE: | 515 case IDS_CONTENT_CONTEXT_DELETE: |
523 source_tab_contents_->render_view_host()->Delete(); | 516 source_tab_contents_->render_view_host()->Delete(); |
524 break; | 517 break; |
525 | 518 |
526 case IDS_CONTENT_CONTEXT_SELECTALL: | 519 case IDS_CONTENT_CONTEXT_SELECTALL: |
527 source_tab_contents_->render_view_host()->SelectAll(); | 520 source_tab_contents_->render_view_host()->SelectAll(); |
528 break; | 521 break; |
529 | 522 |
530 case IDS_CONTENT_CONTEXT_SEARCHWEBFOR: { | 523 case IDS_CONTENT_CONTEXT_SEARCHWEBFOR: { |
531 const TemplateURL* const default_provider = source_tab_contents_-> | 524 const TemplateURL* const default_provider = |
532 profile()->GetTemplateURLModel()->GetDefaultSearchProvider(); | 525 profile_->GetTemplateURLModel()->GetDefaultSearchProvider(); |
533 DCHECK(default_provider); // The context menu should not contain this | 526 DCHECK(default_provider); // The context menu should not contain this |
534 // item when there is no provider. | 527 // item when there is no provider. |
535 const TemplateURLRef* const search_url = default_provider->url(); | 528 const TemplateURLRef* const search_url = default_provider->url(); |
536 DCHECK(search_url->SupportsReplacement()); | 529 DCHECK(search_url->SupportsReplacement()); |
537 OpenURL(GURL(search_url->ReplaceSearchTerms(*default_provider, | 530 OpenURL(GURL(search_url->ReplaceSearchTerms(*default_provider, |
538 params_.selection_text, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, | 531 params_.selection_text, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, |
539 std::wstring())), NEW_FOREGROUND_TAB, PageTransition::GENERATED); | 532 std::wstring())), NEW_FOREGROUND_TAB, PageTransition::GENERATED); |
540 break; | 533 break; |
541 } | 534 } |
542 | 535 |
(...skipping 12 matching lines...) Expand all Loading... |
555 case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY: | 548 case IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY: |
556 source_tab_contents_->render_view_host()->AddToDictionary( | 549 source_tab_contents_->render_view_host()->AddToDictionary( |
557 params_.misspelled_word); | 550 params_.misspelled_word); |
558 break; | 551 break; |
559 | 552 |
560 case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS: { | 553 case IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS: { |
561 #if defined(OS_WIN) | 554 #if defined(OS_WIN) |
562 // TODO(yusukes): This should be moved to some shared place of commands | 555 // TODO(yusukes): This should be moved to some shared place of commands |
563 // for the options stuff so that we don't have to do all this work here. | 556 // for the options stuff so that we don't have to do all this work here. |
564 FontsLanguagesWindowView* window_ = new FontsLanguagesWindowView( | 557 FontsLanguagesWindowView* window_ = new FontsLanguagesWindowView( |
565 source_tab_contents_->profile()); | 558 profile_); |
566 views::Window::CreateChromeWindow( | 559 views::Window::CreateChromeWindow( |
567 platform_util::GetTopLevel( | 560 platform_util::GetTopLevel( |
568 source_tab_contents_->GetContentNativeView()), | 561 source_tab_contents_->GetContentNativeView()), |
569 gfx::Rect(), window_)->Show(); | 562 gfx::Rect(), window_)->Show(); |
570 window_->SelectLanguagesTab(); | 563 window_->SelectLanguagesTab(); |
571 #else | 564 #else |
572 // TODO(port): need views::Window | 565 // TODO(port): need views::Window |
573 NOTIMPLEMENTED() << "IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS"; | 566 NOTIMPLEMENTED() << "IDS_CONTENT_CONTEXT_LANGUAGE_SETTINGS"; |
574 #endif | 567 #endif |
575 break; | 568 break; |
(...skipping 29 matching lines...) Expand all Loading... |
605 | 598 |
606 // Don't inspect about:network, about:memory, etc. | 599 // Don't inspect about:network, about:memory, etc. |
607 // However, we do want to inspect about:blank, which is often | 600 // However, we do want to inspect about:blank, which is often |
608 // used by ordinary web pages. | 601 // used by ordinary web pages. |
609 if (active_entry->display_url().SchemeIs(chrome::kAboutScheme) && | 602 if (active_entry->display_url().SchemeIs(chrome::kAboutScheme) && |
610 !LowerCaseEqualsASCII(active_entry->display_url().path(), "blank")) | 603 !LowerCaseEqualsASCII(active_entry->display_url().path(), "blank")) |
611 return false; | 604 return false; |
612 | 605 |
613 // Don't enable the web inspector if JavaScript is disabled | 606 // Don't enable the web inspector if JavaScript is disabled |
614 if (id == IDS_CONTENT_CONTEXT_INSPECTELEMENT) { | 607 if (id == IDS_CONTENT_CONTEXT_INSPECTELEMENT) { |
615 PrefService* prefs = source_tab_contents_->profile()->GetPrefs(); | 608 if (!profile_->GetPrefs()->GetBoolean(prefs::kWebKitJavascriptEnabled) || |
616 if (!prefs->GetBoolean(prefs::kWebKitJavascriptEnabled) || | |
617 command_line.HasSwitch(switches::kDisableJavaScript)) | 609 command_line.HasSwitch(switches::kDisableJavaScript)) |
618 return false; | 610 return false; |
619 } | 611 } |
620 | 612 |
621 return true; | 613 return true; |
622 } | 614 } |
623 | 615 |
624 // Controller functions -------------------------------------------------------- | 616 // Controller functions -------------------------------------------------------- |
625 | 617 |
626 void RenderViewContextMenu::OpenURL( | 618 void RenderViewContextMenu::OpenURL( |
(...skipping 16 matching lines...) Expand all Loading... |
643 Clipboard* clipboard = g_browser_process->clipboard(); | 635 Clipboard* clipboard = g_browser_process->clipboard(); |
644 | 636 |
645 if (!clipboard) | 637 if (!clipboard) |
646 return; | 638 return; |
647 | 639 |
648 ScopedClipboardWriter scw(clipboard); | 640 ScopedClipboardWriter scw(clipboard); |
649 scw.WriteText(text); | 641 scw.WriteText(text); |
650 } | 642 } |
651 | 643 |
652 void RenderViewContextMenu::WriteURLToClipboard(const GURL& url) { | 644 void RenderViewContextMenu::WriteURLToClipboard(const GURL& url) { |
653 if (url.SchemeIs(chrome::kMailToScheme)) | 645 if (url.SchemeIs(chrome::kMailToScheme)) { |
654 WriteTextToClipboard(UTF8ToUTF16(url.path())); | 646 WriteTextToClipboard(UTF8ToUTF16(url.path())); |
655 else | 647 } else { |
656 WriteTextToClipboard(UTF8ToUTF16(url.spec())); | 648 std::wstring languages = |
| 649 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); |
| 650 // Unescaping path and query is not a good idea because other |
| 651 // applications may not enocode non-ASCII characters in UTF-8. |
| 652 // So the 4th parameter of net::FormatUrl() should be false. |
| 653 // See crbug.com/2820. |
| 654 WriteTextToClipboard(WideToUTF16( |
| 655 net::FormatUrl(url, languages, false, false, NULL, NULL))); |
| 656 } |
657 } | 657 } |
OLD | NEW |