| OLD | NEW | 
|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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  // defined(OS_WIN) | 10 #endif  // defined(OS_WIN) | 
| (...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1230   // Instant overlay state. | 1230   // Instant overlay state. | 
| 1231   // ModeChanged() updates bookmark bar state for all mode transitions except | 1231   // ModeChanged() updates bookmark bar state for all mode transitions except | 
| 1232   // when new mode is |SEARCH_SUGGESTIONS|, because that needs to be done when | 1232   // when new mode is |SEARCH_SUGGESTIONS|, because that needs to be done when | 
| 1233   // the suggestions are ready. | 1233   // the suggestions are ready. | 
| 1234   if (mode.is_search_suggestions() && | 1234   if (mode.is_search_suggestions() && | 
| 1235       bookmark_bar_state_ == BookmarkBar::SHOW) { | 1235       bookmark_bar_state_ == BookmarkBar::SHOW) { | 
| 1236     UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 1236     UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 
| 1237   } | 1237   } | 
| 1238 } | 1238 } | 
| 1239 | 1239 | 
|  | 1240 void Browser::ShowDownload(content::DownloadItem* download) { | 
|  | 1241   if (!window()) | 
|  | 1242     return; | 
|  | 1243 | 
|  | 1244   // If the download occurs in a new tab, and it's not a save page | 
|  | 1245   // download (started before initial navigation completed) close it. | 
|  | 1246   WebContents* source = download->GetWebContents(); | 
|  | 1247   if (source && source->GetController().IsInitialNavigation() && | 
|  | 1248       tab_strip_model_->count() > 1 && !download->IsSavePackageDownload()) { | 
|  | 1249     CloseContents(source); | 
|  | 1250   } | 
|  | 1251 | 
|  | 1252   // Some (app downloads) are not supposed to appear on the shelf. | 
|  | 1253   if (!DownloadItemModel(download).ShouldShowInShelf()) | 
|  | 1254     return; | 
|  | 1255 | 
|  | 1256   // GetDownloadShelf creates the download shelf if it was not yet created. | 
|  | 1257   DownloadShelf* shelf = window()->GetDownloadShelf(); | 
|  | 1258   shelf->AddDownload(download); | 
|  | 1259 } | 
|  | 1260 | 
| 1240 /////////////////////////////////////////////////////////////////////////////// | 1261 /////////////////////////////////////////////////////////////////////////////// | 
| 1241 // Browser, content::WebContentsDelegate implementation: | 1262 // Browser, content::WebContentsDelegate implementation: | 
| 1242 | 1263 | 
| 1243 WebContents* Browser::OpenURLFromTab(WebContents* source, | 1264 WebContents* Browser::OpenURLFromTab(WebContents* source, | 
| 1244                                      const OpenURLParams& params) { | 1265                                      const OpenURLParams& params) { | 
| 1245   chrome::NavigateParams nav_params(this, params.url, params.transition); | 1266   chrome::NavigateParams nav_params(this, params.url, params.transition); | 
| 1246   nav_params.source_contents = source; | 1267   nav_params.source_contents = source; | 
| 1247   nav_params.referrer = params.referrer; | 1268   nav_params.referrer = params.referrer; | 
| 1248   nav_params.extra_headers = params.extra_headers; | 1269   nav_params.extra_headers = params.extra_headers; | 
| 1249   nav_params.disposition = params.disposition; | 1270   nav_params.disposition = params.disposition; | 
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1395 } | 1416 } | 
| 1396 | 1417 | 
| 1397 void Browser::RenderWidgetShowing() { | 1418 void Browser::RenderWidgetShowing() { | 
| 1398   window_->DisableInactiveFrame(); | 1419   window_->DisableInactiveFrame(); | 
| 1399 } | 1420 } | 
| 1400 | 1421 | 
| 1401 int Browser::GetExtraRenderViewHeight() const { | 1422 int Browser::GetExtraRenderViewHeight() const { | 
| 1402   return window_->GetExtraRenderViewHeight(); | 1423   return window_->GetExtraRenderViewHeight(); | 
| 1403 } | 1424 } | 
| 1404 | 1425 | 
| 1405 void Browser::OnStartDownload(WebContents* source, |  | 
| 1406                               content::DownloadItem* download) { |  | 
| 1407   if (!DownloadItemModel(download).ShouldShowInShelf()) |  | 
| 1408     return; |  | 
| 1409 |  | 
| 1410   WebContents* constrained = GetConstrainingWebContents(source); |  | 
| 1411   if (constrained != source) { |  | 
| 1412     // Download in a constrained popup is shown in the tab that opened it. |  | 
| 1413     constrained->GetDelegate()->OnStartDownload(constrained, download); |  | 
| 1414     return; |  | 
| 1415   } |  | 
| 1416 |  | 
| 1417   if (!window()) |  | 
| 1418     return; |  | 
| 1419 |  | 
| 1420   // GetDownloadShelf creates the download shelf if it was not yet created. |  | 
| 1421   DownloadShelf* shelf = window()->GetDownloadShelf(); |  | 
| 1422   shelf->AddDownload(download); |  | 
| 1423 |  | 
| 1424   // If the download occurs in a new tab, and it's not a save page |  | 
| 1425   // download (started before initial navigation completed), close it. |  | 
| 1426   if (source->GetController().IsInitialNavigation() && |  | 
| 1427       tab_strip_model_->count() > 1 && !download->IsSavePackageDownload()) |  | 
| 1428     CloseContents(source); |  | 
| 1429 } |  | 
| 1430 |  | 
| 1431 void Browser::ViewSourceForTab(WebContents* source, const GURL& page_url) { | 1426 void Browser::ViewSourceForTab(WebContents* source, const GURL& page_url) { | 
| 1432   DCHECK(source); | 1427   DCHECK(source); | 
| 1433   chrome::ViewSource(this, source); | 1428   chrome::ViewSource(this, source); | 
| 1434 } | 1429 } | 
| 1435 | 1430 | 
| 1436 void Browser::ViewSourceForFrame(WebContents* source, | 1431 void Browser::ViewSourceForFrame(WebContents* source, | 
| 1437                                  const GURL& frame_url, | 1432                                  const GURL& frame_url, | 
| 1438                                  const std::string& frame_content_state) { | 1433                                  const std::string& frame_content_state) { | 
| 1439   DCHECK(source); | 1434   DCHECK(source); | 
| 1440   chrome::ViewSource(this, source, frame_url, frame_content_state); | 1435   chrome::ViewSource(this, source, frame_url, frame_content_state); | 
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2259   if (contents && !allow_js_access) { | 2254   if (contents && !allow_js_access) { | 
| 2260     contents->web_contents()->GetController().LoadURL( | 2255     contents->web_contents()->GetController().LoadURL( | 
| 2261         target_url, | 2256         target_url, | 
| 2262         content::Referrer(), | 2257         content::Referrer(), | 
| 2263         content::PAGE_TRANSITION_LINK, | 2258         content::PAGE_TRANSITION_LINK, | 
| 2264         std::string());  // No extra headers. | 2259         std::string());  // No extra headers. | 
| 2265   } | 2260   } | 
| 2266 | 2261 | 
| 2267   return contents != NULL; | 2262   return contents != NULL; | 
| 2268 } | 2263 } | 
| OLD | NEW | 
|---|