Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: chrome/browser/android/dev_tools_manager_delegate_android.cc

Issue 884213005: Update {virtual,override,final} to follow C++11 style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_manager_delegate_android.h" 5 #include "chrome/browser/android/dev_tools_manager_delegate_android.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 base::TimeTicks GetLastActiveTimeForAgentHost( 48 base::TimeTicks GetLastActiveTimeForAgentHost(
49 scoped_refptr<DevToolsAgentHost> agent_host) { 49 scoped_refptr<DevToolsAgentHost> agent_host) {
50 if (WebContents* web_contents = agent_host->GetWebContents()) 50 if (WebContents* web_contents = agent_host->GetWebContents())
51 return web_contents->GetLastActiveTime(); 51 return web_contents->GetLastActiveTime();
52 return base::TimeTicks(); 52 return base::TimeTicks();
53 } 53 }
54 54
55 class TargetBase : public content::DevToolsTarget { 55 class TargetBase : public content::DevToolsTarget {
56 public: 56 public:
57 // content::DevToolsTarget implementation: 57 // content::DevToolsTarget implementation:
58 virtual std::string GetParentId() const override { return std::string(); } 58 std::string GetParentId() const override { return std::string(); }
59 59
60 virtual std::string GetTitle() const override { return title_; } 60 std::string GetTitle() const override { return title_; }
61 61
62 virtual std::string GetDescription() const override { return std::string(); } 62 std::string GetDescription() const override { return std::string(); }
63 63
64 virtual GURL GetURL() const override { return url_; } 64 GURL GetURL() const override { return url_; }
65 65
66 virtual GURL GetFaviconURL() const override { return favicon_url_; } 66 GURL GetFaviconURL() const override { return favicon_url_; }
67 67
68 virtual base::TimeTicks GetLastActivityTime() const override { 68 base::TimeTicks GetLastActivityTime() const override {
69 return last_activity_time_; 69 return last_activity_time_;
70 } 70 }
71 71
72 protected: 72 protected:
73 explicit TargetBase(WebContents* web_contents) 73 explicit TargetBase(WebContents* web_contents)
74 : title_(base::UTF16ToUTF8(web_contents->GetTitle())), 74 : title_(base::UTF16ToUTF8(web_contents->GetTitle())),
75 url_(web_contents->GetURL()), 75 url_(web_contents->GetURL()),
76 favicon_url_(GetFaviconURLForContents(web_contents)), 76 favicon_url_(GetFaviconURLForContents(web_contents)),
77 last_activity_time_(web_contents->GetLastActiveTime()) { 77 last_activity_time_(web_contents->GetLastActiveTime()) {
78 } 78 }
(...skipping 24 matching lines...) Expand all
103 return new TabTarget(tab_id, web_contents); 103 return new TabTarget(tab_id, web_contents);
104 } 104 }
105 105
106 static TabTarget* CreateForUnloadedTab(int tab_id, 106 static TabTarget* CreateForUnloadedTab(int tab_id,
107 const base::string16& title, 107 const base::string16& title,
108 const GURL& url) { 108 const GURL& url) {
109 return new TabTarget(tab_id, title, url); 109 return new TabTarget(tab_id, title, url);
110 } 110 }
111 111
112 // content::DevToolsTarget implementation: 112 // content::DevToolsTarget implementation:
113 virtual std::string GetId() const override { 113 std::string GetId() const override { return base::IntToString(tab_id_); }
114 return base::IntToString(tab_id_);
115 }
116 114
117 virtual std::string GetType() const override { 115 std::string GetType() const override { return kTargetTypePage; }
118 return kTargetTypePage;
119 }
120 116
121 virtual bool IsAttached() const override { 117 bool IsAttached() const override {
122 TabModel* model; 118 TabModel* model;
123 int index; 119 int index;
124 if (!FindTab(&model, &index)) 120 if (!FindTab(&model, &index))
125 return false; 121 return false;
126 WebContents* web_contents = model->GetWebContentsAt(index); 122 WebContents* web_contents = model->GetWebContentsAt(index);
127 if (!web_contents) 123 if (!web_contents)
128 return false; 124 return false;
129 return DevToolsAgentHost::IsDebuggerAttached(web_contents); 125 return DevToolsAgentHost::IsDebuggerAttached(web_contents);
130 } 126 }
131 127
132 virtual scoped_refptr<DevToolsAgentHost> GetAgentHost() const override { 128 scoped_refptr<DevToolsAgentHost> GetAgentHost() const override {
133 TabModel* model; 129 TabModel* model;
134 int index; 130 int index;
135 if (!FindTab(&model, &index)) 131 if (!FindTab(&model, &index))
136 return NULL; 132 return NULL;
137 WebContents* web_contents = model->GetWebContentsAt(index); 133 WebContents* web_contents = model->GetWebContentsAt(index);
138 if (!web_contents) { 134 if (!web_contents) {
139 // The tab has been pushed out of memory, pull it back. 135 // The tab has been pushed out of memory, pull it back.
140 TabAndroid* tab = model->GetTabAt(index); 136 TabAndroid* tab = model->GetTabAt(index);
141 if (!tab) 137 if (!tab)
142 return NULL; 138 return NULL;
143 139
144 if (!tab->LoadIfNeeded()) 140 if (!tab->LoadIfNeeded())
145 return NULL; 141 return NULL;
146 142
147 web_contents = model->GetWebContentsAt(index); 143 web_contents = model->GetWebContentsAt(index);
148 if (!web_contents) 144 if (!web_contents)
149 return NULL; 145 return NULL;
150 } 146 }
151 return DevToolsAgentHost::GetOrCreateFor(web_contents); 147 return DevToolsAgentHost::GetOrCreateFor(web_contents);
152 } 148 }
153 149
154 virtual bool Activate() const override { 150 bool Activate() const override {
155 TabModel* model; 151 TabModel* model;
156 int index; 152 int index;
157 if (!FindTab(&model, &index)) 153 if (!FindTab(&model, &index))
158 return false; 154 return false;
159 model->SetActiveIndex(index); 155 model->SetActiveIndex(index);
160 return true; 156 return true;
161 } 157 }
162 158
163 virtual bool Close() const override { 159 bool Close() const override {
164 TabModel* model; 160 TabModel* model;
165 int index; 161 int index;
166 if (!FindTab(&model, &index)) 162 if (!FindTab(&model, &index))
167 return false; 163 return false;
168 model->CloseTabAt(index); 164 model->CloseTabAt(index);
169 return true; 165 return true;
170 } 166 }
171 167
172 private: 168 private:
173 TabTarget(int tab_id, WebContents* web_contents) 169 TabTarget(int tab_id, WebContents* web_contents)
(...skipping 26 matching lines...) Expand all
200 }; 196 };
201 197
202 class NonTabTarget : public TargetBase { 198 class NonTabTarget : public TargetBase {
203 public: 199 public:
204 explicit NonTabTarget(scoped_refptr<DevToolsAgentHost> agent_host) 200 explicit NonTabTarget(scoped_refptr<DevToolsAgentHost> agent_host)
205 : TargetBase(agent_host), 201 : TargetBase(agent_host),
206 agent_host_(agent_host) { 202 agent_host_(agent_host) {
207 } 203 }
208 204
209 // content::DevToolsTarget implementation: 205 // content::DevToolsTarget implementation:
210 virtual std::string GetId() const override { 206 std::string GetId() const override { return agent_host_->GetId(); }
211 return agent_host_->GetId();
212 }
213 207
214 virtual std::string GetType() const override { 208 std::string GetType() const override {
215 switch (agent_host_->GetType()) { 209 switch (agent_host_->GetType()) {
216 case DevToolsAgentHost::TYPE_WEB_CONTENTS: 210 case DevToolsAgentHost::TYPE_WEB_CONTENTS:
217 if (TabModelList::begin() == TabModelList::end()) { 211 if (TabModelList::begin() == TabModelList::end()) {
218 // If there are no tab models we must be running in ChromeShell. 212 // If there are no tab models we must be running in ChromeShell.
219 // Return the 'page' target type for backwards compatibility. 213 // Return the 'page' target type for backwards compatibility.
220 return kTargetTypePage; 214 return kTargetTypePage;
221 } 215 }
222 break; 216 break;
223 case DevToolsAgentHost::TYPE_SERVICE_WORKER: 217 case DevToolsAgentHost::TYPE_SERVICE_WORKER:
224 return kTargetTypeServiceWorker; 218 return kTargetTypeServiceWorker;
225 default: 219 default:
226 break; 220 break;
227 } 221 }
228 return kTargetTypeOther; 222 return kTargetTypeOther;
229 } 223 }
230 224
231 virtual bool IsAttached() const override { 225 bool IsAttached() const override { return agent_host_->IsAttached(); }
232 return agent_host_->IsAttached();
233 }
234 226
235 virtual scoped_refptr<DevToolsAgentHost> GetAgentHost() const override { 227 scoped_refptr<DevToolsAgentHost> GetAgentHost() const override {
236 return agent_host_; 228 return agent_host_;
237 } 229 }
238 230
239 virtual bool Activate() const override { 231 bool Activate() const override { return agent_host_->Activate(); }
240 return agent_host_->Activate();
241 }
242 232
243 virtual bool Close() const override { 233 bool Close() const override { return agent_host_->Close(); }
244 return agent_host_->Close();
245 }
246 234
247 private: 235 private:
248 scoped_refptr<DevToolsAgentHost> agent_host_; 236 scoped_refptr<DevToolsAgentHost> agent_host_;
249 }; 237 };
250 238
251 } // namespace 239 } // namespace
252 240
253 DevToolsManagerDelegateAndroid::DevToolsManagerDelegateAndroid() 241 DevToolsManagerDelegateAndroid::DevToolsManagerDelegateAndroid()
254 : network_protocol_handler_(new DevToolsNetworkProtocolHandler()) { 242 : network_protocol_handler_(new DevToolsNetworkProtocolHandler()) {
255 } 243 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 Profile* profile = ProfileManager::GetLastUsedProfile()->GetOriginalProfile(); 328 Profile* profile = ProfileManager::GetLastUsedProfile()->GetOriginalProfile();
341 scoped_refptr<history::TopSites> top_sites = 329 scoped_refptr<history::TopSites> top_sites =
342 TopSitesFactory::GetForProfile(profile); 330 TopSitesFactory::GetForProfile(profile);
343 if (top_sites) { 331 if (top_sites) {
344 scoped_refptr<base::RefCountedMemory> data; 332 scoped_refptr<base::RefCountedMemory> data;
345 if (top_sites->GetPageThumbnail(url, false, &data)) 333 if (top_sites->GetPageThumbnail(url, false, &data))
346 return std::string(data->front_as<char>(), data->size()); 334 return std::string(data->front_as<char>(), data->size());
347 } 335 }
348 return std::string(); 336 return std::string();
349 } 337 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698