OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <shellapi.h> | 8 #include <shellapi.h> |
9 #include <windows.h> | 9 #include <windows.h> |
10 #endif // OS_WIN | 10 #endif // OS_WIN |
(...skipping 3281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3292 } | 3292 } |
3293 | 3293 |
3294 void Browser::RenderWidgetShowing() { | 3294 void Browser::RenderWidgetShowing() { |
3295 window_->DisableInactiveFrame(); | 3295 window_->DisableInactiveFrame(); |
3296 } | 3296 } |
3297 | 3297 |
3298 int Browser::GetExtraRenderViewHeight() const { | 3298 int Browser::GetExtraRenderViewHeight() const { |
3299 return window_->GetExtraRenderViewHeight(); | 3299 return window_->GetExtraRenderViewHeight(); |
3300 } | 3300 } |
3301 | 3301 |
| 3302 void Browser::OnStartDownload(DownloadItem* download, TabContents* tab) { |
| 3303 if (!window()) |
| 3304 return; |
| 3305 |
| 3306 #if defined(OS_CHROMEOS) |
| 3307 // Don't show content browser for extension/theme downloads from gallery. |
| 3308 if (download->is_extension_install()) { |
| 3309 ExtensionService* service = profile_->GetExtensionService(); |
| 3310 if (service && service->IsDownloadFromGallery(download->url(), |
| 3311 download->referrer_url())) { |
| 3312 return; |
| 3313 } |
| 3314 } |
| 3315 // Open the Active Downloads ui for chromeos. |
| 3316 ActiveDownloadsUI::OpenPopup(profile_); |
| 3317 #else |
| 3318 // GetDownloadShelf creates the download shelf if it was not yet created. |
| 3319 window()->GetDownloadShelf()->AddDownload(new DownloadItemModel(download)); |
| 3320 |
| 3321 // Don't show the animation for "Save file" downloads. |
| 3322 if (download->total_bytes() <= 0) |
| 3323 return; |
| 3324 |
| 3325 // For non-theme extensions, we don't show the download animation. |
| 3326 if (download->is_extension_install() && |
| 3327 !ExtensionService::IsDownloadFromMiniGallery(download->url())) |
| 3328 return; |
| 3329 |
| 3330 TabContents* current_tab = GetSelectedTabContents(); |
| 3331 // We make this check for the case of minimized windows, unit tests, etc. |
| 3332 if (platform_util::IsVisible(current_tab->GetNativeView()) && |
| 3333 ui::Animation::ShouldRenderRichAnimation()) { |
| 3334 DownloadStartedAnimation::Show(current_tab); |
| 3335 } |
| 3336 #endif |
| 3337 |
| 3338 // If the download occurs in a new tab, close it. |
| 3339 TabContentsWrapper* wrapper = |
| 3340 TabContentsWrapper::GetCurrentWrapperForContents(tab); |
| 3341 if (tab->controller().IsInitialNavigation() && |
| 3342 GetConstrainingContentsWrapper(wrapper) == wrapper && tab_count() > 1) { |
| 3343 CloseContents(tab); |
| 3344 } |
| 3345 } |
| 3346 |
3302 void Browser::ShowPageInfo(Profile* profile, | 3347 void Browser::ShowPageInfo(Profile* profile, |
3303 const GURL& url, | 3348 const GURL& url, |
3304 const NavigationEntry::SSLStatus& ssl, | 3349 const NavigationEntry::SSLStatus& ssl, |
3305 bool show_history) { | 3350 bool show_history) { |
3306 window()->ShowPageInfo(profile, url, ssl, show_history); | 3351 window()->ShowPageInfo(profile, url, ssl, show_history); |
3307 } | 3352 } |
3308 | 3353 |
3309 void Browser::ViewSourceForTab(TabContents* source, const GURL& page_url) { | 3354 void Browser::ViewSourceForTab(TabContents* source, const GURL& page_url) { |
3310 DCHECK(source); | 3355 DCHECK(source); |
3311 int index = tabstrip_model()->GetWrapperIndex(source); | 3356 int index = tabstrip_model()->GetWrapperIndex(source); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3431 | 3476 |
3432 /////////////////////////////////////////////////////////////////////////////// | 3477 /////////////////////////////////////////////////////////////////////////////// |
3433 // Browser, BookmarkTabHelperDelegate implementation: | 3478 // Browser, BookmarkTabHelperDelegate implementation: |
3434 | 3479 |
3435 void Browser::URLStarredChanged(TabContentsWrapper* source, bool starred) { | 3480 void Browser::URLStarredChanged(TabContentsWrapper* source, bool starred) { |
3436 if (source == GetSelectedTabContentsWrapper()) | 3481 if (source == GetSelectedTabContentsWrapper()) |
3437 window_->SetStarredState(starred); | 3482 window_->SetStarredState(starred); |
3438 } | 3483 } |
3439 | 3484 |
3440 /////////////////////////////////////////////////////////////////////////////// | 3485 /////////////////////////////////////////////////////////////////////////////// |
3441 // Browser, DownloadTabHelperDelegate implementation: | |
3442 | |
3443 bool Browser::CanDownload(int request_id) { | |
3444 return true; | |
3445 } | |
3446 | |
3447 void Browser::OnStartDownload(DownloadItem* download, TabContentsWrapper* tab) { | |
3448 if (!window()) | |
3449 return; | |
3450 | |
3451 #if defined(OS_CHROMEOS) | |
3452 // Don't show content browser for extension/theme downloads from gallery. | |
3453 if (download->is_extension_install()) { | |
3454 ExtensionService* service = profile_->GetExtensionService(); | |
3455 if (service && service->IsDownloadFromGallery(download->url(), | |
3456 download->referrer_url())) { | |
3457 return; | |
3458 } | |
3459 } | |
3460 // Open the Active Downloads ui for chromeos. | |
3461 ActiveDownloadsUI::OpenPopup(profile_); | |
3462 #else | |
3463 // GetDownloadShelf creates the download shelf if it was not yet created. | |
3464 window()->GetDownloadShelf()->AddDownload(new DownloadItemModel(download)); | |
3465 | |
3466 // Don't show the animation for "Save file" downloads. | |
3467 if (download->total_bytes() <= 0) | |
3468 return; | |
3469 | |
3470 // For non-theme extensions, we don't show the download animation. | |
3471 if (download->is_extension_install() && | |
3472 !ExtensionService::IsDownloadFromMiniGallery(download->url())) | |
3473 return; | |
3474 | |
3475 TabContents* current_tab = GetSelectedTabContents(); | |
3476 // We make this check for the case of minimized windows, unit tests, etc. | |
3477 if (platform_util::IsVisible(current_tab->GetNativeView()) && | |
3478 ui::Animation::ShouldRenderRichAnimation()) { | |
3479 DownloadStartedAnimation::Show(current_tab); | |
3480 } | |
3481 #endif | |
3482 | |
3483 // If the download occurs in a new tab, close it. | |
3484 if (tab->tab_contents()->controller().IsInitialNavigation() && | |
3485 GetConstrainingContentsWrapper(tab) == tab && tab_count() > 1) { | |
3486 CloseContents(tab->tab_contents()); | |
3487 } | |
3488 } | |
3489 | |
3490 /////////////////////////////////////////////////////////////////////////////// | |
3491 // Browser, SelectFileDialog::Listener implementation: | 3486 // Browser, SelectFileDialog::Listener implementation: |
3492 | 3487 |
3493 void Browser::FileSelected(const FilePath& path, int index, void* params) { | 3488 void Browser::FileSelected(const FilePath& path, int index, void* params) { |
3494 profile_->set_last_selected_directory(path.DirName()); | 3489 profile_->set_last_selected_directory(path.DirName()); |
3495 GURL file_url = net::FilePathToFileURL(path); | 3490 GURL file_url = net::FilePathToFileURL(path); |
3496 if (!file_url.is_empty()) | 3491 if (!file_url.is_empty()) |
3497 OpenURL(file_url, GURL(), CURRENT_TAB, PageTransition::TYPED); | 3492 OpenURL(file_url, GURL(), CURRENT_TAB, PageTransition::TYPED); |
3498 } | 3493 } |
3499 | 3494 |
3500 /////////////////////////////////////////////////////////////////////////////// | 3495 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4390 } | 4385 } |
4391 | 4386 |
4392 void Browser::SetAsDelegate(TabContentsWrapper* tab, Browser* delegate) { | 4387 void Browser::SetAsDelegate(TabContentsWrapper* tab, Browser* delegate) { |
4393 // TabContents... | 4388 // TabContents... |
4394 tab->tab_contents()->set_delegate(delegate); | 4389 tab->tab_contents()->set_delegate(delegate); |
4395 tab->set_delegate(delegate); | 4390 tab->set_delegate(delegate); |
4396 | 4391 |
4397 // ...and all the helpers. | 4392 // ...and all the helpers. |
4398 tab->blocked_content_tab_helper()->set_delegate(delegate); | 4393 tab->blocked_content_tab_helper()->set_delegate(delegate); |
4399 tab->bookmark_tab_helper()->set_delegate(delegate); | 4394 tab->bookmark_tab_helper()->set_delegate(delegate); |
4400 tab->download_tab_helper()->set_delegate(delegate); | |
4401 tab->search_engine_tab_helper()->set_delegate(delegate); | 4395 tab->search_engine_tab_helper()->set_delegate(delegate); |
4402 } | 4396 } |
4403 | 4397 |
4404 void Browser::FindInPage(bool find_next, bool forward_direction) { | 4398 void Browser::FindInPage(bool find_next, bool forward_direction) { |
4405 ShowFindBar(); | 4399 ShowFindBar(); |
4406 if (find_next) { | 4400 if (find_next) { |
4407 string16 find_text; | 4401 string16 find_text; |
4408 #if defined(OS_MACOSX) | 4402 #if defined(OS_MACOSX) |
4409 // We always want to search for the contents of the find pasteboard on OS X. | 4403 // We always want to search for the contents of the find pasteboard on OS X. |
4410 find_text = GetFindPboardText(); | 4404 find_text = GetFindPboardText(); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4614 TabContents* current_tab = GetSelectedTabContents(); | 4608 TabContents* current_tab = GetSelectedTabContents(); |
4615 if (current_tab) { | 4609 if (current_tab) { |
4616 content_restrictions = current_tab->content_restrictions(); | 4610 content_restrictions = current_tab->content_restrictions(); |
4617 NavigationEntry* active_entry = current_tab->controller().GetActiveEntry(); | 4611 NavigationEntry* active_entry = current_tab->controller().GetActiveEntry(); |
4618 // See comment in UpdateCommandsForTabState about why we call url(). | 4612 // See comment in UpdateCommandsForTabState about why we call url(). |
4619 if (!SavePackage::IsSavableURL(active_entry ? active_entry->url() : GURL())) | 4613 if (!SavePackage::IsSavableURL(active_entry ? active_entry->url() : GURL())) |
4620 content_restrictions |= CONTENT_RESTRICTION_SAVE; | 4614 content_restrictions |= CONTENT_RESTRICTION_SAVE; |
4621 } | 4615 } |
4622 return content_restrictions; | 4616 return content_restrictions; |
4623 } | 4617 } |
OLD | NEW |