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/app_modal_dialogs/javascript_dialog_manager.h" | 5 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 #else | 51 #else |
52 return NULL; | 52 return NULL; |
53 #endif // defined(ENABLE_EXTENSIONS) | 53 #endif // defined(ENABLE_EXTENSIONS) |
54 } | 54 } |
55 | 55 |
56 // Keeps an |extension| from shutting down its lazy background page. If an | 56 // Keeps an |extension| from shutting down its lazy background page. If an |
57 // extension opens a dialog its lazy background page must stay alive until the | 57 // extension opens a dialog its lazy background page must stay alive until the |
58 // dialog closes. | 58 // dialog closes. |
59 void IncrementLazyKeepaliveCount(const Extension* extension, | 59 void IncrementLazyKeepaliveCount(const Extension* extension, |
60 WebContents* web_contents) { | 60 WebContents* web_contents) { |
61 #if defined(ENABLE_EXTENSIONS) | |
61 DCHECK(extension); | 62 DCHECK(extension); |
62 DCHECK(web_contents); | 63 DCHECK(web_contents); |
63 extensions::ProcessManager* pm = GetExtensionsProcessManager(web_contents); | 64 extensions::ProcessManager* pm = GetExtensionsProcessManager(web_contents); |
64 if (pm) | 65 if (pm) |
65 pm->IncrementLazyKeepaliveCount(extension); | 66 pm->IncrementLazyKeepaliveCount(extension); |
67 #endif // defined(ENABLE_EXTENSIONS) | |
msw
2014/08/22 22:21:50
nit: "// ENABLE_EXTENSIONS" would follow the more
David Yen
2014/08/22 22:28:25
Done. I went ahead and fixed all the other #endif
| |
66 } | 68 } |
67 | 69 |
68 // Allows an |extension| to shut down its lazy background page after a dialog | 70 // Allows an |extension| to shut down its lazy background page after a dialog |
69 // closes (if nothing else is keeping it open). | 71 // closes (if nothing else is keeping it open). |
70 void DecrementLazyKeepaliveCount(const Extension* extension, | 72 void DecrementLazyKeepaliveCount(const Extension* extension, |
71 WebContents* web_contents) { | 73 WebContents* web_contents) { |
74 #if defined(ENABLE_EXTENSIONS) | |
72 DCHECK(extension); | 75 DCHECK(extension); |
73 DCHECK(web_contents); | 76 DCHECK(web_contents); |
74 extensions::ProcessManager* pm = GetExtensionsProcessManager(web_contents); | 77 extensions::ProcessManager* pm = GetExtensionsProcessManager(web_contents); |
75 if (pm) | 78 if (pm) |
76 pm->DecrementLazyKeepaliveCount(extension); | 79 pm->DecrementLazyKeepaliveCount(extension); |
80 #endif // defined(ENABLE_EXTENSIONS) | |
77 } | 81 } |
78 | 82 |
79 class ChromeJavaScriptDialogManager : public JavaScriptDialogManager { | 83 class ChromeJavaScriptDialogManager : public JavaScriptDialogManager { |
80 public: | 84 public: |
81 static ChromeJavaScriptDialogManager* GetInstance(); | 85 static ChromeJavaScriptDialogManager* GetInstance(); |
82 | 86 |
83 virtual void RunJavaScriptDialog( | 87 virtual void RunJavaScriptDialog( |
84 WebContents* web_contents, | 88 WebContents* web_contents, |
85 const GURL& origin_url, | 89 const GURL& origin_url, |
86 const std::string& accept_lang, | 90 const std::string& accept_lang, |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 DecrementLazyKeepaliveCount(extension, web_contents); | 317 DecrementLazyKeepaliveCount(extension, web_contents); |
314 | 318 |
315 callback.Run(success, user_input); | 319 callback.Run(success, user_input); |
316 } | 320 } |
317 | 321 |
318 } // namespace | 322 } // namespace |
319 | 323 |
320 content::JavaScriptDialogManager* GetJavaScriptDialogManagerInstance() { | 324 content::JavaScriptDialogManager* GetJavaScriptDialogManagerInstance() { |
321 return ChromeJavaScriptDialogManager::GetInstance(); | 325 return ChromeJavaScriptDialogManager::GetInstance(); |
322 } | 326 } |
OLD | NEW |