| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_SUPPORT_HOST_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_SUPPORT_HOST_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_SUPPORT_HOST_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_SUPPORT_HOST_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "chrome/browser/chromeos/arc/arc_auth_service.h" | 9 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
| 10 #include "components/prefs/pref_change_registrar.h" | 10 #include "components/prefs/pref_change_registrar.h" |
| 11 #include "extensions/browser/api/messaging/native_message_host.h" | 11 #include "extensions/browser/api/messaging/native_message_host.h" |
| 12 #include "ui/display/display_observer.h" | 12 #include "ui/display/display_observer.h" |
| 13 | 13 |
| 14 // Supports communication with Arc support dialog. | 14 // Supports communication with Arc support dialog. |
| 15 class ArcSupportHost : public extensions::NativeMessageHost, | 15 class ArcSupportHost : public extensions::NativeMessageHost, |
| 16 public arc::ArcAuthService::Observer, | 16 public arc::ArcAuthService::Observer, |
| 17 public display::DisplayObserver { | 17 public display::DisplayObserver { |
| 18 public: | 18 public: |
| 19 static const char kHostName[]; | 19 static const char kHostName[]; |
| 20 static const char kHostAppId[]; | 20 static const char kHostAppId[]; |
| 21 static const char kStorageId[]; | 21 static const char kStorageId[]; |
| 22 static const char* const kHostOrigin[]; | 22 static const char* const kHostOrigin[]; |
| 23 | 23 |
| 24 static std::unique_ptr<NativeMessageHost> Create(); | 24 static std::unique_ptr<NativeMessageHost> Create(); |
| 25 | 25 |
| 26 ~ArcSupportHost() override; | 26 ~ArcSupportHost() override; |
| 27 | 27 |
| 28 // Requests to close the extension window. |
| 29 void Close(); |
| 30 |
| 28 // Overrides NativeMessageHost: | 31 // Overrides NativeMessageHost: |
| 29 void Start(Client* client) override; | 32 void Start(Client* client) override; |
| 30 void OnMessage(const std::string& request_string) override; | 33 void OnMessage(const std::string& request_string) override; |
| 31 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const override; | 34 scoped_refptr<base::SingleThreadTaskRunner> task_runner() const override; |
| 32 | 35 |
| 33 // Overrides arc::ArcAuthService::Observer: | 36 // Overrides arc::ArcAuthService::Observer: |
| 34 void OnOptInUIClose() override; | 37 void OnOptInUIClose() override; |
| 35 void OnOptInUIShowPage(arc::ArcAuthService::UIPage page, | 38 void OnOptInUIShowPage(arc::ArcAuthService::UIPage page, |
| 36 const base::string16& status) override; | 39 const base::string16& status) override; |
| 37 | 40 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 53 void SendLocationServicesMode(); | 56 void SendLocationServicesMode(); |
| 54 void SendOptionMode(const std::string& action_name, | 57 void SendOptionMode(const std::string& action_name, |
| 55 const std::string& pref_name); | 58 const std::string& pref_name); |
| 56 void EnableMetrics(bool is_enabled); | 59 void EnableMetrics(bool is_enabled); |
| 57 void EnableBackupRestore(bool is_enabled); | 60 void EnableBackupRestore(bool is_enabled); |
| 58 void EnableLocationService(bool is_enabled); | 61 void EnableLocationService(bool is_enabled); |
| 59 | 62 |
| 60 // Unowned pointer. | 63 // Unowned pointer. |
| 61 Client* client_ = nullptr; | 64 Client* client_ = nullptr; |
| 62 | 65 |
| 66 // Keep if Close() is requested from the browser. |
| 67 // TODO(hidehiko): Remove this. This is temporarily introduced for checking |
| 68 // if ArcAuthService::CancelAuthCode() needs to be invoked or not. |
| 69 // ArcAuthService should know its own state and the transition so moving to |
| 70 // there should simplify the structure. However, it is blocked by the current |
| 71 // dependency. For the clean up, more refactoring is needed, which can be |
| 72 // bigger changes. |
| 73 bool close_requested_ = false; |
| 74 |
| 63 // Used to track metrics preference. | 75 // Used to track metrics preference. |
| 64 PrefChangeRegistrar pref_local_change_registrar_; | 76 PrefChangeRegistrar pref_local_change_registrar_; |
| 65 // Used to track backup&restore and location service preference. | 77 // Used to track backup&restore and location service preference. |
| 66 PrefChangeRegistrar pref_change_registrar_; | 78 PrefChangeRegistrar pref_change_registrar_; |
| 67 | 79 |
| 68 DISALLOW_COPY_AND_ASSIGN(ArcSupportHost); | 80 DISALLOW_COPY_AND_ASSIGN(ArcSupportHost); |
| 69 }; | 81 }; |
| 70 | 82 |
| 71 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SUPPORT_HOST_H_ | 83 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SUPPORT_HOST_H_ |
| OLD | NEW |