| 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 1282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 | 1293 |
| 1294 // We can synchronously update commands since they will only change once per | 1294 // We can synchronously update commands since they will only change once per |
| 1295 // navigation, so we don't have to worry about flickering. We do, however, | 1295 // navigation, so we don't have to worry about flickering. We do, however, |
| 1296 // need to update the command state early on load to always present usable | 1296 // need to update the command state early on load to always present usable |
| 1297 // actions in the face of slow-to-commit pages. | 1297 // actions in the face of slow-to-commit pages. |
| 1298 if (changed_flags & (content::INVALIDATE_TYPE_URL | | 1298 if (changed_flags & (content::INVALIDATE_TYPE_URL | |
| 1299 content::INVALIDATE_TYPE_LOAD)) | 1299 content::INVALIDATE_TYPE_LOAD)) |
| 1300 command_controller_->TabStateChanged(); | 1300 command_controller_->TabStateChanged(); |
| 1301 } | 1301 } |
| 1302 | 1302 |
| 1303 void Browser::AddNewContents(WebContents* source, | 1303 bool Browser::AddNewContents(WebContents* source, |
| 1304 WebContents* new_contents, | 1304 WebContents* new_contents, |
| 1305 WindowOpenDisposition disposition, | 1305 WindowOpenDisposition disposition, |
| 1306 const gfx::Rect& initial_pos, | 1306 const gfx::Rect& initial_pos, |
| 1307 bool user_gesture) { | 1307 bool user_gesture) { |
| 1308 chrome::AddWebContents(this, source, new_contents, disposition, initial_pos, | 1308 return chrome::AddWebContents( |
| 1309 user_gesture); | 1309 this, source, new_contents, disposition, initial_pos, user_gesture); |
| 1310 } | 1310 } |
| 1311 | 1311 |
| 1312 void Browser::ActivateContents(WebContents* contents) { | 1312 void Browser::ActivateContents(WebContents* contents) { |
| 1313 chrome::ActivateTabAt(this, tab_strip_model_->GetIndexOfWebContents(contents), | 1313 chrome::ActivateTabAt(this, tab_strip_model_->GetIndexOfWebContents(contents), |
| 1314 false); | 1314 false); |
| 1315 window_->Activate(); | 1315 window_->Activate(); |
| 1316 } | 1316 } |
| 1317 | 1317 |
| 1318 void Browser::DeactivateContents(WebContents* contents) { | 1318 void Browser::DeactivateContents(WebContents* contents) { |
| 1319 window_->Deactivate(); | 1319 window_->Deactivate(); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 const GURL& target_url) { | 1500 const GURL& target_url) { |
| 1501 if (window_container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { | 1501 if (window_container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { |
| 1502 // If a BackgroundContents is created, suppress the normal WebContents. | 1502 // If a BackgroundContents is created, suppress the normal WebContents. |
| 1503 return !MaybeCreateBackgroundContents( | 1503 return !MaybeCreateBackgroundContents( |
| 1504 route_id, web_contents, frame_name, target_url); | 1504 route_id, web_contents, frame_name, target_url); |
| 1505 } | 1505 } |
| 1506 | 1506 |
| 1507 return true; | 1507 return true; |
| 1508 } | 1508 } |
| 1509 | 1509 |
| 1510 void Browser::WebContentsCreated(WebContents* source_contents, | 1510 bool Browser::WebContentsCreated(WebContents* source_contents, |
| 1511 int64 source_frame_id, | 1511 int64 source_frame_id, |
| 1512 const GURL& target_url, | 1512 const GURL& target_url, |
| 1513 WebContents* new_contents) { | 1513 WebContents* new_contents) { |
| 1514 // Create a TabContents now, so all observers are in place, as the network | 1514 // Create a TabContents now, so all observers are in place, as the network |
| 1515 // requests for its initial navigation will start immediately. The WebContents | 1515 // requests for its initial navigation will start immediately. The WebContents |
| 1516 // will later be inserted into this browser using Browser::Navigate via | 1516 // will later be inserted into this browser using Browser::Navigate via |
| 1517 // AddNewContents. The latter will retrieve the newly created TabContents from | 1517 // AddNewContents. The latter will retrieve the newly created TabContents from |
| 1518 // WebContents object. | 1518 // WebContents object. |
| 1519 TabContents::Factory::CreateTabContents(new_contents); | 1519 TabContents::Factory::CreateTabContents(new_contents); |
| 1520 | 1520 |
| 1521 // Notify. | 1521 // Notify. |
| 1522 RetargetingDetails details; | 1522 RetargetingDetails details; |
| 1523 details.source_web_contents = source_contents; | 1523 details.source_web_contents = source_contents; |
| 1524 details.source_frame_id = source_frame_id; | 1524 details.source_frame_id = source_frame_id; |
| 1525 details.target_url = target_url; | 1525 details.target_url = target_url; |
| 1526 details.target_web_contents = new_contents; | 1526 details.target_web_contents = new_contents; |
| 1527 details.not_yet_in_tabstrip = true; | 1527 details.not_yet_in_tabstrip = true; |
| 1528 content::NotificationService::current()->Notify( | 1528 content::NotificationService::current()->Notify( |
| 1529 chrome::NOTIFICATION_RETARGETING, | 1529 chrome::NOTIFICATION_RETARGETING, |
| 1530 content::Source<Profile>(profile_), | 1530 content::Source<Profile>(profile_), |
| 1531 content::Details<RetargetingDetails>(&details)); | 1531 content::Details<RetargetingDetails>(&details)); |
| 1532 |
| 1533 return true; |
| 1532 } | 1534 } |
| 1533 | 1535 |
| 1534 void Browser::ContentRestrictionsChanged(WebContents* source) { | 1536 void Browser::ContentRestrictionsChanged(WebContents* source) { |
| 1535 command_controller_->ContentRestrictionsChanged(); | 1537 command_controller_->ContentRestrictionsChanged(); |
| 1536 } | 1538 } |
| 1537 | 1539 |
| 1538 void Browser::RendererUnresponsive(WebContents* source) { | 1540 void Browser::RendererUnresponsive(WebContents* source) { |
| 1539 // Ignore hangs if print preview is open. | 1541 // Ignore hangs if print preview is open. |
| 1540 TabContents* tab_contents = TabContents::FromWebContents(source); | 1542 TabContents* tab_contents = TabContents::FromWebContents(source); |
| 1541 if (tab_contents) { | 1543 if (tab_contents) { |
| (...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2308 if (contents && !allow_js_access) { | 2310 if (contents && !allow_js_access) { |
| 2309 contents->web_contents()->GetController().LoadURL( | 2311 contents->web_contents()->GetController().LoadURL( |
| 2310 target_url, | 2312 target_url, |
| 2311 content::Referrer(), | 2313 content::Referrer(), |
| 2312 content::PAGE_TRANSITION_LINK, | 2314 content::PAGE_TRANSITION_LINK, |
| 2313 std::string()); // No extra headers. | 2315 std::string()); // No extra headers. |
| 2314 } | 2316 } |
| 2315 | 2317 |
| 2316 return contents != NULL; | 2318 return contents != NULL; |
| 2317 } | 2319 } |
| OLD | NEW |