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

Side by Side Diff: chrome/browser/extensions/tab_helper.cc

Issue 23007021: Report Javascript Runtime Errors to the Error Console (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dc_ec_feldman
Patch Set: Created 7 years, 3 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 (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/extensions/tab_helper.h" 5 #include "chrome/browser/extensions/tab_helper.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h" 7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/activity_log/activity_log.h" 8 #include "chrome/browser/extensions/activity_log/activity_log.h"
9 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" 9 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h"
10 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist ry.h" 10 #include "chrome/browser/extensions/api/declarative_content/content_rules_regist ry.h"
11 #include "chrome/browser/extensions/crx_installer.h" 11 #include "chrome/browser/extensions/crx_installer.h"
12 #include "chrome/browser/extensions/error_console/error_console.h"
12 #include "chrome/browser/extensions/extension_action.h" 13 #include "chrome/browser/extensions/extension_action.h"
13 #include "chrome/browser/extensions/extension_action_manager.h" 14 #include "chrome/browser/extensions/extension_action_manager.h"
14 #include "chrome/browser/extensions/extension_service.h" 15 #include "chrome/browser/extensions/extension_service.h"
15 #include "chrome/browser/extensions/extension_system.h" 16 #include "chrome/browser/extensions/extension_system.h"
16 #include "chrome/browser/extensions/extension_tab_util.h" 17 #include "chrome/browser/extensions/extension_tab_util.h"
17 #include "chrome/browser/extensions/image_loader.h" 18 #include "chrome/browser/extensions/image_loader.h"
18 #include "chrome/browser/extensions/page_action_controller.h" 19 #include "chrome/browser/extensions/page_action_controller.h"
19 #include "chrome/browser/extensions/script_badge_controller.h" 20 #include "chrome/browser/extensions/script_badge_controller.h"
20 #include "chrome/browser/extensions/script_bubble_controller.h" 21 #include "chrome/browser/extensions/script_bubble_controller.h"
21 #include "chrome/browser/extensions/script_executor.h" 22 #include "chrome/browser/extensions/script_executor.h"
(...skipping 16 matching lines...) Expand all
38 #include "content/public/browser/navigation_details.h" 39 #include "content/public/browser/navigation_details.h"
39 #include "content/public/browser/navigation_entry.h" 40 #include "content/public/browser/navigation_entry.h"
40 #include "content/public/browser/notification_service.h" 41 #include "content/public/browser/notification_service.h"
41 #include "content/public/browser/notification_source.h" 42 #include "content/public/browser/notification_source.h"
42 #include "content/public/browser/notification_types.h" 43 #include "content/public/browser/notification_types.h"
43 #include "content/public/browser/render_process_host.h" 44 #include "content/public/browser/render_process_host.h"
44 #include "content/public/browser/render_view_host.h" 45 #include "content/public/browser/render_view_host.h"
45 #include "content/public/browser/render_widget_host_view.h" 46 #include "content/public/browser/render_widget_host_view.h"
46 #include "content/public/browser/web_contents.h" 47 #include "content/public/browser/web_contents.h"
47 #include "content/public/browser/web_contents_view.h" 48 #include "content/public/browser/web_contents_view.h"
49 #include "extensions/browser/extension_error.h"
50 #include "extensions/common/constants.h"
48 #include "extensions/common/extension_resource.h" 51 #include "extensions/common/extension_resource.h"
49 #include "ui/gfx/image/image.h" 52 #include "ui/gfx/image/image.h"
50 53
51 using content::NavigationController; 54 using content::NavigationController;
52 using content::NavigationEntry; 55 using content::NavigationEntry;
53 using content::RenderViewHost; 56 using content::RenderViewHost;
54 using content::WebContents; 57 using content::WebContents;
55 58
56 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::TabHelper); 59 DEFINE_WEB_CONTENTS_USER_DATA_KEY(extensions::TabHelper);
57 60
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 WebContents* new_web_contents) { 249 WebContents* new_web_contents) {
247 // When the WebContents that this is attached to is cloned, give the new clone 250 // When the WebContents that this is attached to is cloned, give the new clone
248 // a TabHelper and copy state over. 251 // a TabHelper and copy state over.
249 CreateForWebContents(new_web_contents); 252 CreateForWebContents(new_web_contents);
250 TabHelper* new_helper = FromWebContents(new_web_contents); 253 TabHelper* new_helper = FromWebContents(new_web_contents);
251 254
252 new_helper->SetExtensionApp(extension_app()); 255 new_helper->SetExtensionApp(extension_app());
253 new_helper->extension_app_icon_ = extension_app_icon_; 256 new_helper->extension_app_icon_ = extension_app_icon_;
254 } 257 }
255 258
259 void TabHelper::OnMessageAddedToConsole(const base::string16& source,
260 const base::string16& message,
261 const base::string16& stack_trace,
262 int32 line_number,
263 logging::LogSeverity level) {
264 if (IsSourceFromAnExtension(source)) {
265 ErrorConsole::Get(profile_)->ReportError(
266 scoped_ptr<const ExtensionError>(new JavascriptRuntimeError(
267 profile_->IsOffTheRecord(),
268 source,
269 message,
270 stack_trace,
271 line_number,
272 web_contents() ?
273 web_contents()->GetLastCommittedURL() : GURL::EmptyGURL(),
274 level)));
275 }
276 }
256 277
257 void TabHelper::OnDidGetApplicationInfo(int32 page_id, 278 void TabHelper::OnDidGetApplicationInfo(int32 page_id,
258 const WebApplicationInfo& info) { 279 const WebApplicationInfo& info) {
259 // Android does not implement BrowserWindow. 280 // Android does not implement BrowserWindow.
260 #if !defined(OS_MACOSX) && !defined(OS_ANDROID) 281 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
261 web_app_info_ = info; 282 web_app_info_ = info;
262 283
263 NavigationEntry* entry = 284 NavigationEntry* entry =
264 web_contents()->GetController().GetLastCommittedEntry(); 285 web_contents()->GetController().GetLastCommittedEntry();
265 if (!entry || (entry->GetPageID() != page_id)) 286 if (!entry || (entry->GetPageID() != page_id))
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 } 474 }
454 } 475 }
455 476
456 void TabHelper::SetTabId(RenderViewHost* render_view_host) { 477 void TabHelper::SetTabId(RenderViewHost* render_view_host) {
457 render_view_host->Send( 478 render_view_host->Send(
458 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), 479 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(),
459 SessionID::IdForTab(web_contents()))); 480 SessionID::IdForTab(web_contents())));
460 } 481 }
461 482
462 } // namespace extensions 483 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698