Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(741)

Side by Side Diff: chrome/browser/ui/omnibox/alternate_nav_url_fetcher.cc

Issue 18223002: InstantExtended: Remove overlay control code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Call renamed method. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/omnibox/alternate_nav_url_fetcher.h" 5 #include "chrome/browser/ui/omnibox/alternate_nav_url_fetcher.h"
6 6
7 #include "chrome/browser/infobars/infobar_service.h" 7 #include "chrome/browser/infobars/infobar_service.h"
8 #include "chrome/browser/intranet_redirect_detector.h" 8 #include "chrome/browser/intranet_redirect_detector.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.h" 10 #include "chrome/browser/ui/omnibox/alternate_nav_infobar_delegate.h"
(...skipping 11 matching lines...) Expand all
22 using content::NavigationController; 22 using content::NavigationController;
23 23
24 AlternateNavURLFetcher::AlternateNavURLFetcher( 24 AlternateNavURLFetcher::AlternateNavURLFetcher(
25 const GURL& alternate_nav_url) 25 const GURL& alternate_nav_url)
26 : alternate_nav_url_(alternate_nav_url), 26 : alternate_nav_url_(alternate_nav_url),
27 controller_(NULL), 27 controller_(NULL),
28 state_(NOT_STARTED), 28 state_(NOT_STARTED),
29 navigated_to_entry_(false) { 29 navigated_to_entry_(false) {
30 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, 30 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
31 content::NotificationService::AllSources()); 31 content::NotificationService::AllSources());
32 registrar_.Add(this, chrome::NOTIFICATION_INSTANT_COMMITTED,
33 content::NotificationService::AllSources());
34 } 32 }
35 33
36 AlternateNavURLFetcher::~AlternateNavURLFetcher() { 34 AlternateNavURLFetcher::~AlternateNavURLFetcher() {
37 } 35 }
38 36
39 void AlternateNavURLFetcher::Observe( 37 void AlternateNavURLFetcher::Observe(
40 int type, 38 int type,
41 const content::NotificationSource& source, 39 const content::NotificationSource& source,
42 const content::NotificationDetails& details) { 40 const content::NotificationDetails& details) {
43 switch (type) { 41 switch (type) {
44 case content::NOTIFICATION_NAV_ENTRY_PENDING: { 42 case content::NOTIFICATION_NAV_ENTRY_PENDING: {
45 // If we've already received a notification for the same controller, we 43 // If we've already received a notification for the same controller, we
46 // should delete ourselves as that indicates that the page is being 44 // should delete ourselves as that indicates that the page is being
47 // re-loaded so this instance is now stale. 45 // re-loaded so this instance is now stale.
48 NavigationController* controller = 46 NavigationController* controller =
49 content::Source<NavigationController>(source).ptr(); 47 content::Source<NavigationController>(source).ptr();
50 if (controller_ == controller) { 48 if (controller_ == controller) {
51 delete this; 49 delete this;
52 } else if (!controller_) { 50 } else if (!controller_) {
53 // Start listening for the commit notification. 51 // Start listening for the commit notification.
54 DCHECK(controller->GetPendingEntry()); 52 DCHECK(controller->GetPendingEntry());
55 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 53 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
56 content::Source<NavigationController>( 54 content::Source<NavigationController>(
57 controller)); 55 controller));
58 StartFetch(controller); 56 StartFetch(controller);
59 } 57 }
60 break; 58 break;
61 } 59 }
62 60
63 case chrome::NOTIFICATION_INSTANT_COMMITTED: {
64 // See above.
65 NavigationController* controller =
66 &content::Source<content::WebContents>(source)->GetController();
67 if (controller_ == controller) {
68 delete this;
69 } else if (!controller_) {
70 navigated_to_entry_ = true;
71 StartFetch(controller);
72 }
73 break;
74 }
75
76 case content::NOTIFICATION_NAV_ENTRY_COMMITTED: 61 case content::NOTIFICATION_NAV_ENTRY_COMMITTED:
77 // The page was navigated, we can show the infobar now if necessary. 62 // The page was navigated, we can show the infobar now if necessary.
78 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 63 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
79 content::Source<NavigationController>(controller_)); 64 content::Source<NavigationController>(controller_));
80 navigated_to_entry_ = true; 65 navigated_to_entry_ = true;
81 ShowInfobarIfPossible(); 66 ShowInfobarIfPossible();
82 // WARNING: |this| may be deleted! 67 // WARNING: |this| may be deleted!
83 break; 68 break;
84 69
85 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED: 70 case content::NOTIFICATION_WEB_CONTENTS_DESTROYED:
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 void AlternateNavURLFetcher::ShowInfobarIfPossible() { 135 void AlternateNavURLFetcher::ShowInfobarIfPossible() {
151 if (navigated_to_entry_ && (state_ == SUCCEEDED)) { 136 if (navigated_to_entry_ && (state_ == SUCCEEDED)) {
152 AlternateNavInfoBarDelegate::Create( 137 AlternateNavInfoBarDelegate::Create(
153 InfoBarService::FromWebContents(controller_->GetWebContents()), 138 InfoBarService::FromWebContents(controller_->GetWebContents()),
154 alternate_nav_url_); 139 alternate_nav_url_);
155 } else if (state_ != FAILED) { 140 } else if (state_ != FAILED) {
156 return; 141 return;
157 } 142 }
158 delete this; 143 delete this;
159 } 144 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/tab_contents/render_view_context_menu_mac.mm ('k') | chrome/browser/ui/omnibox/omnibox_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698