| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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/android/dev_tools_discovery_provider_android.h" | 5 #include "chrome/browser/android/dev_tools_discovery_provider_android.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 | 59 |
| 60 GURL GetURL() const override { | 60 GURL GetURL() const override { |
| 61 return url_; | 61 return url_; |
| 62 } | 62 } |
| 63 | 63 |
| 64 GURL GetFaviconURL() const override { | 64 GURL GetFaviconURL() const override { |
| 65 return favicon_url_; | 65 return favicon_url_; |
| 66 } | 66 } |
| 67 | 67 |
| 68 base::Time GetLastActiveTime() const override { return last_active_time_; } | 68 base::TimeTicks GetLastActivityTime() const override { |
| 69 return last_activity_time_; |
| 70 } |
| 69 | 71 |
| 70 std::string GetId() const override { | 72 std::string GetId() const override { |
| 71 return base::IntToString(tab_id_); | 73 return base::IntToString(tab_id_); |
| 72 } | 74 } |
| 73 | 75 |
| 74 std::string GetType() const override { | 76 std::string GetType() const override { |
| 75 return devtools_discovery::BasicTargetDescriptor::kTypePage; | 77 return devtools_discovery::BasicTargetDescriptor::kTypePage; |
| 76 } | 78 } |
| 77 | 79 |
| 78 bool IsAttached() const override { | 80 bool IsAttached() const override { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 model->CloseTabAt(index); | 127 model->CloseTabAt(index); |
| 126 return true; | 128 return true; |
| 127 } | 129 } |
| 128 | 130 |
| 129 private: | 131 private: |
| 130 TabDescriptor(int tab_id, WebContents* web_contents) | 132 TabDescriptor(int tab_id, WebContents* web_contents) |
| 131 : tab_id_(tab_id), | 133 : tab_id_(tab_id), |
| 132 title_(base::UTF16ToUTF8(web_contents->GetTitle())), | 134 title_(base::UTF16ToUTF8(web_contents->GetTitle())), |
| 133 url_(web_contents->GetURL()), | 135 url_(web_contents->GetURL()), |
| 134 favicon_url_(CalculateFaviconURL()), | 136 favicon_url_(CalculateFaviconURL()), |
| 135 last_active_time_(web_contents->GetLastActiveTime()) {} | 137 last_activity_time_(web_contents->GetLastActiveTime()) { |
| 138 } |
| 136 | 139 |
| 137 TabDescriptor(int tab_id, const base::string16& title, const GURL& url) | 140 TabDescriptor(int tab_id, const base::string16& title, const GURL& url) |
| 138 : tab_id_(tab_id), | 141 : tab_id_(tab_id), |
| 139 title_(base::UTF16ToUTF8(title)), | 142 title_(base::UTF16ToUTF8(title)), |
| 140 url_(url), | 143 url_(url), |
| 141 favicon_url_(CalculateFaviconURL()) { | 144 favicon_url_(CalculateFaviconURL()) { |
| 142 } | 145 } |
| 143 | 146 |
| 144 GURL CalculateFaviconURL() { | 147 GURL CalculateFaviconURL() { |
| 145 TabModel* model; | 148 TabModel* model; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 184 } |
| 182 } | 185 } |
| 183 } | 186 } |
| 184 return false; | 187 return false; |
| 185 } | 188 } |
| 186 | 189 |
| 187 const int tab_id_; | 190 const int tab_id_; |
| 188 const std::string title_; | 191 const std::string title_; |
| 189 const GURL url_; | 192 const GURL url_; |
| 190 const GURL favicon_url_; | 193 const GURL favicon_url_; |
| 191 const base::Time last_active_time_; | 194 const base::TimeTicks last_activity_time_; |
| 192 | 195 |
| 193 DISALLOW_COPY_AND_ASSIGN(TabDescriptor); | 196 DISALLOW_COPY_AND_ASSIGN(TabDescriptor); |
| 194 }; | 197 }; |
| 195 | 198 |
| 196 scoped_ptr<devtools_discovery::DevToolsTargetDescriptor> | 199 scoped_ptr<devtools_discovery::DevToolsTargetDescriptor> |
| 197 CreateNewAndroidTab(const GURL& url) { | 200 CreateNewAndroidTab(const GURL& url) { |
| 198 if (TabModelList::empty()) | 201 if (TabModelList::empty()) |
| 199 return scoped_ptr<devtools_discovery::DevToolsTargetDescriptor>(); | 202 return scoped_ptr<devtools_discovery::DevToolsTargetDescriptor>(); |
| 200 | 203 |
| 201 TabModel* tab_model = TabModelList::get(0); | 204 TabModel* tab_model = TabModelList::get(0); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 266 } |
| 264 | 267 |
| 265 // static | 268 // static |
| 266 void DevToolsDiscoveryProviderAndroid::Install() { | 269 void DevToolsDiscoveryProviderAndroid::Install() { |
| 267 devtools_discovery::DevToolsDiscoveryManager* discovery_manager = | 270 devtools_discovery::DevToolsDiscoveryManager* discovery_manager = |
| 268 devtools_discovery::DevToolsDiscoveryManager::GetInstance(); | 271 devtools_discovery::DevToolsDiscoveryManager::GetInstance(); |
| 269 discovery_manager->AddProvider( | 272 discovery_manager->AddProvider( |
| 270 make_scoped_ptr(new DevToolsDiscoveryProviderAndroid())); | 273 make_scoped_ptr(new DevToolsDiscoveryProviderAndroid())); |
| 271 discovery_manager->SetCreateCallback(base::Bind(&CreateNewAndroidTab)); | 274 discovery_manager->SetCreateCallback(base::Bind(&CreateNewAndroidTab)); |
| 272 } | 275 } |
| OLD | NEW |