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

Side by Side Diff: content/renderer/unique_name_helper.h

Issue 2714943004: Move unique name generation and tracking into //content. (Closed)
Patch Set: . Created 3 years, 9 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 2017 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 // Description of the current unique name format
6 // ---------------------------------------------
7 //
8 // Changing the format of unique name is undesirable, because it breaks
9 // backcompatibility of session history (which stores unique names
10 // generated in the past on user's disk). This incremental,
11 // backcompatibility-aware approach has resulted so far in the following
12 // rather baroque format... :
13 //
14 // uniqueName ::= <nullForMainFrame> | <assignedName> | <generatedName>
15 // (generatedName is used if assignedName is
16 // non-unique / conflicts with other frame's unique name.
17 //
18 // assignedName ::= value of iframe's name attribute
19 // or value assigned to window.name (*before* the first
20 // real commit - afterwards unique name stays immutable).
21 //
22 // generatedName ::= oldGeneratedName newUniqueSuffix?
23 // (newUniqueSuffix is only present if oldGeneratedName was
24 // not unique after all)
25 //
26 // oldGeneratedName ::= "<!--framePath //" ancestorChain
27 // "/<!--frame" childCount "-->-->"
28 // (oldGeneratedName is generated by
29 // generateUniqueNameCandidate method).
30 //
31 // childCount ::= current number of siblings
32 //
33 // ancestorChain ::= concatenated unique names of ancestor chain,
34 // terminated on the first ancestor (if any) starting with
35 // "<!--framePath"; each ancestor's unique name is
36 // separated by "/" character
37 // ancestorChain example1: "grandparent/parent"
38 // (ancestor's unique names : #1--^ | #2-^ )
39 // ancestorChain example2:
40 // "<!--framePath //foo/bar/<!--frame42-->-->/blah/foobar"
41 // (ancestor's unique names:
42 // ^--#1--^ | #2 | #3-^ )
43 //
44 // newUniqueSuffix ::= "<!--framePosition" framePosition "/" retryNumber
45 // "-->"
46 //
47 // framePosition ::= "-" numberOfSiblingsBeforeChild
48 // [ framePosition-forParent? ]
49 //
50 // retryNumber ::= smallest non-negative integer resulting in unique name
51
52 #ifndef CONTENT_RENDERER_UNIQUE_NAME_HELPER_H_
53 #define CONTENT_RENDERER_UNIQUE_NAME_HELPER_H_
54
55 #include <string>
56
57 #include "base/macros.h"
58
59 namespace blink {
60 class WebFrame;
61 class WebLocalFrame;
62 } // namespace blink
63
64 namespace content {
65
66 class RenderFrameImpl;
67
68 class UniqueNameHelper {
69 public:
70 explicit UniqueNameHelper(RenderFrameImpl* render_frame);
71 ~UniqueNameHelper();
72
73 const std::string& value() const { return unique_name_; }
74
75 void set_from_replicated_state(const std::string& unique_name) {
76 unique_name_ = unique_name;
77 }
78
79 // Note: |parent| needs to be plumbed in for new child frames, since the
80 // unique name needs to be calculated before the new child RenderFrameImpl is
81 // created.
82 static std::string GenerateNameForNewChildFrame(blink::WebFrame* parent,
83 const std::string& name);
84
85 void UpdateName(const std::string& name);
86
87 private:
88 blink::WebLocalFrame* GetWebFrame() const;
89
90 RenderFrameImpl* const render_frame_;
91 std::string unique_name_;
92
93 DISALLOW_COPY_AND_ASSIGN(UniqueNameHelper);
94 };
95
96 } // namespace content
97
98 #endif // CONTENT_RENDERER_UNIQUE_NAME_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698