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

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

Issue 12386019: Instant: Use only one hidden WebContents per profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 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 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_overlay_model.h" 5 #include "chrome/browser/instant/instant_overlay_model.h"
6 6
7 #include "chrome/browser/instant/instant_controller.h" 7 #include "base/stringprintf.h"
8 #include "chrome/browser/instant/instant_overlay_model_observer.h" 8 #include "chrome/browser/instant/instant_overlay_model_observer.h"
9 #include "chrome/browser/instant/instant_service.h"
9 10
10 InstantOverlayModel::InstantOverlayModel(InstantController* controller) 11 InstantOverlayModel::InstantOverlayModel(InstantService* service)
11 : height_(0), 12 : contents_(NULL),
12 height_units_(INSTANT_SIZE_PIXELS), 13 height_(0),
13 overlay_contents_(NULL), 14 height_units_(INSTANT_SIZE_PIXELS),
14 controller_(controller) { 15 service_(service) {
15 } 16 }
16 17
17 InstantOverlayModel::~InstantOverlayModel() { 18 InstantOverlayModel::~InstantOverlayModel() {
18 } 19 }
19 20
20 void InstantOverlayModel::SetOverlayState(const chrome::search::Mode& mode, 21 void InstantOverlayModel::SetOverlayState(content::WebContents* contents,
21 int height, 22 int height,
22 InstantSizeUnits height_units) { 23 InstantSizeUnits height_units) {
23 if (mode_.mode == mode.mode && height_ == height && 24 if (contents_ == contents && height_ == height &&
24 height_units_ == height_units) { 25 height_units_ == height_units)
25 // Mode::mode hasn't changed, but perhaps bits that we ignore (such as
26 // Mode::origin) have. Update |mode_| anyway, so it's consistent with the
27 // argument (so mode() doesn't return something unexpected).
28 mode_ = mode;
29 return; 26 return;
30 }
31 27
32 DVLOG(1) << "SetOverlayState: " << mode_.mode << " to " << mode.mode; 28 service_->LogDebugEvent(base::StringPrintf("%p SetOverlayState %s",
33 mode_ = mode; 29 this,
30 contents ? "show" : "hide"));
31 contents_ = contents;
34 height_ = height; 32 height_ = height;
35 height_units_ = height_units; 33 height_units_ = height_units;
36 34
37 FOR_EACH_OBSERVER(InstantOverlayModelObserver, observers_, 35 FOR_EACH_OBSERVER(InstantOverlayModelObserver, observers_,
38 OverlayStateChanged(*this)); 36 OverlayStateChanged(*this));
39 } 37 }
40 38
41 void InstantOverlayModel::SetOverlayContents(
42 content::WebContents* overlay_contents) {
43 if (overlay_contents_ == overlay_contents)
44 return;
45
46 overlay_contents_ = overlay_contents;
47
48 FOR_EACH_OBSERVER(InstantOverlayModelObserver, observers_,
49 OverlayStateChanged(*this));
50 }
51
52 content::WebContents* InstantOverlayModel::GetOverlayContents() const {
53 // |controller_| maybe NULL durning tests.
54 if (controller_)
55 return controller_->GetOverlayContents();
56 return overlay_contents_;
57 }
58
59 void InstantOverlayModel::AddObserver(InstantOverlayModelObserver* observer) { 39 void InstantOverlayModel::AddObserver(InstantOverlayModelObserver* observer) {
60 observers_.AddObserver(observer); 40 observers_.AddObserver(observer);
61 } 41 }
62 42
63 void InstantOverlayModel::RemoveObserver( 43 void InstantOverlayModel::RemoveObserver(
64 InstantOverlayModelObserver* observer) { 44 InstantOverlayModelObserver* observer) {
65 observers_.RemoveObserver(observer); 45 observers_.RemoveObserver(observer);
66 } 46 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698