OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #import "ios/chrome/browser/geolocation/omnibox_geolocation_controller.h" | 5 #import "ios/chrome/browser/geolocation/omnibox_geolocation_controller.h" |
6 | 6 |
7 #import <CoreLocation/CoreLocation.h> | 7 #import <CoreLocation/CoreLocation.h> |
8 #import <UIKit/UIKit.h> | 8 #import <UIKit/UIKit.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 [self.locationManager startUpdatingLocation]; | 435 [self.locationManager startUpdatingLocation]; |
436 } | 436 } |
437 | 437 |
438 - (void)stopUpdatingLocation { | 438 - (void)stopUpdatingLocation { |
439 // Note that we don't need to initialize |locationManager_| here. If it's | 439 // Note that we don't need to initialize |locationManager_| here. If it's |
440 // nil, then it's not running. | 440 // nil, then it's not running. |
441 [locationManager_ stopUpdatingLocation]; | 441 [locationManager_ stopUpdatingLocation]; |
442 } | 442 } |
443 | 443 |
444 - (void)addLocationAndReloadTab:(Tab*)tab { | 444 - (void)addLocationAndReloadTab:(Tab*)tab { |
445 if (self.enabled && [tab navigationManager]) { | 445 if (self.enabled && tab.webState) { |
446 // Make sure that GeolocationUpdater is running the first time we request | 446 // Make sure that GeolocationUpdater is running the first time we request |
447 // the current location. | 447 // the current location. |
448 // | 448 // |
449 // If GeolocationUpdater is not running, then it returns nil for the | 449 // If GeolocationUpdater is not running, then it returns nil for the |
450 // current location. That's normally okay, because we cache the most recent | 450 // current location. That's normally okay, because we cache the most recent |
451 // location in LocationManager. However, we arrive here when the user first | 451 // location in LocationManager. However, we arrive here when the user first |
452 // authorizes us to use location, so we may not have ever started | 452 // authorizes us to use location, so we may not have ever started |
453 // GeolocationUpdater. | 453 // GeolocationUpdater. |
454 [self startUpdatingLocation]; | 454 [self startUpdatingLocation]; |
455 | 455 |
456 web::NavigationItem* item = | 456 web::NavigationManager* navigationManager = |
457 tab.webState->GetNavigationManager()->GetVisibleItem(); | 457 tab.webState->GetNavigationManager(); |
| 458 web::NavigationItem* item = navigationManager->GetVisibleItem(); |
458 if ([self addLocationToNavigationItem:item browserState:tab.browserState]) { | 459 if ([self addLocationToNavigationItem:item browserState:tab.browserState]) { |
459 [tab reload]; | 460 navigationManager->Reload(web::ReloadType::NORMAL, |
| 461 false /* check_for_repost */); |
460 } | 462 } |
461 } | 463 } |
462 } | 464 } |
463 | 465 |
464 - (BOOL)shouldShowAuthorizationAlert { | 466 - (BOOL)shouldShowAuthorizationAlert { |
465 base::Version previousVersion(self.localState.lastAuthorizationAlertVersion); | 467 base::Version previousVersion(self.localState.lastAuthorizationAlertVersion); |
466 if (!previousVersion.IsValid()) | 468 if (!previousVersion.IsValid()) |
467 return YES; | 469 return YES; |
468 | 470 |
469 base::Version currentVersion(version_info::GetVersionNumber()); | 471 base::Version currentVersion(version_info::GetVersionNumber()); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 | 579 |
578 - (void)setLocalState:(OmniboxGeolocationLocalState*)localState { | 580 - (void)setLocalState:(OmniboxGeolocationLocalState*)localState { |
579 localState_.reset([localState retain]); | 581 localState_.reset([localState retain]); |
580 } | 582 } |
581 | 583 |
582 - (void)setLocationManager:(LocationManager*)locationManager { | 584 - (void)setLocationManager:(LocationManager*)locationManager { |
583 locationManager_.reset([locationManager retain]); | 585 locationManager_.reset([locationManager retain]); |
584 } | 586 } |
585 | 587 |
586 @end | 588 @end |
OLD | NEW |