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

Side by Side Diff: chrome/browser/chromeos/login/ui/shared_web_view.h

Issue 2610373002: cros: Only preload the lock screen; do not reuse it. (Closed)
Patch Set: Address comments Created 3 years, 11 months 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
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_UI_SHARED_WEB_VIEW_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_UI_SHARED_WEB_VIEW_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "base/memory/memory_pressure_listener.h"
12 #include "base/memory/ref_counted.h"
13 #include "components/keyed_service/core/keyed_service.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
16 #include "url/gurl.h"
17
18 class Profile;
19
20 namespace chromeos {
21
22 class WebViewHandle;
23
24 // Stores and fetches a views::WebView instance that is ulimately owned by the
25 // signin profile. This allows for a WebView to be reused over time or
26 // preloaded. Use SharedWebViewFactory to get an instance of this class.
27 class SharedWebView : public KeyedService,
28 public content::NotificationObserver {
29 public:
30 explicit SharedWebView(Profile* profile);
31 ~SharedWebView() override;
32 void Shutdown() override;
33
34 // Stores a webview instance inside of |out_handle|. |url| is the initial
35 // URL that the webview stores (note: this function does not perform the
36 // navigation). This returns true if the webview was reused, false if it
37 // was freshly created.
38 bool Get(const GURL& url, scoped_refptr<WebViewHandle>* out_handle);
39
40 // Returns true if there is an attached views::WebView instance.
41 bool has_web_view() const { return !!web_view_handle_; }
42
43 private:
44 // content::NotificationObserver:
45 void Observe(int type,
46 const content::NotificationSource& source,
47 const content::NotificationDetails& details) override;
48
49 // Called when there is a memory pressure event.
50 void OnMemoryPressure(
51 base::MemoryPressureListener::MemoryPressureLevel level);
52
53 content::NotificationRegistrar registrar_;
54
55 // Profile used for creating the views::WebView instance.
56 Profile* const profile_;
57
58 // Cached URL that the |web_view_| instance should point to used for
59 // validation.
60 GURL web_view_url_;
61
62 // Shared web-view instance. Callers may take a reference on the handle so it
63 // could outlive this class.
64 scoped_refptr<WebViewHandle> web_view_handle_;
65
66 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_;
67
68 DISALLOW_COPY_AND_ASSIGN(SharedWebView);
69 };
70
71 } // namespace chromeos
72
73 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_UI_SHARED_WEB_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/ui/preloaded_web_view_factory.cc ('k') | chrome/browser/chromeos/login/ui/shared_web_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698