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

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

Issue 11411308: Enable script bubble by default on all but mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Everything passes Created 8 years 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 "chrome/browser/extensions/tab_helper.h" 5 #include "chrome/browser/extensions/tab_helper.h"
6 6
7 #include "chrome/browser/extensions/activity_log.h" 7 #include "chrome/browser/extensions/activity_log.h"
8 #include "chrome/browser/extensions/app_notify_channel_ui.h" 8 #include "chrome/browser/extensions/app_notify_channel_ui.h"
9 #include "chrome/browser/extensions/crx_installer.h" 9 #include "chrome/browser/extensions/crx_installer.h"
10 #include "chrome/browser/extensions/extension_action.h" 10 #include "chrome/browser/extensions/extension_action.h"
11 #include "chrome/browser/extensions/extension_action_manager.h" 11 #include "chrome/browser/extensions/extension_action_manager.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/extension_tab_util.h" 13 #include "chrome/browser/extensions/extension_tab_util.h"
14 #include "chrome/browser/extensions/page_action_controller.h" 14 #include "chrome/browser/extensions/page_action_controller.h"
15 #include "chrome/browser/extensions/script_badge_controller.h" 15 #include "chrome/browser/extensions/script_badge_controller.h"
16 #include "chrome/browser/extensions/script_bubble_controller.h" 16 #include "chrome/browser/extensions/script_bubble_controller.h"
17 #include "chrome/browser/extensions/script_executor.h" 17 #include "chrome/browser/extensions/script_executor.h"
18 #include "chrome/browser/extensions/webstore_standalone_installer.h" 18 #include "chrome/browser/extensions/webstore_standalone_installer.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/sessions/session_id.h" 20 #include "chrome/browser/sessions/session_id.h"
21 #include "chrome/browser/sessions/session_tab_helper.h" 21 #include "chrome/browser/sessions/session_tab_helper.h"
22 #include "chrome/browser/ui/browser_dialogs.h" 22 #include "chrome/browser/ui/browser_dialogs.h"
23 #include "chrome/browser/ui/tab_contents/tab_contents.h" 23 #include "chrome/browser/ui/tab_contents/tab_contents.h"
24 #include "chrome/browser/ui/web_applications/web_app_ui.h" 24 #include "chrome/browser/ui/web_applications/web_app_ui.h"
25 #include "chrome/browser/web_applications/web_app.h" 25 #include "chrome/browser/web_applications/web_app.h"
26 #include "chrome/common/chrome_notification_types.h" 26 #include "chrome/common/chrome_notification_types.h"
27 #include "chrome/common/extensions/extension.h"
27 #include "chrome/common/extensions/extension_constants.h" 28 #include "chrome/common/extensions/extension_constants.h"
28 #include "chrome/common/extensions/extension_icon_set.h" 29 #include "chrome/common/extensions/extension_icon_set.h"
29 #include "chrome/common/extensions/extension_messages.h" 30 #include "chrome/common/extensions/extension_messages.h"
30 #include "chrome/common/extensions/extension_resource.h" 31 #include "chrome/common/extensions/extension_resource.h"
31 #include "chrome/common/extensions/feature_switch.h" 32 #include "chrome/common/extensions/feature_switch.h"
32 #include "content/public/browser/invalidate_type.h" 33 #include "content/public/browser/invalidate_type.h"
33 #include "content/public/browser/navigation_controller.h" 34 #include "content/public/browser/navigation_controller.h"
34 #include "content/public/browser/navigation_details.h" 35 #include "content/public/browser/navigation_details.h"
35 #include "content/public/browser/navigation_entry.h" 36 #include "content/public/browser/navigation_entry.h"
36 #include "content/public/browser/notification_service.h" 37 #include "content/public/browser/notification_service.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 105 }
105 106
106 // If more classes need to listen to global content script activity, then 107 // If more classes need to listen to global content script activity, then
107 // a separate routing class with an observer interface should be written. 108 // a separate routing class with an observer interface should be written.
108 AddScriptExecutionObserver(ActivityLog::GetInstance()); 109 AddScriptExecutionObserver(ActivityLog::GetInstance());
109 110
110 registrar_.Add(this, 111 registrar_.Add(this,
111 content::NOTIFICATION_LOAD_STOP, 112 content::NOTIFICATION_LOAD_STOP,
112 content::Source<NavigationController>( 113 content::Source<NavigationController>(
113 &web_contents->GetController())); 114 &web_contents->GetController()));
115
116 registrar_.Add(this,
117 chrome::NOTIFICATION_EXTENSION_UNLOADED,
118 content::NotificationService::AllSources());
114 } 119 }
115 120
116 TabHelper::~TabHelper() { 121 TabHelper::~TabHelper() {
117 RemoveScriptExecutionObserver(ActivityLog::GetInstance()); 122 RemoveScriptExecutionObserver(ActivityLog::GetInstance());
118 } 123 }
119 124
120 void TabHelper::CreateApplicationShortcuts() { 125 void TabHelper::CreateApplicationShortcuts() {
121 DCHECK(CanCreateApplicationShortcuts()); 126 DCHECK(CanCreateApplicationShortcuts());
122 NavigationEntry* entry = 127 NavigationEntry* entry =
123 web_contents()->GetController().GetLastCommittedEntry(); 128 web_contents()->GetController().GetLastCommittedEntry();
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 return web_contents(); 482 return web_contents();
478 } 483 }
479 484
480 void TabHelper::GetApplicationInfo(int32 page_id) { 485 void TabHelper::GetApplicationInfo(int32 page_id) {
481 Send(new ExtensionMsg_GetApplicationInfo(routing_id(), page_id)); 486 Send(new ExtensionMsg_GetApplicationInfo(routing_id(), page_id));
482 } 487 }
483 488
484 void TabHelper::Observe(int type, 489 void TabHelper::Observe(int type,
485 const content::NotificationSource& source, 490 const content::NotificationSource& source,
486 const content::NotificationDetails& details) { 491 const content::NotificationDetails& details) {
487 DCHECK(type == content::NOTIFICATION_LOAD_STOP); 492 switch (type) {
488 const NavigationController& controller = 493 case content::NOTIFICATION_LOAD_STOP: {
489 *content::Source<NavigationController>(source).ptr(); 494 const NavigationController& controller =
490 DCHECK_EQ(controller.GetWebContents(), web_contents()); 495 *content::Source<NavigationController>(source).ptr();
496 DCHECK_EQ(controller.GetWebContents(), web_contents());
491 497
492 if (pending_web_app_action_ == UPDATE_SHORTCUT) { 498 if (pending_web_app_action_ == UPDATE_SHORTCUT) {
493 // Schedule a shortcut update when web application info is available if 499 // Schedule a shortcut update when web application info is available if
494 // last committed entry is not NULL. Last committed entry could be NULL 500 // last committed entry is not NULL. Last committed entry could be NULL
495 // when an interstitial page is injected (e.g. bad https certificate, 501 // when an interstitial page is injected (e.g. bad https certificate,
496 // malware site etc). When this happens, we abort the shortcut update. 502 // malware site etc). When this happens, we abort the shortcut update.
497 NavigationEntry* entry = controller.GetLastCommittedEntry(); 503 NavigationEntry* entry = controller.GetLastCommittedEntry();
498 if (entry) 504 if (entry)
499 GetApplicationInfo(entry->GetPageID()); 505 GetApplicationInfo(entry->GetPageID());
500 else 506 else
501 pending_web_app_action_ = NONE; 507 pending_web_app_action_ = NONE;
508 }
509 break;
510 }
511
512 case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
513 if (script_bubble_controller_.get()) {
514 script_bubble_controller_->OnExtensionUnloaded(
515 content::Details<extensions::UnloadedExtensionInfo>(
516 details)->extension->id());
517 break;
518 }
519 }
502 } 520 }
503 } 521 }
504 522
505 } // namespace extensions 523 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698