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

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

Issue 11824050: InstantExtended: Committed NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 7 years, 10 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
OLDNEW
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/instant/instant_tab.h" 5 #include "chrome/browser/instant/instant_tab.h"
6 6
7 #include "chrome/browser/instant/instant_controller.h" 7 InstantTab::InstantTab(InstantPage::Delegate* delegate)
8 8 : InstantPage(delegate) {
9 InstantTab::InstantTab(InstantController* controller,
10 content::WebContents* contents)
11 : client_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
12 controller_(controller),
13 contents_(contents),
14 supports_instant_(false) {
15 } 9 }
16 10
17 InstantTab::~InstantTab() { 11 InstantTab::~InstantTab() {
18 } 12 }
19 13
20 void InstantTab::Init() { 14 void InstantTab::Init(content::WebContents* contents) {
21 client_.SetContents(contents_); 15 SetContents(contents);
22 client_.DetermineIfPageSupportsInstant(); 16 DetermineIfPageSupportsInstant();
23 } 17 }
24 18
25 void InstantTab::Update(const string16& text, 19 bool InstantTab::ShouldProcessRenderViewGone() const {
26 size_t selection_start, 20 // For a committed page, a crash should not be handled differently.
27 size_t selection_end, 21 return false;
28 bool verbatim) {
29 client_.Update(text, selection_start, selection_end, verbatim);
30 } 22 }
31 23
32 void InstantTab::Submit(const string16& text) { 24 bool InstantTab::ShouldProcessAboutToNavigateMainFrame() const {
33 client_.Submit(text); 25 // The client is a committed tab, navigations will happen as expected.
26 return false;
34 } 27 }
35 28
36 void InstantTab::SendAutocompleteResults( 29 bool InstantTab::ShouldProcessShowInstantPreview() const {
37 const std::vector<InstantAutocompleteResult>& results) { 30 // The page is a committed tab (i.e., always showing), so nothing to do.
38 client_.SendAutocompleteResults(results); 31 return false;
39 } 32 }
40
41 void InstantTab::SetDisplayInstantResults(bool display_instant_results) {
42 client_.SetDisplayInstantResults(display_instant_results);
43 }
44
45 void InstantTab::UpOrDownKeyPressed(int count) {
46 client_.UpOrDownKeyPressed(count);
47 }
48
49 void InstantTab::SetMarginSize(int start, int end) {
50 client_.SetMarginSize(start, end);
51 }
52
53 void InstantTab::SetSuggestions(
54 const std::vector<InstantSuggestion>& suggestions) {
55 InstantSupportDetermined(true);
56 controller_->SetSuggestions(contents_, suggestions);
57 }
58
59 void InstantTab::InstantSupportDetermined(bool supports_instant) {
60 // If we had already determined that the page supports Instant, nothing to do.
61 if (supports_instant_)
62 return;
63
64 supports_instant_ = supports_instant;
65
66 // If the page doesn't support Instant, stop communicating with it.
67 if (!supports_instant)
68 client_.SetContents(NULL);
69
70 controller_->InstantSupportDetermined(contents_, supports_instant);
71 }
72
73 void InstantTab::ShowInstantPreview(InstantShownReason /* reason */,
74 int /* height */,
75 InstantSizeUnits /* units */) {
76 // The page is a committed tab (i.e., always showing), so nothing to do.
77 }
78
79 void InstantTab::StartCapturingKeyStrokes() {
80 // We don't honor this call from committed tabs.
81 }
82
83 void InstantTab::StopCapturingKeyStrokes() {
84 // We don't honor this call from committed tabs.
85 }
86
87 void InstantTab::RenderViewGone() {
88 // For a commit page, a crash should not be handled differently.
89 }
90
91 void InstantTab::AboutToNavigateMainFrame(const GURL& url) {
92 // The client is a committed tab, navigations will happen as expected.
93 }
94
95 void InstantTab::NavigateToURL(const GURL& url,
96 content::PageTransition transition) {
97 controller_->NavigateToURL(url, transition);
98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698