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/android/dev_tools_server.h" | 5 #include "chrome/browser/android/dev_tools_server.h" |
6 | 6 |
7 #include <pwd.h> | 7 #include <pwd.h> |
8 #include <cstring> | 8 #include <cstring> |
9 | 9 |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 82 } |
83 | 83 |
84 protected: | 84 protected: |
85 explicit TargetBase(WebContents* web_contents) | 85 explicit TargetBase(WebContents* web_contents) |
86 : title_(UTF16ToUTF8(web_contents->GetTitle())), | 86 : title_(UTF16ToUTF8(web_contents->GetTitle())), |
87 url_(web_contents->GetURL()), | 87 url_(web_contents->GetURL()), |
88 favicon_url_(GetFaviconURL(web_contents)), | 88 favicon_url_(GetFaviconURL(web_contents)), |
89 last_activity_time_(web_contents->GetLastSelectedTime()) { | 89 last_activity_time_(web_contents->GetLastSelectedTime()) { |
90 } | 90 } |
91 | 91 |
92 TargetBase(const string16& title, const GURL& url) | 92 TargetBase(const base::string16& title, const GURL& url) |
93 : title_(UTF16ToUTF8(title)), | 93 : title_(UTF16ToUTF8(title)), |
94 url_(url) | 94 url_(url) |
95 {} | 95 {} |
96 | 96 |
97 private: | 97 private: |
98 const std::string title_; | 98 const std::string title_; |
99 const GURL url_; | 99 const GURL url_; |
100 const GURL favicon_url_; | 100 const GURL favicon_url_; |
101 const base::TimeTicks last_activity_time_; | 101 const base::TimeTicks last_activity_time_; |
102 }; | 102 }; |
103 | 103 |
104 class TabTarget : public TargetBase { | 104 class TabTarget : public TargetBase { |
105 public: | 105 public: |
106 static TabTarget* CreateForWebContents(int tab_id, | 106 static TabTarget* CreateForWebContents(int tab_id, |
107 WebContents* web_contents) { | 107 WebContents* web_contents) { |
108 return new TabTarget(tab_id, web_contents); | 108 return new TabTarget(tab_id, web_contents); |
109 } | 109 } |
110 | 110 |
111 static TabTarget* CreateForUnloadedTab(int tab_id, | 111 static TabTarget* CreateForUnloadedTab(int tab_id, |
112 const string16& title, | 112 const base::string16& title, |
113 const GURL& url) { | 113 const GURL& url) { |
114 return new TabTarget(tab_id, title, url); | 114 return new TabTarget(tab_id, title, url); |
115 } | 115 } |
116 | 116 |
117 // content::DevToolsTarget implementation: | 117 // content::DevToolsTarget implementation: |
118 virtual std::string GetId() const OVERRIDE { | 118 virtual std::string GetId() const OVERRIDE { |
119 return base::IntToString(tab_id_); | 119 return base::IntToString(tab_id_); |
120 } | 120 } |
121 | 121 |
122 virtual std::string GetType() const OVERRIDE { return kTargetTypePage; } | 122 virtual std::string GetType() const OVERRIDE { return kTargetTypePage; } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 model->CloseTabAt(index); | 167 model->CloseTabAt(index); |
168 return true; | 168 return true; |
169 } | 169 } |
170 | 170 |
171 private: | 171 private: |
172 TabTarget(int tab_id, WebContents* web_contents) | 172 TabTarget(int tab_id, WebContents* web_contents) |
173 : TargetBase(web_contents), | 173 : TargetBase(web_contents), |
174 tab_id_(tab_id) { | 174 tab_id_(tab_id) { |
175 } | 175 } |
176 | 176 |
177 TabTarget(int tab_id, const string16& title, const GURL& url) | 177 TabTarget(int tab_id, const base::string16& title, const GURL& url) |
178 : TargetBase(title, url), | 178 : TargetBase(title, url), |
179 tab_id_(tab_id) { | 179 tab_id_(tab_id) { |
180 } | 180 } |
181 | 181 |
182 bool FindTab(TabModel** model_result, int* index_result) const { | 182 bool FindTab(TabModel** model_result, int* index_result) const { |
183 for (TabModelList::const_iterator iter = TabModelList::begin(); | 183 for (TabModelList::const_iterator iter = TabModelList::begin(); |
184 iter != TabModelList::end(); ++iter) { | 184 iter != TabModelList::end(); ++iter) { |
185 TabModel* model = *iter; | 185 TabModel* model = *iter; |
186 for (int i = 0; i < model->GetTabCount(); ++i) { | 186 for (int i = 0; i < model->GetTabCount(); ++i) { |
187 TabAndroid* tab = model->GetTabAt(i); | 187 TabAndroid* tab = model->GetTabAt(i); |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 jobject obj, | 463 jobject obj, |
464 jint server, | 464 jint server, |
465 jboolean enabled) { | 465 jboolean enabled) { |
466 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); | 466 DevToolsServer* devtools_server = reinterpret_cast<DevToolsServer*>(server); |
467 if (enabled) { | 467 if (enabled) { |
468 devtools_server->Start(); | 468 devtools_server->Start(); |
469 } else { | 469 } else { |
470 devtools_server->Stop(); | 470 devtools_server->Stop(); |
471 } | 471 } |
472 } | 472 } |
OLD | NEW |