| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/extensions/api/tab_capture/tab_capture_registry.h" | 5 #include "chrome/browser/extensions/api/tab_capture/tab_capture_registry.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/sessions/session_tab_helper.h" | 9 #include "chrome/browser/sessions/session_tab_helper.h" |
| 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 is_verified_(false), | 38 is_verified_(false), |
| 39 // TODO(miu): This initial value for |is_fullscreened_| is a faulty | 39 // TODO(miu): This initial value for |is_fullscreened_| is a faulty |
| 40 // assumption. http://crbug.com/350491 | 40 // assumption. http://crbug.com/350491 |
| 41 is_fullscreened_(false), | 41 is_fullscreened_(false), |
| 42 render_process_id_(-1), | 42 render_process_id_(-1), |
| 43 render_frame_id_(-1) { | 43 render_frame_id_(-1) { |
| 44 DCHECK(web_contents()); | 44 DCHECK(web_contents()); |
| 45 DCHECK(registry_); | 45 DCHECK(registry_); |
| 46 } | 46 } |
| 47 | 47 |
| 48 virtual ~LiveRequest() {} | 48 ~LiveRequest() override {} |
| 49 | 49 |
| 50 // Accessors. | 50 // Accessors. |
| 51 const std::string& extension_id() const { | 51 const std::string& extension_id() const { |
| 52 return extension_id_; | 52 return extension_id_; |
| 53 } | 53 } |
| 54 TabCaptureState capture_state() const { | 54 TabCaptureState capture_state() const { |
| 55 return capture_state_; | 55 return capture_state_; |
| 56 } | 56 } |
| 57 bool is_verified() const { | 57 bool is_verified() const { |
| 58 return is_verified_; | 58 return is_verified_; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 89 registry_->DispatchStatusChangeEvent(this); | 89 registry_->DispatchStatusChangeEvent(this); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void GetCaptureInfo(tab_capture::CaptureInfo* info) const { | 92 void GetCaptureInfo(tab_capture::CaptureInfo* info) const { |
| 93 info->tab_id = SessionTabHelper::IdForTab(web_contents()); | 93 info->tab_id = SessionTabHelper::IdForTab(web_contents()); |
| 94 info->status = capture_state_; | 94 info->status = capture_state_; |
| 95 info->fullscreen = is_fullscreened_; | 95 info->fullscreen = is_fullscreened_; |
| 96 } | 96 } |
| 97 | 97 |
| 98 protected: | 98 protected: |
| 99 virtual void DidShowFullscreenWidget(int routing_id) override { | 99 void DidShowFullscreenWidget(int routing_id) override { |
| 100 is_fullscreened_ = true; | 100 is_fullscreened_ = true; |
| 101 if (capture_state_ == tab_capture::TAB_CAPTURE_STATE_ACTIVE) | 101 if (capture_state_ == tab_capture::TAB_CAPTURE_STATE_ACTIVE) |
| 102 registry_->DispatchStatusChangeEvent(this); | 102 registry_->DispatchStatusChangeEvent(this); |
| 103 } | 103 } |
| 104 | 104 |
| 105 virtual void DidDestroyFullscreenWidget(int routing_id) override { | 105 void DidDestroyFullscreenWidget(int routing_id) override { |
| 106 is_fullscreened_ = false; | 106 is_fullscreened_ = false; |
| 107 if (capture_state_ == tab_capture::TAB_CAPTURE_STATE_ACTIVE) | 107 if (capture_state_ == tab_capture::TAB_CAPTURE_STATE_ACTIVE) |
| 108 registry_->DispatchStatusChangeEvent(this); | 108 registry_->DispatchStatusChangeEvent(this); |
| 109 } | 109 } |
| 110 | 110 |
| 111 virtual void DidToggleFullscreenModeForTab(bool entered_fullscreen) override { | 111 void DidToggleFullscreenModeForTab(bool entered_fullscreen) override { |
| 112 is_fullscreened_ = entered_fullscreen; | 112 is_fullscreened_ = entered_fullscreen; |
| 113 if (capture_state_ == tab_capture::TAB_CAPTURE_STATE_ACTIVE) | 113 if (capture_state_ == tab_capture::TAB_CAPTURE_STATE_ACTIVE) |
| 114 registry_->DispatchStatusChangeEvent(this); | 114 registry_->DispatchStatusChangeEvent(this); |
| 115 } | 115 } |
| 116 | 116 |
| 117 virtual void WebContentsDestroyed() override { | 117 void WebContentsDestroyed() override { |
| 118 registry_->KillRequest(this); // Deletes |this|. | 118 registry_->KillRequest(this); // Deletes |this|. |
| 119 } | 119 } |
| 120 | 120 |
| 121 private: | 121 private: |
| 122 const std::string extension_id_; | 122 const std::string extension_id_; |
| 123 TabCaptureRegistry* const registry_; | 123 TabCaptureRegistry* const registry_; |
| 124 TabCaptureState capture_state_; | 124 TabCaptureState capture_state_; |
| 125 bool is_verified_; | 125 bool is_verified_; |
| 126 bool is_fullscreened_; | 126 bool is_fullscreened_; |
| 127 | 127 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 it != requests_.end(); ++it) { | 348 it != requests_.end(); ++it) { |
| 349 if ((*it) == request) { | 349 if ((*it) == request) { |
| 350 requests_.erase(it); | 350 requests_.erase(it); |
| 351 return; | 351 return; |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 NOTREACHED(); | 354 NOTREACHED(); |
| 355 } | 355 } |
| 356 | 356 |
| 357 } // namespace extensions | 357 } // namespace extensions |
| OLD | NEW |