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/ui/unload_controller.h" | 5 #include "chrome/browser/ui/unload_controller.h" |
6 | 6 |
7 #include "base/location.h" | 7 #include "base/location.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/devtools/devtools_window.h" | 11 #include "chrome/browser/devtools/devtools_window.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_tabstrip.h" | 13 #include "chrome/browser/ui/browser_tabstrip.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
16 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
17 #include "content/public/browser/notification_types.h" | 17 #include "content/public/browser/notification_types.h" |
18 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "extensions/features/features.h" |
20 | 21 |
21 #if defined (ENABLE_EXTENSIONS) | 22 #if BUILDFLAG(ENABLE_EXTENSIONS) |
22 #include "extensions/browser/extension_registry.h" | 23 #include "extensions/browser/extension_registry.h" |
23 #include "extensions/common/constants.h" | 24 #include "extensions/common/constants.h" |
24 #endif // (ENABLE_EXTENSIONS) | 25 #endif // (ENABLE_EXTENSIONS) |
25 | 26 |
26 namespace chrome { | 27 namespace chrome { |
27 | 28 |
28 //////////////////////////////////////////////////////////////////////////////// | 29 //////////////////////////////////////////////////////////////////////////////// |
29 // UnloadController, public: | 30 // UnloadController, public: |
30 | 31 |
31 UnloadController::UnloadController(Browser* browser) | 32 UnloadController::UnloadController(Browser* browser) |
(...skipping 17 matching lines...) Expand all Loading... |
49 } | 50 } |
50 | 51 |
51 bool UnloadController::ShouldRunUnloadEventsHelper( | 52 bool UnloadController::ShouldRunUnloadEventsHelper( |
52 content::WebContents* contents) { | 53 content::WebContents* contents) { |
53 // If |contents| is being inspected, devtools needs to intercept beforeunload | 54 // If |contents| is being inspected, devtools needs to intercept beforeunload |
54 // events. | 55 // events. |
55 return DevToolsWindow::GetInstanceForInspectedWebContents(contents) != NULL; | 56 return DevToolsWindow::GetInstanceForInspectedWebContents(contents) != NULL; |
56 } | 57 } |
57 | 58 |
58 bool UnloadController::RunUnloadEventsHelper(content::WebContents* contents) { | 59 bool UnloadController::RunUnloadEventsHelper(content::WebContents* contents) { |
59 #if defined (ENABLE_EXTENSIONS) | 60 #if BUILDFLAG(ENABLE_EXTENSIONS) |
60 // Don't run for extensions that are disabled or uninstalled; the tabs will | 61 // Don't run for extensions that are disabled or uninstalled; the tabs will |
61 // be killed if they make any network requests, and the extension shouldn't | 62 // be killed if they make any network requests, and the extension shouldn't |
62 // be doing any work if it's removed. | 63 // be doing any work if it's removed. |
63 GURL url = contents->GetLastCommittedURL(); | 64 GURL url = contents->GetLastCommittedURL(); |
64 if (url.SchemeIs(extensions::kExtensionScheme) && | 65 if (url.SchemeIs(extensions::kExtensionScheme) && |
65 !extensions::ExtensionRegistry::Get(browser_->profile()) | 66 !extensions::ExtensionRegistry::Get(browser_->profile()) |
66 ->enabled_extensions() | 67 ->enabled_extensions() |
67 .GetExtensionOrAppByURL(url)) { | 68 .GetExtensionOrAppByURL(url)) { |
68 return false; | 69 return false; |
69 } | 70 } |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 ProcessPendingTabs(); | 380 ProcessPendingTabs(); |
380 } else { | 381 } else { |
381 base::ThreadTaskRunnerHandle::Get()->PostTask( | 382 base::ThreadTaskRunnerHandle::Get()->PostTask( |
382 FROM_HERE, base::Bind(&UnloadController::ProcessPendingTabs, | 383 FROM_HERE, base::Bind(&UnloadController::ProcessPendingTabs, |
383 weak_factory_.GetWeakPtr())); | 384 weak_factory_.GetWeakPtr())); |
384 } | 385 } |
385 } | 386 } |
386 } | 387 } |
387 | 388 |
388 } // namespace chrome | 389 } // namespace chrome |
OLD | NEW |