Chromium Code Reviews| Index: chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc |
| diff --git a/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc b/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc |
| index 866f6ceae240c9ceed18353d4c75964b655f1b5d..ead909d1d6e1bc55e21b8568064f955f927519cf 100644 |
| --- a/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc |
| +++ b/chrome/browser/extensions/api/tab_capture/tab_capture_registry.cc |
| @@ -30,9 +30,11 @@ class TabCaptureRegistry::LiveRequest : public content::WebContentsObserver { |
| public: |
| LiveRequest(content::WebContents* target_contents, |
| const std::string& extension_id, |
| + bool is_anonymous, |
| TabCaptureRegistry* registry) |
| : content::WebContentsObserver(target_contents), |
| extension_id_(extension_id), |
| + is_anonymous_(is_anonymous), |
| registry_(registry), |
| capture_state_(tab_capture::TAB_CAPTURE_STATE_NONE), |
| is_verified_(false), |
| @@ -51,6 +53,9 @@ class TabCaptureRegistry::LiveRequest : public content::WebContentsObserver { |
| const std::string& extension_id() const { |
| return extension_id_; |
| } |
| + bool is_anonymous() const { |
| + return is_anonymous_; |
| + } |
| TabCaptureState capture_state() const { |
| return capture_state_; |
| } |
| @@ -120,6 +125,7 @@ class TabCaptureRegistry::LiveRequest : public content::WebContentsObserver { |
| private: |
| const std::string extension_id_; |
| + const bool is_anonymous_; |
| TabCaptureRegistry* const registry_; |
| TabCaptureState capture_state_; |
| bool is_verified_; |
| @@ -164,13 +170,13 @@ void TabCaptureRegistry::GetCapturedTabs( |
| DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| DCHECK(list_of_capture_info); |
| list_of_capture_info->Clear(); |
| - for (ScopedVector<LiveRequest>::const_iterator it = requests_.begin(); |
| - it != requests_.end(); ++it) { |
| - if ((*it)->is_verified() && (*it)->extension_id() == extension_id) { |
| - tab_capture::CaptureInfo info; |
| - (*it)->GetCaptureInfo(&info); |
| - list_of_capture_info->Append(info.ToValue().release()); |
| - } |
| + for (const LiveRequest* request : requests_) { |
| + if (request->is_anonymous() || !request->is_verified() || |
| + request->extension_id() != extension_id) |
| + return; |
|
imcheng
2015/09/29 01:28:55
Did you mean continue; here?
miu
2015/09/30 19:46:38
Good catch. Done.
|
| + tab_capture::CaptureInfo info; |
| + request->GetCaptureInfo(&info); |
| + list_of_capture_info->Append(info.ToValue().release()); |
| } |
| } |
| @@ -190,7 +196,8 @@ void TabCaptureRegistry::OnExtensionUnloaded( |
| } |
| bool TabCaptureRegistry::AddRequest(content::WebContents* target_contents, |
| - const std::string& extension_id) { |
| + const std::string& extension_id, |
| + bool is_anonymous) { |
| LiveRequest* const request = FindRequest(target_contents); |
| // Currently, we do not allow multiple active captures for same tab. |
| @@ -204,7 +211,8 @@ bool TabCaptureRegistry::AddRequest(content::WebContents* target_contents, |
| } |
| } |
| - requests_.push_back(new LiveRequest(target_contents, extension_id, this)); |
| + requests_.push_back( |
| + new LiveRequest(target_contents, extension_id, is_anonymous, this)); |
| return true; |
| } |
| @@ -305,6 +313,9 @@ void TabCaptureRegistry::OnRequestUpdate( |
| void TabCaptureRegistry::DispatchStatusChangeEvent( |
| const LiveRequest* request) const { |
| + if (request->is_anonymous()) |
| + return; |
| + |
| EventRouter* router = EventRouter::Get(browser_context_); |
| if (!router) |
| return; |