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