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

Side by Side Diff: content/shell/shell.cc

Issue 10837177: Add a menu item to content_shell to open devtools to make it more discoverable. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix android compile, and add gtk support Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
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 "content/shell/shell.h" 5 #include "content/shell/shell.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/string_number_conversions.h"
11 #include "base/string_util.h" 12 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "content/public/browser/devtools_http_handler.h"
13 #include "content/public/browser/navigation_entry.h" 15 #include "content/public/browser/navigation_entry.h"
14 #include "content/public/browser/navigation_controller.h" 16 #include "content/public/browser/navigation_controller.h"
15 #include "content/public/browser/notification_details.h" 17 #include "content/public/browser/notification_details.h"
16 #include "content/public/browser/notification_source.h" 18 #include "content/public/browser/notification_source.h"
17 #include "content/public/browser/notification_types.h" 19 #include "content/public/browser/notification_types.h"
18 #include "content/public/browser/render_view_host.h" 20 #include "content/public/browser/render_view_host.h"
19 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "content/shell/shell_browser_main_parts.h"
23 #include "content/shell/shell_content_browser_client.h"
24 #include "content/shell/shell_devtools_delegate.h"
20 #include "content/shell/shell_javascript_dialog_creator.h" 25 #include "content/shell/shell_javascript_dialog_creator.h"
21 #include "content/shell/shell_messages.h" 26 #include "content/shell/shell_messages.h"
22 #include "content/shell/shell_switches.h" 27 #include "content/shell/shell_switches.h"
23 #include "ui/gfx/size.h" 28 #include "ui/gfx/size.h"
24 29
25 // Content area size for newly created windows. 30 // Content area size for newly created windows.
26 static const int kTestWindowWidth = 800; 31 static const int kTestWindowWidth = 800;
27 static const int kTestWindowHeight = 600; 32 static const int kTestWindowHeight = 600;
28 33
29 namespace content { 34 namespace content {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 149
145 void Shell::UpdateNavigationControls() { 150 void Shell::UpdateNavigationControls() {
146 int current_index = web_contents_->GetController().GetCurrentEntryIndex(); 151 int current_index = web_contents_->GetController().GetCurrentEntryIndex();
147 int max_index = web_contents_->GetController().GetEntryCount() - 1; 152 int max_index = web_contents_->GetController().GetEntryCount() - 1;
148 153
149 PlatformEnableUIControl(BACK_BUTTON, current_index > 0); 154 PlatformEnableUIControl(BACK_BUTTON, current_index > 0);
150 PlatformEnableUIControl(FORWARD_BUTTON, current_index < max_index); 155 PlatformEnableUIControl(FORWARD_BUTTON, current_index < max_index);
151 PlatformEnableUIControl(STOP_BUTTON, web_contents_->IsLoading()); 156 PlatformEnableUIControl(STOP_BUTTON, web_contents_->IsLoading());
152 } 157 }
153 158
159 void Shell::ShowDevTools() {
160 ShellContentBrowserClient* browser_client =
161 static_cast<ShellContentBrowserClient*>(
162 GetContentClient()->browser());
163 ShellDevToolsDelegate* delegate =
164 browser_client->shell_browser_main_parts()->devtools_delegate();
165 GURL url = delegate->devtools_http_handler()->GetFrontendURL(
166 web_contents()->GetRenderViewHost());
167 CreateNewWindow(
168 web_contents()->GetBrowserContext(),
169 url, NULL, MSG_ROUTING_NONE, NULL);
170 }
171
154 gfx::NativeView Shell::GetContentView() { 172 gfx::NativeView Shell::GetContentView() {
155 if (!web_contents_.get()) 173 if (!web_contents_.get())
156 return NULL; 174 return NULL;
157 return web_contents_->GetNativeView(); 175 return web_contents_->GetNativeView();
158 } 176 }
159 177
160 WebContents* Shell::OpenURLFromTab(WebContents* source, 178 WebContents* Shell::OpenURLFromTab(WebContents* source,
161 const OpenURLParams& params) { 179 const OpenURLParams& params) {
162 // The only one we implement for now. 180 // The only one we implement for now.
163 DCHECK(params.disposition == CURRENT_TAB); 181 DCHECK(params.disposition == CURRENT_TAB);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 Details<std::pair<NavigationEntry*, bool> >(details).ptr(); 233 Details<std::pair<NavigationEntry*, bool> >(details).ptr();
216 234
217 if (title->first) { 235 if (title->first) {
218 string16 text = title->first->GetTitle(); 236 string16 text = title->first->GetTitle();
219 PlatformSetTitle(text); 237 PlatformSetTitle(text);
220 } 238 }
221 } 239 }
222 } 240 }
223 241
224 } // namespace content 242 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698