Clean up extension confirmation prompts and make them consistent between Views and...
[chromium-blink-merge.git] / components / html_viewer / setup.h
blob305ef14dcb1e9341d72d1dcd21c84e6e3c2ff2f8
1 // Copyright 2015 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_HTML_VIEWER_SETUP_H_
6 #define COMPONENTS_HTML_VIEWER_SETUP_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/threading/thread.h"
11 #include "components/html_viewer/discardable_memory_allocator.h"
12 #include "components/resource_provider/public/cpp/resource_loader.h"
13 #include "ui/gfx/geometry/size.h"
15 namespace mojo {
16 class ApplicationImpl;
17 class Shell;
20 namespace scheduler {
21 class RendererScheduler;
24 namespace html_viewer {
26 class BlinkPlatformImpl;
27 class UISetup;
28 class MediaFactory;
30 // Setup encapsulates the necessary state needed by HTMLViewer. Some objects
31 // are created immediately in the constructor, otherwise not until
32 // InitIfNecessary() is invoked.
33 // Setup can be initialized in two distinct ways:
34 // . headless: this is determined by the command line, but can be forced by way
35 // of InitHeadless().
36 // . with a ui: this is done via InitIfNecessary().
37 class Setup {
38 public:
39 explicit Setup(mojo::ApplicationImpl* app);
40 ~Setup();
42 // Inits with the specified screen size and device pixel ratio.
43 // NOTE: we wait to complete setup until the device pixel ratio is available
44 // as ResourceBundle uses the device pixel ratio during initialization.
45 void InitIfNecessary(const gfx::Size& screen_size_in_pixels,
46 float device_pixel_ratio);
48 bool is_headless() const { return is_headless_; }
49 bool did_init() const { return did_init_; }
51 const gfx::Size& screen_size_in_pixels() const {
52 return screen_size_in_pixels_;
55 float device_pixel_ratio() const { return device_pixel_ratio_; }
57 scoped_refptr<base::SingleThreadTaskRunner> compositor_thread() {
58 return compositor_thread_.task_runner();
61 MediaFactory* media_factory() { return media_factory_.get(); }
63 private:
64 // App for HTMLViewer, not the document's app.
65 // WARNING: do not expose this. It's too easy to use the wrong one.
66 // HTMLDocument should be using the application it creates, not this one.
67 mojo::ApplicationImpl* app_;
69 resource_provider::ResourceLoader resource_loader_;
71 const bool is_headless_;
73 // True once we've completed init.
74 bool did_init_;
76 float device_pixel_ratio_;
78 gfx::Size screen_size_in_pixels_;
80 scoped_ptr<UISetup> ui_setup_;
82 // Skia requires that we have one of these. Unlike the one used in chrome,
83 // this doesn't use purgable shared memory. Instead, it tries to free the
84 // oldest unlocked chunks on allocation.
86 // TODO(erg): In the long run, delete this allocator and get the real shared
87 // memory based purging allocator working here.
88 DiscardableMemoryAllocator discardable_memory_allocator_;
90 scoped_ptr<scheduler::RendererScheduler> renderer_scheduler_;
91 scoped_ptr<BlinkPlatformImpl> blink_platform_;
92 base::Thread compositor_thread_;
93 scoped_ptr<MediaFactory> media_factory_;
95 DISALLOW_COPY_AND_ASSIGN(Setup);
98 } // namespace html_viewer
100 #endif // COMPONENTS_HTML_VIEWER_SETUP_H_