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

Side by Side Diff: blimp/client/core/contents/blimp_contents_impl.cc

Issue 2624903006: Remove all blimp client code. (Closed)
Patch Set: Update buildbot configuration Created 3 years, 11 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "blimp/client/core/contents/blimp_contents_impl.h"
6
7 #include "base/memory/ptr_util.h"
8 #include "base/metrics/histogram_macros.h"
9 #include "base/supports_user_data.h"
10 #include "blimp/client/core/contents/tab_control_feature.h"
11 #include "blimp/client/public/contents/blimp_contents_observer.h"
12 #include "ui/gfx/native_widget_types.h"
13
14 #if defined(OS_ANDROID)
15 #include "blimp/client/core/contents/android/blimp_contents_impl_android.h"
16 #endif // OS_ANDROID
17
18 namespace blimp {
19 namespace client {
20
21 namespace {
22
23 #if defined(OS_ANDROID)
24 const char kBlimpContentsImplAndroidKey[] = "blimp_contents_impl_android";
25 #endif // OS_ANDROID
26 }
27
28 BlimpContentsImpl::BlimpContentsImpl(
29 int id,
30 gfx::NativeWindow window,
31 BlimpCompositorDependencies* compositor_deps,
32 ImeFeature* ime_feature,
33 NavigationFeature* navigation_feature,
34 RenderWidgetFeature* render_widget_feature,
35 TabControlFeature* tab_control_feature)
36 : navigation_controller_(id, this, navigation_feature),
37 document_manager_(id, render_widget_feature, compositor_deps),
38 id_(id),
39 ime_feature_(ime_feature),
40 window_(window),
41 tab_control_feature_(tab_control_feature) {
42 blimp_contents_view_ =
43 BlimpContentsViewImpl::Create(this, document_manager_.layer());
44 ime_feature_->set_delegate(blimp_contents_view_->GetImeDelegate());
45 }
46
47 BlimpContentsImpl::~BlimpContentsImpl() {
48 for (auto& observer : observers_)
49 observer.BlimpContentsDying();
50 ime_feature_->set_delegate(nullptr);
51 }
52
53 #if defined(OS_ANDROID)
54
55 base::android::ScopedJavaLocalRef<jobject> BlimpContentsImpl::GetJavaObject() {
56 return GetBlimpContentsImplAndroid()->GetJavaObject();
57 }
58
59 BlimpContentsImplAndroid* BlimpContentsImpl::GetBlimpContentsImplAndroid() {
60 BlimpContentsImplAndroid* blimp_contents_impl_android =
61 static_cast<BlimpContentsImplAndroid*>(
62 GetUserData(kBlimpContentsImplAndroidKey));
63 if (!blimp_contents_impl_android) {
64 blimp_contents_impl_android = new BlimpContentsImplAndroid(this);
65 SetUserData(kBlimpContentsImplAndroidKey, blimp_contents_impl_android);
66 }
67 return blimp_contents_impl_android;
68 }
69
70 // static
71 BlimpContents* BlimpContents::FromJavaObject(
72 JNIEnv* env,
73 const base::android::JavaRef<jobject>& jobj) {
74 BlimpContentsImplAndroid* blimp_contents_impl_android =
75 BlimpContentsImplAndroid::FromJavaObject(env, jobj);
76 if (!blimp_contents_impl_android) {
77 return nullptr;
78 }
79 return blimp_contents_impl_android->blimp_contents_impl();
80 }
81
82 #endif // defined(OS_ANDROID)
83
84 BlimpNavigationControllerImpl& BlimpContentsImpl::GetNavigationController() {
85 return navigation_controller_;
86 }
87
88 gfx::NativeWindow BlimpContentsImpl::GetNativeWindow() {
89 return window_;
90 }
91
92 void BlimpContentsImpl::AddObserver(BlimpContentsObserver* observer) {
93 observers_.AddObserver(observer);
94 }
95
96 void BlimpContentsImpl::RemoveObserver(BlimpContentsObserver* observer) {
97 observers_.RemoveObserver(observer);
98 }
99
100 BlimpContentsViewImpl* BlimpContentsImpl::GetView() {
101 return blimp_contents_view_.get();
102 }
103
104 void BlimpContentsImpl::Show() {
105 document_manager_.SetVisible(true);
106 UMA_HISTOGRAM_BOOLEAN("Blimp.Tab.Visible", true);
107 }
108
109 void BlimpContentsImpl::Hide() {
110 document_manager_.SetVisible(false);
111 UMA_HISTOGRAM_BOOLEAN("Blimp.Tab.Visible", false);
112 }
113
114 bool BlimpContentsImpl::HasObserver(BlimpContentsObserver* observer) {
115 return observers_.HasObserver(observer);
116 }
117
118 void BlimpContentsImpl::OnNavigationStateChanged() {
119 for (auto& observer : observers_)
120 observer.OnNavigationStateChanged();
121 }
122
123 void BlimpContentsImpl::OnLoadingStateChanged(bool loading) {
124 for (auto& observer : observers_)
125 observer.OnLoadingStateChanged(loading);
126 }
127
128 void BlimpContentsImpl::OnPageLoadingStateChanged(bool loading) {
129 for (auto& observer : observers_)
130 observer.OnPageLoadingStateChanged(loading);
131 }
132
133 void BlimpContentsImpl::SetSizeAndScale(const gfx::Size& size,
134 float device_pixel_ratio) {
135 tab_control_feature_->SetSizeAndScale(size, device_pixel_ratio);
136 }
137
138 } // namespace client
139 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/client/core/contents/blimp_contents_impl.h ('k') | blimp/client/core/contents/blimp_contents_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698