| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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/app/linux/blimp_client_session_linux.h" | |
| 6 | |
| 7 #include <string> | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 #include "base/message_loop/message_loop.h" | |
| 11 #include "blimp/client/app/linux/blimp_display_manager.h" | |
| 12 #include "ui/events/platform/platform_event_source.h" | |
| 13 #include "ui/gfx/geometry/size.h" | |
| 14 #include "url/gurl.h" | |
| 15 | |
| 16 namespace blimp { | |
| 17 namespace client { | |
| 18 namespace { | |
| 19 | |
| 20 const int kDummyTabId = 0; | |
| 21 const char kDefaultAssignerUrl[] = | |
| 22 "https://blimp-pa.googleapis.com/v1/assignment"; | |
| 23 | |
| 24 class FakeNavigationFeatureDelegate | |
| 25 : public NavigationFeature::NavigationFeatureDelegate { | |
| 26 public: | |
| 27 FakeNavigationFeatureDelegate(); | |
| 28 ~FakeNavigationFeatureDelegate() override; | |
| 29 | |
| 30 // NavigationFeatureDelegate implementation. | |
| 31 void OnUrlChanged(int tab_id, const GURL& url) override; | |
| 32 void OnFaviconChanged(int tab_id, const SkBitmap& favicon) override; | |
| 33 void OnTitleChanged(int tab_id, const std::string& title) override; | |
| 34 void OnLoadingChanged(int tab_id, bool loading) override; | |
| 35 void OnPageLoadStatusUpdate(int tab_id, bool completed) override; | |
| 36 | |
| 37 private: | |
| 38 DISALLOW_COPY_AND_ASSIGN(FakeNavigationFeatureDelegate); | |
| 39 }; | |
| 40 | |
| 41 FakeNavigationFeatureDelegate::FakeNavigationFeatureDelegate() {} | |
| 42 | |
| 43 FakeNavigationFeatureDelegate::~FakeNavigationFeatureDelegate() {} | |
| 44 | |
| 45 void FakeNavigationFeatureDelegate::OnUrlChanged(int tab_id, const GURL& url) { | |
| 46 DVLOG(1) << "URL changed to " << url << " in tab " << tab_id; | |
| 47 } | |
| 48 | |
| 49 void FakeNavigationFeatureDelegate::OnFaviconChanged(int tab_id, | |
| 50 const SkBitmap& favicon) { | |
| 51 DVLOG(1) << "Favicon changed in tab " << tab_id; | |
| 52 } | |
| 53 | |
| 54 void FakeNavigationFeatureDelegate::OnTitleChanged(int tab_id, | |
| 55 const std::string& title) { | |
| 56 DVLOG(1) << "Title changed to " << title << " in tab " << tab_id; | |
| 57 } | |
| 58 | |
| 59 void FakeNavigationFeatureDelegate::OnLoadingChanged(int tab_id, bool loading) { | |
| 60 DVLOG(1) << "Loading status changed to " << loading << " in tab " << tab_id; | |
| 61 } | |
| 62 | |
| 63 void FakeNavigationFeatureDelegate::OnPageLoadStatusUpdate(int tab_id, | |
| 64 bool completed) { | |
| 65 DVLOG(1) << "Page Load Status changed to completed = " << completed << | |
| 66 " in tab " << tab_id; | |
| 67 } | |
| 68 | |
| 69 class FakeImeFeatureDelegate : public ImeFeature::Delegate { | |
| 70 public: | |
| 71 FakeImeFeatureDelegate(); | |
| 72 ~FakeImeFeatureDelegate() override; | |
| 73 | |
| 74 // ImeFeature::Delegate implementation. | |
| 75 void OnShowImeRequested(ui::TextInputType input_type, | |
| 76 const std::string& text, | |
| 77 const ImeFeature::ShowImeCallback& callback) override; | |
| 78 void OnHideImeRequested() override; | |
| 79 | |
| 80 private: | |
| 81 DISALLOW_COPY_AND_ASSIGN(FakeImeFeatureDelegate); | |
| 82 }; | |
| 83 | |
| 84 FakeImeFeatureDelegate::FakeImeFeatureDelegate() {} | |
| 85 | |
| 86 FakeImeFeatureDelegate::~FakeImeFeatureDelegate() {} | |
| 87 | |
| 88 void FakeImeFeatureDelegate::OnShowImeRequested( | |
| 89 ui::TextInputType input_type, | |
| 90 const std::string& text, | |
| 91 const ImeFeature::ShowImeCallback& callback) { | |
| 92 DVLOG(1) << "Show IME requested (input_type=" << input_type << ")"; | |
| 93 } | |
| 94 | |
| 95 void FakeImeFeatureDelegate::OnHideImeRequested() { | |
| 96 DVLOG(1) << "Hide IME requested"; | |
| 97 } | |
| 98 | |
| 99 } // namespace | |
| 100 | |
| 101 BlimpClientSessionLinux::BlimpClientSessionLinux() | |
| 102 : BlimpClientSession(GURL(kDefaultAssignerUrl)), | |
| 103 event_source_(ui::PlatformEventSource::CreateDefault()), | |
| 104 navigation_feature_delegate_(new FakeNavigationFeatureDelegate), | |
| 105 ime_feature_delegate_(new FakeImeFeatureDelegate) { | |
| 106 blimp_display_manager_.reset(new BlimpDisplayManager(gfx::Size(800, 600), | |
| 107 this, | |
| 108 GetRenderWidgetFeature(), | |
| 109 GetTabControlFeature())); | |
| 110 GetNavigationFeature()->SetDelegate(kDummyTabId, | |
| 111 navigation_feature_delegate_.get()); | |
| 112 GetImeFeature()->set_delegate(ime_feature_delegate_.get()); | |
| 113 } | |
| 114 | |
| 115 BlimpClientSessionLinux::~BlimpClientSessionLinux() {} | |
| 116 | |
| 117 void BlimpClientSessionLinux::OnClosed() { | |
| 118 base::MessageLoop::current()->QuitNow(); | |
| 119 } | |
| 120 | |
| 121 } // namespace client | |
| 122 } // namespace blimp | |
| OLD | NEW |