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

Side by Side Diff: chrome/browser/instant/instant_loader.cc

Issue 8956059: Rename NavigationController to NavigationControllerImpl and put it into the content namespace. Al... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 12 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
« no previous file with comments | « chrome/browser/infobars/infobar_delegate.cc ('k') | chrome/browser/memory_details.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/instant/instant_loader.h" 5 #include "chrome/browser/instant/instant_loader.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "content/public/browser/notification_observer.h" 44 #include "content/public/browser/notification_observer.h"
45 #include "content/public/browser/notification_registrar.h" 45 #include "content/public/browser/notification_registrar.h"
46 #include "content/public/browser/notification_service.h" 46 #include "content/public/browser/notification_service.h"
47 #include "content/public/browser/notification_source.h" 47 #include "content/public/browser/notification_source.h"
48 #include "content/public/browser/notification_types.h" 48 #include "content/public/browser/notification_types.h"
49 #include "content/public/browser/web_contents_delegate.h" 49 #include "content/public/browser/web_contents_delegate.h"
50 #include "net/http/http_util.h" 50 #include "net/http/http_util.h"
51 #include "ui/base/l10n/l10n_util.h" 51 #include "ui/base/l10n/l10n_util.h"
52 #include "ui/gfx/codec/png_codec.h" 52 #include "ui/gfx/codec/png_codec.h"
53 53
54 using content::NavigationEntry;
55
54 namespace { 56 namespace {
55 57
56 // Number of ms to delay before updating the omnibox bounds. This is only used 58 // Number of ms to delay before updating the omnibox bounds. This is only used
57 // when the bounds of the omnibox shrinks. If the bounds grows, we update 59 // when the bounds of the omnibox shrinks. If the bounds grows, we update
58 // immediately. 60 // immediately.
59 const int kUpdateBoundsDelayMS = 1000; 61 const int kUpdateBoundsDelayMS = 1000;
60 62
61 // If this status code is seen instant is disabled for the specified host. 63 // If this status code is seen instant is disabled for the specified host.
62 const int kHostBlacklistStatusCode = 403; 64 const int kHostBlacklistStatusCode = 403;
63 65
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 DISALLOW_COPY_AND_ASSIGN(FrameLoadObserver); 137 DISALLOW_COPY_AND_ASSIGN(FrameLoadObserver);
136 }; 138 };
137 139
138 void InstantLoader::FrameLoadObserver::Observe( 140 void InstantLoader::FrameLoadObserver::Observe(
139 int type, 141 int type,
140 const content::NotificationSource& source, 142 const content::NotificationSource& source,
141 const content::NotificationDetails& details) { 143 const content::NotificationDetails& details) {
142 switch (type) { 144 switch (type) {
143 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: { 145 case content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME: {
144 int page_id = *(content::Details<int>(details).ptr()); 146 int page_id = *(content::Details<int>(details).ptr());
145 content::NavigationEntry* active_entry = 147 NavigationEntry* active_entry =
146 tab_contents_->GetController().GetActiveEntry(); 148 tab_contents_->GetController().GetActiveEntry();
147 if (!active_entry || active_entry->GetPageID() != page_id || 149 if (!active_entry || active_entry->GetPageID() != page_id ||
148 active_entry->GetUniqueID() != unique_id_) { 150 active_entry->GetUniqueID() != unique_id_) {
149 return; 151 return;
150 } 152 }
151 loader_->SendBoundsToPage(true); 153 loader_->SendBoundsToPage(true);
152 // TODO: support real cursor position. 154 // TODO: support real cursor position.
153 int text_length = static_cast<int>(text_.size()); 155 int text_length = static_cast<int>(text_.size());
154 RenderViewHost* host = tab_contents_->GetRenderViewHost(); 156 RenderViewHost* host = tab_contents_->GetRenderViewHost();
155 host->Send(new ChromeViewMsg_DetermineIfPageSupportsInstant( 157 host->Send(new ChromeViewMsg_DetermineIfPageSupportsInstant(
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 bool supports_instant) { 327 bool supports_instant) {
326 TabContentsWrapper* tab = loader_->preview_contents(); 328 TabContentsWrapper* tab = loader_->preview_contents();
327 if (tab->profile()->IsOffTheRecord()) 329 if (tab->profile()->IsOffTheRecord())
328 return; 330 return;
329 331
330 for (size_t i = 0; i < add_page_vector_.size(); ++i) { 332 for (size_t i = 0; i < add_page_vector_.size(); ++i) {
331 tab->history_tab_helper()->UpdateHistoryForNavigation( 333 tab->history_tab_helper()->UpdateHistoryForNavigation(
332 add_page_vector_[i].get()); 334 add_page_vector_[i].get());
333 } 335 }
334 336
335 content::NavigationEntry* active_entry = 337 NavigationEntry* active_entry =
336 tab->tab_contents()->GetController().GetActiveEntry(); 338 tab->tab_contents()->GetController().GetActiveEntry();
337 if (!active_entry) { 339 if (!active_entry) {
338 // It appears to be possible to get here with no active entry. This seems 340 // It appears to be possible to get here with no active entry. This seems
339 // to be possible with an auth dialog, but I can't narrow down the 341 // to be possible with an auth dialog, but I can't narrow down the
340 // circumstances. If you hit this, file a bug with the steps you did and 342 // circumstances. If you hit this, file a bug with the steps you did and
341 // assign it to me (sky). 343 // assign it to me (sky).
342 NOTREACHED(); 344 NOTREACHED();
343 return; 345 return;
344 } 346 }
345 tab->history_tab_helper()->UpdateHistoryPageTitle(*active_entry); 347 tab->history_tab_helper()->UpdateHistoryPageTitle(*active_entry);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 IPC_MESSAGE_UNHANDLED(handled = false) 544 IPC_MESSAGE_UNHANDLED(handled = false)
543 IPC_END_MESSAGE_MAP() 545 IPC_END_MESSAGE_MAP()
544 return handled; 546 return handled;
545 } 547 }
546 548
547 void InstantLoader::TabContentsDelegateImpl::OnSetSuggestions( 549 void InstantLoader::TabContentsDelegateImpl::OnSetSuggestions(
548 int32 page_id, 550 int32 page_id,
549 const std::vector<std::string>& suggestions, 551 const std::vector<std::string>& suggestions,
550 InstantCompleteBehavior behavior) { 552 InstantCompleteBehavior behavior) {
551 TabContentsWrapper* source = loader_->preview_contents(); 553 TabContentsWrapper* source = loader_->preview_contents();
552 content::NavigationEntry* entry = 554 NavigationEntry* entry =
553 source->tab_contents()->GetController().GetActiveEntry(); 555 source->tab_contents()->GetController().GetActiveEntry();
554 if (!entry || page_id != entry->GetPageID()) 556 if (!entry || page_id != entry->GetPageID())
555 return; 557 return;
556 558
557 if (suggestions.empty()) 559 if (suggestions.empty())
558 loader_->SetCompleteSuggestedText(string16(), behavior); 560 loader_->SetCompleteSuggestedText(string16(), behavior);
559 else 561 else
560 loader_->SetCompleteSuggestedText(UTF8ToUTF16(suggestions[0]), behavior); 562 loader_->SetCompleteSuggestedText(UTF8ToUTF16(suggestions[0]), behavior);
561 } 563 }
562 564
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 host->Send(new ChromeViewMsg_SearchBoxResize( 1104 host->Send(new ChromeViewMsg_SearchBoxResize(
1103 host->routing_id(), GetOmniboxBoundsInTermsOfPreview())); 1105 host->routing_id(), GetOmniboxBoundsInTermsOfPreview()));
1104 } else { 1106 } else {
1105 host->Send(new ChromeViewMsg_SearchBoxChange( 1107 host->Send(new ChromeViewMsg_SearchBoxChange(
1106 host->routing_id(), user_text, verbatim, 0, 0)); 1108 host->routing_id(), user_text, verbatim, 0, 0));
1107 } 1109 }
1108 1110
1109 frame_load_observer_.reset(new FrameLoadObserver( 1111 frame_load_observer_.reset(new FrameLoadObserver(
1110 this, preview_contents()->tab_contents(), user_text, verbatim)); 1112 this, preview_contents()->tab_contents(), user_text, verbatim));
1111 } 1113 }
OLDNEW
« no previous file with comments | « chrome/browser/infobars/infobar_delegate.cc ('k') | chrome/browser/memory_details.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698