OLD | NEW |
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/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 2486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2497 // them. Once they have fired, we'll get a message back saying whether | 2497 // them. Once they have fired, we'll get a message back saying whether |
2498 // to proceed closing the page or not, which sends us back to this method | 2498 // to proceed closing the page or not, which sends us back to this method |
2499 // with the NeedToFireBeforeUnload bit cleared. | 2499 // with the NeedToFireBeforeUnload bit cleared. |
2500 contents->GetRenderViewHost()->FirePageBeforeUnload(false); | 2500 contents->GetRenderViewHost()->FirePageBeforeUnload(false); |
2501 return true; | 2501 return true; |
2502 } | 2502 } |
2503 return false; | 2503 return false; |
2504 } | 2504 } |
2505 | 2505 |
2506 // static | 2506 // static |
2507 void Browser::RunFileChooserHelper( | |
2508 WebContents* tab, const content::FileChooserParams& params) { | |
2509 Profile* profile = | |
2510 Profile::FromBrowserContext(tab->GetBrowserContext()); | |
2511 // FileSelectHelper adds a reference to itself and only releases it after | |
2512 // sending the result message. It won't be destroyed when this reference | |
2513 // goes out of scope. | |
2514 scoped_refptr<FileSelectHelper> file_select_helper( | |
2515 new FileSelectHelper(profile)); | |
2516 file_select_helper->RunFileChooser(tab->GetRenderViewHost(), tab, params); | |
2517 } | |
2518 | |
2519 // static | |
2520 void Browser::EnumerateDirectoryHelper(WebContents* tab, int request_id, | |
2521 const FilePath& path) { | |
2522 Profile* profile = | |
2523 Profile::FromBrowserContext(tab->GetBrowserContext()); | |
2524 // FileSelectHelper adds a reference to itself and only releases it after | |
2525 // sending the result message. It won't be destroyed when this reference | |
2526 // goes out of scope. | |
2527 scoped_refptr<FileSelectHelper> file_select_helper( | |
2528 new FileSelectHelper(profile)); | |
2529 file_select_helper->EnumerateDirectory(request_id, | |
2530 tab->GetRenderViewHost(), | |
2531 path); | |
2532 } | |
2533 | |
2534 // static | |
2535 void Browser::JSOutOfMemoryHelper(WebContents* tab) { | 2507 void Browser::JSOutOfMemoryHelper(WebContents* tab) { |
2536 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( | 2508 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( |
2537 tab); | 2509 tab); |
2538 if (!tcw) | 2510 if (!tcw) |
2539 return; | 2511 return; |
2540 | 2512 |
2541 InfoBarTabHelper* infobar_helper = tcw->infobar_tab_helper(); | 2513 InfoBarTabHelper* infobar_helper = tcw->infobar_tab_helper(); |
2542 infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( | 2514 infobar_helper->AddInfoBar(new SimpleAlertInfoBarDelegate( |
2543 infobar_helper, | 2515 infobar_helper, |
2544 NULL, | 2516 NULL, |
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3882 #endif | 3854 #endif |
3883 return color_chooser_.get(); | 3855 return color_chooser_.get(); |
3884 } | 3856 } |
3885 | 3857 |
3886 void Browser::DidEndColorChooser() { | 3858 void Browser::DidEndColorChooser() { |
3887 color_chooser_.reset(); | 3859 color_chooser_.reset(); |
3888 } | 3860 } |
3889 | 3861 |
3890 void Browser::RunFileChooser(WebContents* tab, | 3862 void Browser::RunFileChooser(WebContents* tab, |
3891 const content::FileChooserParams& params) { | 3863 const content::FileChooserParams& params) { |
3892 RunFileChooserHelper(tab, params); | 3864 FileSelectHelper::RunFileChooser(tab, params); |
3893 } | 3865 } |
3894 | 3866 |
3895 void Browser::EnumerateDirectory(WebContents* tab, int request_id, | 3867 void Browser::EnumerateDirectory(WebContents* tab, |
| 3868 int request_id, |
3896 const FilePath& path) { | 3869 const FilePath& path) { |
3897 EnumerateDirectoryHelper(tab, request_id, path); | 3870 FileSelectHelper::EnumerateDirectory(tab, request_id, path); |
3898 } | 3871 } |
3899 | 3872 |
3900 void Browser::ToggleFullscreenModeForTab(WebContents* tab, | 3873 void Browser::ToggleFullscreenModeForTab(WebContents* tab, |
3901 bool enter_fullscreen) { | 3874 bool enter_fullscreen) { |
3902 fullscreen_controller_->ToggleFullscreenModeForTab(tab, enter_fullscreen); | 3875 fullscreen_controller_->ToggleFullscreenModeForTab(tab, enter_fullscreen); |
3903 } | 3876 } |
3904 | 3877 |
3905 bool Browser::IsFullscreenForTabOrPending(const WebContents* tab) const { | 3878 bool Browser::IsFullscreenForTabOrPending(const WebContents* tab) const { |
3906 return fullscreen_controller_->IsFullscreenForTabOrPending(tab); | 3879 return fullscreen_controller_->IsFullscreenForTabOrPending(tab); |
3907 } | 3880 } |
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5425 if (contents && !allow_js_access) { | 5398 if (contents && !allow_js_access) { |
5426 contents->web_contents()->GetController().LoadURL( | 5399 contents->web_contents()->GetController().LoadURL( |
5427 target_url, | 5400 target_url, |
5428 content::Referrer(), | 5401 content::Referrer(), |
5429 content::PAGE_TRANSITION_LINK, | 5402 content::PAGE_TRANSITION_LINK, |
5430 std::string()); // No extra headers. | 5403 std::string()); // No extra headers. |
5431 } | 5404 } |
5432 | 5405 |
5433 return contents != NULL; | 5406 return contents != NULL; |
5434 } | 5407 } |
OLD | NEW |