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

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

Issue 2512473004: cros: Enable WebUILoginView reuse. (Closed)
Patch Set: Address comments Created 4 years 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 owned by the current user's
25 // profile. This allows for a WebView to be reused over time or preloaded. Use
xiyuan 2016/12/12 18:51:11 "the current user's profile" -> the sign-in profil
jdufault 2016/12/12 19:50:27 Done.
26 // SharedWebViewFactory to get an instance of this class per profile.
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 private:
41 // content::NotificationObserver:
42 void Observe(int type,
43 const content::NotificationSource& source,
44 const content::NotificationDetails& details) override;
45
46 // Called when there is a memory pressure event.
47 void OnMemoryPressure(
48 base::MemoryPressureListener::MemoryPressureLevel level);
49
50 content::NotificationRegistrar registrar_;
51
52 // Profile used for creating the views::WebView instance.
53 Profile* const profile_;
54
55 // Cached URL that the |web_view_| instance should point to used for
56 // validation.
57 GURL web_view_url_;
58
59 // Shared web-view instance. Callers may take a reference on the handle so it
60 // could outlive this class.
61 scoped_refptr<WebViewHandle> web_view_handle_;
62
63 std::unique_ptr<base::MemoryPressureListener> memory_pressure_listener_;
64
65 DISALLOW_COPY_AND_ASSIGN(SharedWebView);
66 };
67
68 } // namespace chromeos
69
70 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_UI_SHARED_WEB_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/ui/login_display_host_impl.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