Don't preload rarely seen large images
[chromium-blink-merge.git] / components / app_modal / javascript_dialog_manager.h
blob7978cddbcadbe91a7f51c065eb5dc1ce582b0058
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_
6 #define COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/singleton.h"
10 #include "components/app_modal/javascript_app_modal_dialog.h"
11 #include "content/public/browser/javascript_dialog_manager.h"
13 namespace app_modal {
15 class JavaScriptDialogExtensionsClient;
16 class JavaScriptNativeDialogFactory;
18 class JavaScriptDialogManager : public content::JavaScriptDialogManager {
19 public:
20 static JavaScriptDialogManager* GetInstance();
22 JavaScriptNativeDialogFactory* native_dialog_factory() {
23 return native_dialog_factory_.get();
26 // Sets the JavaScriptNativeDialogFactory used to create platform specific
27 // dialog window instances.
28 void SetNativeDialogFactory(
29 scoped_ptr<JavaScriptNativeDialogFactory> factory);
31 // JavaScript dialogs may be opened by an extensions/app, thus they need
32 // access to extensions functionality. This sets a client interface to
33 // access //extensions.
34 void SetExtensionsClient(
35 scoped_ptr<JavaScriptDialogExtensionsClient> extensions_client);
37 private:
38 friend struct DefaultSingletonTraits<JavaScriptDialogManager>;
40 JavaScriptDialogManager();
41 ~JavaScriptDialogManager() override;
43 // JavaScriptDialogManager:
44 void RunJavaScriptDialog(content::WebContents* web_contents,
45 const GURL& origin_url,
46 const std::string& accept_lang,
47 content::JavaScriptMessageType message_type,
48 const base::string16& message_text,
49 const base::string16& default_prompt_text,
50 const DialogClosedCallback& callback,
51 bool* did_suppress_message) override;
52 void RunBeforeUnloadDialog(content::WebContents* web_contents,
53 const base::string16& message_text,
54 bool is_reload,
55 const DialogClosedCallback& callback) override;
56 bool HandleJavaScriptDialog(content::WebContents* web_contents,
57 bool accept,
58 const base::string16* prompt_override) override;
59 void CancelActiveAndPendingDialogs(
60 content::WebContents* web_contents) override;
61 void ResetDialogState(content::WebContents* web_contents) override;
63 base::string16 GetTitle(content::WebContents* web_contents,
64 const GURL& origin_url,
65 const std::string& accept_lang,
66 bool is_alert);
68 // Wrapper around a DialogClosedCallback so that we can intercept it before
69 // passing it onto the original callback.
70 void OnDialogClosed(content::WebContents* web_contents,
71 DialogClosedCallback callback,
72 bool success,
73 const base::string16& user_input);
75 // Mapping between the WebContents and their extra data. The key
76 // is a void* because the pointer is just a cookie and is never dereferenced.
77 JavaScriptAppModalDialog::ExtraDataMap javascript_dialog_extra_data_;
79 scoped_ptr<JavaScriptNativeDialogFactory> native_dialog_factory_;
80 scoped_ptr<JavaScriptDialogExtensionsClient> extensions_client_;
82 DISALLOW_COPY_AND_ASSIGN(JavaScriptDialogManager);
85 } // namespace app_modal
87 #endif // COMPONENTS_APP_MODAL_JAVASCRIPT_DIALOG_MANAGER_H_